Skip to content

Commit 01c37b3

Browse files
committed
Clippy fixes for 1.88
1 parent 405f32c commit 01c37b3

File tree

8 files changed

+19
-27
lines changed

8 files changed

+19
-27
lines changed

src/common/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Display for CommandAndArguments {
2525
.map(|a| a.escape_default().collect::<String>())
2626
.collect::<Vec<_>>()
2727
.join(" ");
28-
write!(f, "{} {}", cmd, args)
28+
write!(f, "{cmd} {args}")
2929
}
3030
}
3131

src/su/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl SuOptions {
411411
Err(format!("'--{}' does not take any arguments", option.long))?;
412412
}
413413
} else {
414-
Err(format!("unrecognized option '{}'", arg))?;
414+
Err(format!("unrecognized option '{arg}'"))?;
415415
}
416416
// lookup the option
417417
} else if let Some(option) = Self::SU_OPTIONS.iter().find(|o| o.long == unprefixed)
@@ -424,7 +424,7 @@ impl SuOptions {
424424
(option.set)(&mut options, None)?;
425425
}
426426
} else {
427-
Err(format!("unrecognized option '{}'", arg))?;
427+
Err(format!("unrecognized option '{arg}'"))?;
428428
}
429429
} else if let Some(unprefixed) = arg.strip_prefix('-') {
430430
// flags can be grouped, so we loop over the the characters
@@ -449,7 +449,7 @@ impl SuOptions {
449449
(option.set)(&mut options, None)?;
450450
}
451451
} else {
452-
Err(format!("unrecognized option '{}'", curr))?;
452+
Err(format!("unrecognized option '{curr}'"))?;
453453
}
454454
}
455455
} else {

src/sudo/cli/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,14 @@ impl SudoArg {
537537
// only accept arguments when one is expected
538538
// `--preserve-env` is special as it only takes an argument using this `key=value` syntax
539539
if !Self::TAKES_ARGUMENT.contains(&key) && key != "preserve-env" {
540-
Err(format!("'{}' does not take any arguments", key))?;
540+
Err(format!("'{key}' does not take any arguments"))?;
541541
}
542542
processed.push(SudoArg::Argument("--".to_string() + key, value.to_string()));
543543
} else if Self::TAKES_ARGUMENT.contains(&unprefixed) {
544544
if let Some(next) = arg_iter.next() {
545545
processed.push(SudoArg::Argument(arg, next));
546546
} else {
547-
Err(format!("'{}' expects an argument", &arg))?;
547+
Err(format!("'{arg}' expects an argument"))?;
548548
}
549549
} else {
550550
processed.push(SudoArg::Flag(arg));
@@ -572,7 +572,7 @@ impl SudoArg {
572572
// short version of --help has no arguments
573573
processed.push(SudoArg::Flag(flag));
574574
} else {
575-
Err(format!("'-{}' expects an argument", curr))?;
575+
Err(format!("'-{curr}' expects an argument"))?;
576576
}
577577
break;
578578
} else {

src/system/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ mod tests {
928928
.as_nanos();
929929
let pid = std::process::id();
930930

931-
let filename = format!("sudo_rs_test_{}_{}", pid, timestamp);
931+
let filename = format!("sudo_rs_test_{pid}_{timestamp}");
932932
let path = std::path::PathBuf::from("/tmp").join(filename);
933933
std::fs::File::options()
934934
.read(true)

src/visudo/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl VisudoOptions {
153153
Err(format!("'--{}' does not take any arguments", option.long))?;
154154
}
155155
} else {
156-
Err(format!("unrecognized option '{}'", arg))?;
156+
Err(format!("unrecognized option '{arg}'"))?;
157157
}
158158
// lookup the option
159159
} else if let Some(option) =
@@ -167,7 +167,7 @@ impl VisudoOptions {
167167
(option.set)(&mut options, None)?;
168168
}
169169
} else {
170-
Err(format!("unrecognized option '{}'", arg))?;
170+
Err(format!("unrecognized option '{arg}'"))?;
171171
}
172172
} else if arg.starts_with('-') {
173173
// flags can be grouped, so we loop over the characters
@@ -190,7 +190,7 @@ impl VisudoOptions {
190190
(option.set)(&mut options, None)?;
191191
}
192192
} else {
193-
Err(format!("unrecognized option '{}'", char))?;
193+
Err(format!("unrecognized option '{char}'"))?;
194194
}
195195
}
196196
} else {

src/visudo/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ fn run(file_arg: Option<&str>, perms: bool, owner: bool) -> io::Result<()> {
150150
.map_err(|e| {
151151
io::Error::new(
152152
e.kind(),
153-
format!(
154-
"Failed to open existing sudoers file at {:?}: {}",
155-
sudoers_path, e
156-
),
153+
format!("Failed to open existing sudoers file at {sudoers_path:?}: {e}"),
157154
)
158155
})?;
159156

@@ -163,7 +160,7 @@ fn run(file_arg: Option<&str>, perms: bool, owner: bool) -> io::Result<()> {
163160
let file = File::create(sudoers_path).map_err(|e| {
164161
io::Error::new(
165162
e.kind(),
166-
format!("Failed to create sudoers file at {:?}: {}", sudoers_path, e),
163+
format!("Failed to create sudoers file at {sudoers_path:?}: {e}"),
167164
)
168165
})?;
169166
// ogvisudo sets the permissions of the file so it can be read and written by the user and
@@ -174,8 +171,7 @@ fn run(file_arg: Option<&str>, perms: bool, owner: bool) -> io::Result<()> {
174171
io::Error::new(
175172
e.kind(),
176173
format!(
177-
"Failed to set permissions on new sudoers file at {:?}: {}",
178-
sudoers_path, e
174+
"Failed to set permissions on new sudoers file at {sudoers_path:?}: {e}"
179175
),
180176
)
181177
})?;

test-framework/sudo-compliance-tests/src/sudo/sudoers/passwd_timeout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn zero_time_out() -> Result<()> {
103103
}
104104
Some(status) => {
105105
if let Some(code) = status.code() {
106-
println!("passwd_timeout=0 exited: {:?}", code);
106+
println!("passwd_timeout=0 exited: {code:?}");
107107
println!("{:?}", child.wait());
108108
panic!();
109109
}

test-framework/sudo-test/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ impl EnvBuilder {
230230
let groupname = &group.name;
231231
assert!(
232232
!self.groups.contains_key(groupname),
233-
"group {} has already been declared",
234-
groupname
233+
"group {groupname} has already been declared",
235234
);
236235
self.groups.insert(groupname.to_string(), group);
237236

@@ -248,8 +247,7 @@ impl EnvBuilder {
248247
let username = &user.name;
249248
assert!(
250249
!self.users.contains_key(username),
251-
"user {} has already been declared",
252-
username
250+
"user {username} has already been declared",
253251
);
254252
self.users.insert(username.to_string(), user);
255253

@@ -272,13 +270,11 @@ impl EnvBuilder {
272270
pub fn user_password(&mut self, username: &str, password: &str) -> &mut Self {
273271
assert!(
274272
!self.user_passwords.contains_key(username),
275-
"password for user {} has already been declared",
276-
username
273+
"password for user {username} has already been declared",
277274
);
278275
assert!(
279276
!self.users.contains_key(username),
280-
"password for user {} should be set as part of the .user() call",
281-
username
277+
"password for user {username} should be set as part of the .user() call",
282278
);
283279
self.user_passwords
284280
.insert(username.to_string(), password.to_string());

0 commit comments

Comments
 (0)