Skip to content

Commit 72c065a

Browse files
committed
clippy auto-fixes
1 parent 9955a0f commit 72c065a

File tree

15 files changed

+39
-52
lines changed

15 files changed

+39
-52
lines changed

calc/expr.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,12 @@ fn logop(lhs: &Token, rhs: &Token, is_and: bool) -> Token {
227227
} else {
228228
Token::Integer(0)
229229
}
230+
} else if !lhs_zero {
231+
lhs.clone()
232+
} else if !rhs_zero {
233+
rhs.clone()
230234
} else {
231-
if !lhs_zero {
232-
lhs.clone()
233-
} else if !rhs_zero {
234-
rhs.clone()
235-
} else {
236-
Token::Integer(0)
237-
}
235+
Token::Integer(0)
238236
}
239237
}
240238

datetime/cal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
102102
// If no arguments are provided, display the current month
103103
if args.month.is_none() && args.year.is_none() {
104104
let now = chrono::Local::now();
105-
args.month = Some(now.month() as u32);
105+
args.month = Some(now.month());
106106
args.year = Some(now.year() as u32);
107107

108108
// If only one argument is provided, assume it is the entire year

editors/vi/editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ impl Editor {
25672567
if let Some('=') = ztype {
25682568
// For '=', print separator line around current line
25692569
let cols = self.terminal.size().cols as usize;
2570-
let separator: String = std::iter::repeat('-').take(40.min(cols / 2)).collect();
2570+
let separator: String = "-".repeat(40.min(cols / 2));
25712571
let half = count / 2;
25722572
let before_start = target_line.saturating_sub(half).max(1);
25732573

fs/df.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl Mount {
238238
let percentage_used = percentage_used.ceil() as u32;
239239

240240
FieldsData {
241-
fields: fields,
241+
fields,
242242
source: &self.devname,
243243
size: total,
244244
used,

ftw/src/dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct EntryInternal<'a> {
1616
phantom: PhantomData<&'a libc::dirent>,
1717
}
1818

19-
impl<'a> EntryInternal<'a> {
19+
impl EntryInternal<'_> {
2020
pub fn name_cstr(&self) -> &CStr {
2121
// Avoid dereferencing `dirent` when getting its fields. See note at:
2222
// https://github.com/rust-lang/rust/blob/1.80.1/library/std/src/sys/pal/unix/fs.rs#L725-L742
@@ -193,7 +193,7 @@ pub struct DeferredDirIterator<'a> {
193193
visited: RefMut<'a, HashSet<libc::ino_t>>,
194194
}
195195

196-
impl<'a> Drop for DeferredDirIterator<'a> {
196+
impl Drop for DeferredDirIterator<'_> {
197197
fn drop(&mut self) {
198198
unsafe {
199199
libc::closedir(self.dirp);

mailx/mailbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Mailbox {
230230

231231
// Decide whether to show To or From
232232
let address_field = if show_to && msg.from().contains(&user) {
233-
format!("To {}", truncate(&msg.to().to_string(), 18))
233+
format!("To {}", truncate(msg.to(), 18))
234234
} else {
235235
msg.from_short()
236236
};

mailx/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn run_receive_mode(args: &Args) -> i32 {
9898
}
9999

100100
let mailbox_path = if args.read_mbox {
101-
args.file.clone().unwrap_or_else(|| get_mbox_path())
101+
args.file.clone().unwrap_or_else(get_mbox_path)
102102
} else {
103103
args.file.clone().unwrap_or_else(get_system_mailbox)
104104
};

process/kill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn send_signal(prog_cfg: &Config, sig_no: i32) -> u32 {
7272
let mut exit_code = 0;
7373

7474
for pid in &prog_cfg.pids {
75-
let res = unsafe { libc::kill(*pid as libc::pid_t, sig_no as i32) };
75+
let res = unsafe { libc::kill(*pid as libc::pid_t, sig_no) };
7676
if res != 0 {
7777
let err = std::io::Error::last_os_error();
7878
eprintln!("kill pid {}: {}", pid, err);

text/comm.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,11 @@ fn comm_file(
9292
let mut want2 = true;
9393

9494
loop {
95-
if want1 && buf1.is_empty() {
96-
if rdr1.read_line(&mut buf1)? == 0 {
97-
want1 = false;
98-
}
95+
if want1 && buf1.is_empty() && rdr1.read_line(&mut buf1)? == 0 {
96+
want1 = false;
9997
}
100-
if want2 && buf2.is_empty() {
101-
if rdr2.read_line(&mut buf2)? == 0 {
102-
want2 = false;
103-
}
98+
if want2 && buf2.is_empty() && rdr2.read_line(&mut buf2)? == 0 {
99+
want2 = false;
104100
}
105101

106102
if buf1.is_empty() && buf2.is_empty() {

tree/chown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ enum ParseOwnerGroupResult {
7272

7373
fn parse_owner_group(owner_group: &str) -> Result<ParseOwnerGroupResult, String> {
7474
if owner_group.is_empty() || owner_group == ":" {
75-
return Ok(ParseOwnerGroupResult::EmptyOrColon);
75+
Ok(ParseOwnerGroupResult::EmptyOrColon)
7676
} else {
7777
match owner_group.split_once(':') {
7878
None => {

0 commit comments

Comments
 (0)