Skip to content

Commit 0e1a2db

Browse files
authored
Merge pull request #8769 from bakanovskii/uucore-fix-clippy
uucore: fix clippy warnings
2 parents 5c15d79 + 089faa5 commit 0e1a2db

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed

src/uucore/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn detect_target_utility() -> Option<String> {
7979
// Auto-detect utility name from CARGO_PKG_NAME if it's a uu_* package
8080
if let Ok(pkg_name) = env::var("CARGO_PKG_NAME") {
8181
if let Some(util_name) = pkg_name.strip_prefix("uu_") {
82-
println!("cargo:warning=Auto-detected utility name: {}", util_name);
82+
println!("cargo:warning=Auto-detected utility name: {util_name}");
8383
return Some(util_name.to_string());
8484
}
8585
}

src/uucore/src/lib/features/sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ mod tests {
609609
crc.hash_finalize(&mut output);
610610
let result = u64::from_ne_bytes(output);
611611

612-
assert_eq!(result, expected, "CRC mismatch for input: '{}'", input);
612+
assert_eq!(result, expected, "CRC mismatch for input: '{input}'");
613613
}
614614
}
615615

src/uucore/src/lib/features/systemd_logind.rs

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod login {
5656
let result = unsafe { ffi::sd_get_sessions(&mut sessions_ptr) };
5757

5858
if result < 0 {
59-
return Err(format!("sd_get_sessions failed: {}", result).into());
59+
return Err(format!("sd_get_sessions failed: {result}").into());
6060
}
6161

6262
let mut sessions = Vec::new();
@@ -89,11 +89,9 @@ mod login {
8989
let result = unsafe { ffi::sd_session_get_uid(session_cstring.as_ptr(), &mut uid) };
9090

9191
if result < 0 {
92-
return Err(format!(
93-
"sd_session_get_uid failed for session '{}': {}",
94-
session_id, result
95-
)
96-
.into());
92+
return Err(
93+
format!("sd_session_get_uid failed for session '{session_id}': {result}",).into(),
94+
);
9795
}
9896

9997
Ok(uid)
@@ -108,8 +106,7 @@ mod login {
108106

109107
if result < 0 {
110108
return Err(format!(
111-
"sd_session_get_start_time failed for session '{}': {}",
112-
session_id, result
109+
"sd_session_get_start_time failed for session '{session_id}': {result}",
113110
)
114111
.into());
115112
}
@@ -125,11 +122,9 @@ mod login {
125122
let result = unsafe { ffi::sd_session_get_tty(session_cstring.as_ptr(), &mut tty_ptr) };
126123

127124
if result < 0 {
128-
return Err(format!(
129-
"sd_session_get_tty failed for session '{}': {}",
130-
session_id, result
131-
)
132-
.into());
125+
return Err(
126+
format!("sd_session_get_tty failed for session '{session_id}': {result}",).into(),
127+
);
133128
}
134129

135130
if tty_ptr.is_null() {
@@ -156,8 +151,7 @@ mod login {
156151

157152
if result < 0 {
158153
return Err(format!(
159-
"sd_session_get_remote_host failed for session '{}': {}",
160-
session_id, result
154+
"sd_session_get_remote_host failed for session '{session_id}': {result}",
161155
)
162156
.into());
163157
}
@@ -186,8 +180,7 @@ mod login {
186180

187181
if result < 0 {
188182
return Err(format!(
189-
"sd_session_get_display failed for session '{}': {}",
190-
session_id, result
183+
"sd_session_get_display failed for session '{session_id}': {result}",
191184
)
192185
.into());
193186
}
@@ -214,11 +207,9 @@ mod login {
214207
let result = unsafe { ffi::sd_session_get_type(session_cstring.as_ptr(), &mut type_ptr) };
215208

216209
if result < 0 {
217-
return Err(format!(
218-
"sd_session_get_type failed for session '{}': {}",
219-
session_id, result
220-
)
221-
.into());
210+
return Err(
211+
format!("sd_session_get_type failed for session '{session_id}': {result}",).into(),
212+
);
222213
}
223214

224215
if type_ptr.is_null() {
@@ -243,11 +234,9 @@ mod login {
243234
let result = unsafe { ffi::sd_session_get_seat(session_cstring.as_ptr(), &mut seat_ptr) };
244235

245236
if result < 0 {
246-
return Err(format!(
247-
"sd_session_get_seat failed for session '{}': {}",
248-
session_id, result
249-
)
250-
.into());
237+
return Err(
238+
format!("sd_session_get_seat failed for session '{session_id}': {result}",).into(),
239+
);
251240
}
252241

253242
if seat_ptr.is_null() {
@@ -276,11 +265,11 @@ mod login {
276265
use std::fs;
277266

278267
let metadata = fs::metadata("/var/lib/systemd/random-seed")
279-
.map_err(|e| format!("Failed to read /var/lib/systemd/random-seed: {}", e))?;
268+
.map_err(|e| format!("Failed to read /var/lib/systemd/random-seed: {e}"))?;
280269

281270
metadata
282271
.modified()
283-
.map_err(|e| format!("Failed to get modification time: {}", e).into())
272+
.map_err(|e| format!("Failed to get modification time: {e}").into())
284273
}
285274
}
286275

@@ -396,7 +385,7 @@ pub fn read_login_records() -> UResult<Vec<SystemdLoginRecord>> {
396385
.to_string_lossy()
397386
.into_owned()
398387
} else {
399-
format!("{}", uid) // fallback to UID if username not found
388+
format!("{uid}") // fallback to UID if username not found
400389
}
401390
};
402391

@@ -484,7 +473,7 @@ pub fn read_login_records() -> UResult<Vec<SystemdLoginRecord>> {
484473
if !seat.is_empty() && !tty.is_empty() {
485474
// Both seat and tty - need 2 records, clone for first.
486475
// The seat is prefixed with '?' to match GNU's output.
487-
let seat_formatted = format!("?{}", seat);
476+
let seat_formatted = format!("?{seat}");
488477
records.push(create_record(
489478
seat_formatted,
490479
seat,
@@ -494,19 +483,19 @@ pub fn read_login_records() -> UResult<Vec<SystemdLoginRecord>> {
494483
));
495484

496485
let tty_formatted = if tty.starts_with("tty") {
497-
format!("*{}", tty)
486+
format!("*{tty}")
498487
} else {
499488
tty.clone()
500489
};
501490
records.push(create_record(tty_formatted, tty, user, session_id, host)); // Move for second (and last) record
502491
} else if !seat.is_empty() {
503492
// Only seat
504-
let seat_formatted = format!("?{}", seat);
493+
let seat_formatted = format!("?{seat}");
505494
records.push(create_record(seat_formatted, seat, user, session_id, host));
506495
} else if !tty.is_empty() {
507496
// Only tty
508497
let tty_formatted = if tty.starts_with("tty") {
509-
format!("*{}", tty)
498+
format!("*{tty}")
510499
} else {
511500
tty.clone()
512501
};

src/uucore/src/lib/mods/clap_localization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ mod tests {
705705

706706
for key in &required_keys {
707707
let message = get_message(key);
708-
assert_ne!(message, *key, "Translation missing for key: {}", key);
708+
assert_ne!(message, *key, "Translation missing for key: {key}");
709709
}
710710
}
711711

0 commit comments

Comments
 (0)