Skip to content

Commit 22798ae

Browse files
committed
Fix 1.88 clippy lints
These show up because we run clippy checks against both MSRVs. Fortunately all of them are for 1.85-valid features.
1 parent cca8aac commit 22798ae

27 files changed

Lines changed: 108 additions & 153 deletions

age-core/src/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ xD7o4VEOu1t7KZQ1gDgq2FPzBEeSRqbnqvQEXdLRYy143BxR6oFxsUUJCRB0ErXA
526526
// should reject this artifact.
527527
match read::age_stanza(artifact.as_bytes()) {
528528
Err(nom::Err::Error(e)) => assert_eq!(e.code, ErrorKind::TakeWhileMN),
529-
Err(e) => panic!("Unexpected error: {}", e),
529+
Err(e) => panic!("Unexpected error: {e}"),
530530
Ok((rest, stanza)) => {
531531
assert_eq!(rest, b"\n");
532532
// This is where the fuzzer triggered a panic.
@@ -563,7 +563,7 @@ dy
563563
// should reject this artifact.
564564
match read::age_stanza(artifact.as_bytes()) {
565565
Err(nom::Err::Error(e)) => assert_eq!(e.code, ErrorKind::TakeWhileMN),
566-
Err(e) => panic!("Unexpected error: {}", e),
566+
Err(e) => panic!("Unexpected error: {e}"),
567567
Ok((rest, stanza)) => {
568568
assert_eq!(rest, b"\n");
569569
// This is where the fuzzer triggered a panic.
@@ -599,7 +599,7 @@ ddd
599599
// should reject this artifact.
600600
match read::age_stanza(artifact.as_bytes()) {
601601
Err(nom::Err::Error(e)) => assert_eq!(e.code, ErrorKind::TakeWhileMN),
602-
Err(e) => panic!("Unexpected error: {}", e),
602+
Err(e) => panic!("Unexpected error: {e}"),
603603
Ok((rest, stanza)) => {
604604
assert_eq!(rest, b"\n");
605605
// This is where the fuzzer triggered a panic.

age-core/src/plugin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Connection<DebugReader<ChildStdout>, DebugWriter<ChildStdin>> {
7676
let working_dir = tempfile::tempdir()?;
7777
let debug_enabled = env::var("AGEDEBUG").map(|s| s == "plugin").unwrap_or(false);
7878
let process = Command::new(binary.canonicalize()?)
79-
.arg(format!("--age-plugin={}", state_machine))
79+
.arg(format!("--age-plugin={state_machine}"))
8080
.current_dir(working_dir.path())
8181
.stdin(Stdio::piped())
8282
.stdout(Stdio::piped())
@@ -124,7 +124,7 @@ impl<R: Read, W: Write> Connection<R, W> {
124124
cookie_factory::gen_simple(write::age_stanza(command, metadata, data), &mut self.output)
125125
.map_err(|e| match e {
126126
GenError::IoError(e) => e,
127-
e => io::Error::new(io::ErrorKind::Other, format!("{}", e)),
127+
e => io::Error::other(format!("{e}")),
128128
})
129129
.and_then(|w| w.flush())
130130
}
@@ -356,7 +356,7 @@ impl<R: Read, W: Write> BidirSend<'_, R, W> {
356356
RESPONSE_UNSUPPORTED => Ok(Err(Error::Unsupported)),
357357
tag => Err(io::Error::new(
358358
io::ErrorKind::InvalidData,
359-
format!("unexpected response: {}", tag),
359+
format!("unexpected response: {tag}"),
360360
)),
361361
}
362362
}
@@ -380,7 +380,7 @@ impl<R: Read, W: Write> BidirSend<'_, R, W> {
380380
RESPONSE_UNSUPPORTED => Ok(Err(Error::Unsupported)),
381381
tag => Err(io::Error::new(
382382
io::ErrorKind::InvalidData,
383-
format!("unexpected response: {}", tag),
383+
format!("unexpected response: {tag}"),
384384
)),
385385
}
386386
}

age-plugin/examples/age-plugin-unencrypted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const RECIPIENT_TAG: &str = PLUGIN_NAME;
2222
fn explode(location: &str) {
2323
if let Ok(s) = env::var("AGE_EXPLODES") {
2424
if s == location {
25-
panic!("Env variable AGE_EXPLODES={} is set. Boom! 💥", location);
25+
panic!("Env variable AGE_EXPLODES={location} is set. Boom! 💥");
2626
}
2727
}
2828
}

age-plugin/src/identity.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ pub(crate) fn run_v1<P: IdentityPluginV1>(mut plugin: P) -> io::Result<()> {
227227
([identity], []) => Ok(identity.clone()),
228228
_ => Err(Error::Internal {
229229
message: format!(
230-
"{} command must have exactly one metadata argument and no data",
231-
ADD_IDENTITY
230+
"{ADD_IDENTITY} command must have exactly one metadata argument and no data"
232231
),
233232
}),
234233
}),
@@ -241,15 +240,13 @@ pub(crate) fn run_v1<P: IdentityPluginV1>(mut plugin: P) -> io::Result<()> {
241240
.map(|i| (i, s))
242241
.map_err(|_| Error::Internal {
243242
message: format!(
244-
"first metadata argument to {} must be an integer",
245-
RECIPIENT_STANZA
243+
"first metadata argument to {RECIPIENT_STANZA} must be an integer"
246244
),
247245
})
248246
} else {
249247
Err(Error::Internal {
250248
message: format!(
251-
"{} command must have at least two metadata arguments",
252-
RECIPIENT_STANZA
249+
"{RECIPIENT_STANZA} command must have at least two metadata arguments"
253250
),
254251
})
255252
}
@@ -313,8 +310,7 @@ pub(crate) fn run_v1<P: IdentityPluginV1>(mut plugin: P) -> io::Result<()> {
313310
} else {
314311
errors.push(Error::Internal {
315312
message: format!(
316-
"{} file indices are not ordered and monotonically increasing",
317-
RECIPIENT_STANZA
313+
"{RECIPIENT_STANZA} file indices are not ordered and monotonically increasing"
318314
),
319315
});
320316
}
@@ -355,7 +351,7 @@ pub(crate) fn run_v1<P: IdentityPluginV1>(mut plugin: P) -> io::Result<()> {
355351
phase
356352
.send(
357353
"file-key",
358-
&[&format!("{}", file_index)],
354+
&[&format!("{file_index}")],
359355
file_key.expose_secret(),
360356
)?
361357
.unwrap();

age-plugin/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const PLUGIN_IDENTITY_PREFIX: &str = "AGE-PLUGIN-";
197197
/// A "created" time is included in the output, set to the current local time.
198198
pub fn print_new_identity(plugin_name: &str, identity: &[u8], recipient: &[u8]) {
199199
let mut identity_lower = bech32_encode(
200-
Hrp::parse_unchecked(&format!("{}{}-", PLUGIN_IDENTITY_PREFIX, plugin_name)),
200+
Hrp::parse_unchecked(&format!("{PLUGIN_IDENTITY_PREFIX}{plugin_name}-")),
201201
identity,
202202
);
203203

@@ -208,7 +208,7 @@ pub fn print_new_identity(plugin_name: &str, identity: &[u8], recipient: &[u8])
208208
println!(
209209
"# recipient: {}",
210210
bech32_encode(
211-
Hrp::parse_unchecked(&format!("{}{}", PLUGIN_RECIPIENT_PREFIX, plugin_name)),
211+
Hrp::parse_unchecked(&format!("{PLUGIN_RECIPIENT_PREFIX}{plugin_name}")),
212212
recipient,
213213
)
214214
);

age-plugin/src/recipient.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,15 @@ pub(crate) fn run_v1<P: RecipientPluginV1>(mut plugin: P) -> io::Result<()> {
269269
([recipient], []) => Ok(recipient.clone()),
270270
_ => Err(Error::Internal {
271271
message: format!(
272-
"{} command must have exactly one metadata argument and no data",
273-
ADD_RECIPIENT
272+
"{ADD_RECIPIENT} command must have exactly one metadata argument and no data"
274273
),
275274
}),
276275
}),
277276
(ADD_IDENTITY, |s| match (&s.args[..], &s.body[..]) {
278277
([identity], []) => Ok(identity.clone()),
279278
_ => Err(Error::Internal {
280279
message: format!(
281-
"{} command must have exactly one metadata argument and no data",
282-
ADD_IDENTITY
280+
"{ADD_IDENTITY} command must have exactly one metadata argument and no data"
283281
),
284282
}),
285283
}),
@@ -303,8 +301,7 @@ pub(crate) fn run_v1<P: RecipientPluginV1>(mut plugin: P) -> io::Result<()> {
303301
(Ok(r), Ok(i)) if r.is_empty() && i.is_empty() => (
304302
Err(vec![Error::Internal {
305303
message: format!(
306-
"Need at least one {} or {} command",
307-
ADD_RECIPIENT, ADD_IDENTITY
304+
"Need at least one {ADD_RECIPIENT} or {ADD_IDENTITY} command"
308305
),
309306
}]),
310307
Err(vec![]),
@@ -313,15 +310,15 @@ pub(crate) fn run_v1<P: RecipientPluginV1>(mut plugin: P) -> io::Result<()> {
313310
},
314311
match file_keys.unwrap() {
315312
Ok(f) if f.is_empty() => Err(vec![Error::Internal {
316-
message: format!("Need at least one {} command", WRAP_FILE_KEY),
313+
message: format!("Need at least one {WRAP_FILE_KEY} command"),
317314
}]),
318315
r => r,
319316
},
320317
match &labels_supported.unwrap() {
321318
Ok(v) if v.is_empty() => Ok(false),
322319
Ok(v) if v.len() == 1 => Ok(true),
323320
_ => Err(vec![Error::Internal {
324-
message: format!("Received more than one {} command", EXTENSION_LABELS),
321+
message: format!("Received more than one {EXTENSION_LABELS} command"),
325322
}]),
326323
},
327324
)

age/src/cli_common.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn confirm(query: &str, ok: &str, cancel: Option<&str>) -> pinentry::Result<bool
6767
} else {
6868
// Fall back to CLI interface.
6969
let term = console::Term::stderr();
70-
let initial = format!("{}: (y/n) ", query);
70+
let initial = format!("{query}: (y/n) ");
7171
loop {
7272
term.write_str(&initial)?;
7373
let response = term.read_line()?.to_lowercase();
@@ -126,10 +126,10 @@ pub fn read_secret(
126126
input.interact()
127127
} else {
128128
// Fall back to CLI interface.
129-
let passphrase = prompt_password(format!("{}: ", description)).map(SecretString::from)?;
129+
let passphrase = prompt_password(format!("{description}: ")).map(SecretString::from)?;
130130
if let Some(confirm_prompt) = confirm {
131131
let confirm_passphrase =
132-
prompt_password(format!("{}: ", confirm_prompt)).map(SecretString::from)?;
132+
prompt_password(format!("{confirm_prompt}: ")).map(SecretString::from)?;
133133

134134
if !bool::from(
135135
passphrase
@@ -156,7 +156,7 @@ pub struct UiCallbacks;
156156

157157
impl Callbacks for UiCallbacks {
158158
fn display_message(&self, message: &str) {
159-
eprintln!("{}", message);
159+
eprintln!("{message}");
160160
}
161161

162162
fn confirm(&self, message: &str, yes_string: &str, no_string: Option<&str>) -> Option<bool> {

age/src/cli_common/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ impl fmt::Display for ReadError {
8383
filename = filename.as_str(),
8484
line_number = line_number,
8585
),
86-
ReadError::Io(e) => write!(f, "{}", e),
86+
ReadError::Io(e) => write!(f, "{e}"),
8787
ReadError::MissingRecipientsFile(filename) => wfl!(
8888
f,
8989
"err-read-missing-recipients-file",
9090
filename = filename.as_str(),
9191
),
9292
ReadError::MultipleStdin => wfl!(f, "err-read-multiple-stdin"),
9393
#[cfg(feature = "plugin")]
94-
ReadError::PluginResolve(e) => write!(f, "{}", e),
94+
ReadError::PluginResolve(e) => write!(f, "{e}"),
9595
#[cfg(feature = "ssh")]
9696
ReadError::RsaModulusTooLarge => {
9797
wfl!(f, "err-read-rsa-modulus-too-large", max_size = 4096)

age/src/cli_common/file_io.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl LazyFile {
308308
.as_mut()
309309
.unwrap()
310310
.as_mut()
311-
.map_err(|e| io::Error::new(e.kind(), format!("Failed to open file '{}'", filename)))
311+
.map_err(|e| io::Error::new(e.kind(), format!("Failed to open file '{filename}'")))
312312
}
313313
}
314314

@@ -395,10 +395,7 @@ impl OutputWriter {
395395
} else if is_tty {
396396
if let OutputFormat::Binary = format {
397397
// If output == Some("-") then this error is skipped.
398-
return Err(io::Error::new(
399-
io::ErrorKind::Other,
400-
FileError::DenyBinaryOutput,
401-
));
398+
return Err(io::Error::other(FileError::DenyBinaryOutput));
402399
}
403400
}
404401

age/src/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ impl fmt::Display for PluginError {
157157
metadata,
158158
message,
159159
} => {
160-
write!(f, "({}", kind)?;
160+
write!(f, "({kind}")?;
161161
for d in metadata {
162-
write!(f, " {}", d)?;
162+
write!(f, " {d}")?;
163163
}
164164
write!(f, ")")?;
165165
if !message.is_empty() {
166-
write!(f, " {}", message)?;
166+
write!(f, " {message}")?;
167167
}
168168
Ok(())
169169
}
@@ -286,11 +286,11 @@ impl fmt::Display for EncryptError {
286286
#[cfg(feature = "plugin")]
287287
EncryptError::Plugin(errors) => match &errors[..] {
288288
[] => unreachable!(),
289-
[e] => write!(f, "{}", e),
289+
[e] => write!(f, "{e}"),
290290
_ => {
291291
wlnfl!(f, "err-plugin-multiple")?;
292292
for e in errors {
293-
writeln!(f, "- {}", e)?;
293+
writeln!(f, "- {e}")?;
294294
}
295295
Ok(())
296296
}
@@ -388,11 +388,11 @@ impl fmt::Display for DecryptError {
388388
#[cfg(feature = "plugin")]
389389
DecryptError::Plugin(errors) => match &errors[..] {
390390
[] => unreachable!(),
391-
[e] => write!(f, "{}", e),
391+
[e] => write!(f, "{e}"),
392392
_ => {
393393
wlnfl!(f, "err-plugin-multiple")?;
394394
for e in errors {
395-
writeln!(f, "- {}", e)?;
395+
writeln!(f, "- {e}")?;
396396
}
397397
Ok(())
398398
}

0 commit comments

Comments
 (0)