Skip to content

Commit 5a5a3e4

Browse files
committed
bless clippy
1 parent 543afa8 commit 5a5a3e4

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

src/tools/miri/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fn main() {
44
// Re-export the TARGET environment variable so it can
55
// be accessed by miri.
66
let target = std::env::var("TARGET").unwrap();
7-
println!("cargo:rustc-env=TARGET={}", target);
7+
println!("cargo:rustc-env=TARGET={target}");
88
}

src/tools/miri/cargo-miri/src/phases.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Examples:
3434
"#;
3535

3636
fn show_help() {
37-
println!("{}", CARGO_MIRI_HELP);
37+
println!("{CARGO_MIRI_HELP}");
3838
}
3939

4040
fn show_version() {
@@ -52,7 +52,7 @@ fn forward_patched_extern_arg(args: &mut impl Iterator<Item = String>, cmd: &mut
5252
let path = args.next().expect("`--extern` should be followed by a filename");
5353
if let Some(lib) = path.strip_suffix(".rlib") {
5454
// If this is an rlib, make it an rmeta.
55-
cmd.arg(format!("{}.rmeta", lib));
55+
cmd.arg(format!("{lib}.rmeta"));
5656
} else {
5757
// Some other extern file (e.g. a `.so`). Forward unchanged.
5858
cmd.arg(path);
@@ -336,7 +336,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
336336
"[cargo-miri rustc inside rustdoc] captured input:\n{}",
337337
std::str::from_utf8(&env.stdin).unwrap()
338338
);
339-
eprintln!("[cargo-miri rustc inside rustdoc] going to run:\n{:?}", cmd);
339+
eprintln!("[cargo-miri rustc inside rustdoc] going to run:\n{cmd:?}");
340340
}
341341

342342
exec_with_pipe(cmd, &env.stdin, format!("{}.stdin", out_filename("", "").display()));
@@ -374,7 +374,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
374374
val.push("metadata");
375375
}
376376
}
377-
cmd.arg(format!("{}={}", emit_flag, val.join(",")));
377+
cmd.arg(format!("{emit_flag}={}", val.join(",")));
378378
} else if arg == "--extern" {
379379
// Patch `--extern` filenames, since Cargo sometimes passes stub `.rlib` files:
380380
// https://github.com/rust-lang/miri/issues/1705
@@ -535,7 +535,7 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
535535
// Run it.
536536
debug_cmd("[cargo-miri runner]", verbose, &cmd);
537537
match phase {
538-
RunnerPhase::Rustdoc => exec_with_pipe(cmd, &info.stdin, format!("{}.stdin", binary)),
538+
RunnerPhase::Rustdoc => exec_with_pipe(cmd, &info.stdin, format!("{binary}.stdin")),
539539
RunnerPhase::Cargo => exec(cmd),
540540
}
541541
}

src/tools/miri/cargo-miri/src/util.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn escape_for_toml(s: &str) -> String {
8383
// We want to surround this string in quotes `"`. So we first escape all quotes,
8484
// and also all backslashes (that are used to escape quotes).
8585
let s = s.replace('\\', r#"\\"#).replace('"', r#"\""#);
86-
format!("\"{}\"", s)
86+
format!("\"{s}\"")
8787
}
8888

8989
/// Returns the path to the `miri` binary
@@ -175,7 +175,7 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
175175
let is_ci = env::var_os("CI").is_some() || env::var_os("TF_BUILD").is_some();
176176
if ask && !is_ci {
177177
let mut buf = String::new();
178-
print!("I will run `{:?}` to {}. Proceed? [Y/n] ", cmd, text);
178+
print!("I will run `{cmd:?}` to {text}. Proceed? [Y/n] ");
179179
io::stdout().flush().unwrap();
180180
io::stdin().read_line(&mut buf).unwrap();
181181
match buf.trim().to_lowercase().as_ref() {
@@ -185,10 +185,10 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
185185
a => show_error!("invalid answer `{}`", a),
186186
};
187187
} else {
188-
eprintln!("Running `{:?}` to {}.", cmd, text);
188+
eprintln!("Running `{cmd:?}` to {text}.");
189189
}
190190

191-
if cmd.status().unwrap_or_else(|_| panic!("failed to execute {:?}", cmd)).success().not() {
191+
if cmd.status().unwrap_or_else(|_| panic!("failed to execute {cmd:?}")).success().not() {
192192
show_error!("failed to {}", text);
193193
}
194194
}
@@ -276,12 +276,12 @@ pub fn debug_cmd(prefix: &str, verbose: usize, cmd: &Command) {
276276
// Print only what has been changed for this `cmd`.
277277
for (var, val) in cmd.get_envs() {
278278
if let Some(val) = val {
279-
writeln!(out, "{}={:?} \\", var.to_string_lossy(), val).unwrap();
279+
writeln!(out, "{}={val:?} \\", var.to_string_lossy()).unwrap();
280280
} else {
281281
writeln!(out, "--unset={}", var.to_string_lossy()).unwrap();
282282
}
283283
}
284284
}
285285
write!(out, "{cmd:?}").unwrap();
286-
eprintln!("{}", out);
286+
eprintln!("{out}");
287287
}

src/tools/miri/src/bin/miri.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn init_late_loggers(tcx: TyCtxt<'_>) {
192192
if log::Level::from_str(&var).is_ok() {
193193
env::set_var(
194194
"RUSTC_LOG",
195-
&format!(
195+
format!(
196196
"rustc_middle::mir::interpret={0},rustc_const_eval::interpret={0}",
197197
var
198198
),
@@ -243,7 +243,7 @@ fn host_sysroot() -> Option<String> {
243243
)
244244
}
245245
}
246-
format!("{}/toolchains/{}", home, toolchain)
246+
format!("{home}/toolchains/{toolchain}")
247247
}
248248
_ => option_env!("RUST_SYSROOT")
249249
.unwrap_or_else(|| {
@@ -330,7 +330,7 @@ fn main() {
330330
} else if crate_kind == "host" {
331331
false
332332
} else {
333-
panic!("invalid `MIRI_BE_RUSTC` value: {:?}", crate_kind)
333+
panic!("invalid `MIRI_BE_RUSTC` value: {crate_kind:?}")
334334
};
335335

336336
// We cannot use `rustc_driver::main` as we need to adjust the CLI arguments.

src/tools/miri/src/concurrency/vector_clock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ mod tests {
399399

400400
//Test partial_cmp
401401
let compare = l.partial_cmp(&r);
402-
assert_eq!(compare, o, "Invalid comparison\n l: {:?}\n r: {:?}", l, r);
402+
assert_eq!(compare, o, "Invalid comparison\n l: {l:?}\n r: {r:?}");
403403
let alt_compare = r.partial_cmp(&l);
404404
assert_eq!(
405405
alt_compare,

src/tools/miri/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn report_error<'tcx, 'mir>(
263263
msg.insert(0, e.to_string());
264264
report_msg(
265265
DiagLevel::Error,
266-
&if let Some(title) = title { format!("{}: {}", title, msg[0]) } else { msg[0].clone() },
266+
&if let Some(title) = title { format!("{title}: {}", msg[0]) } else { msg[0].clone() },
267267
msg,
268268
vec![],
269269
helps,

src/tools/miri/src/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
107107
/// Gets an instance for a path.
108108
fn resolve_path(&self, path: &[&str]) -> ty::Instance<'tcx> {
109109
self.try_resolve_path(path)
110-
.unwrap_or_else(|| panic!("failed to find required Rust item: {:?}", path))
110+
.unwrap_or_else(|| panic!("failed to find required Rust item: {path:?}"))
111111
}
112112

113113
/// Evaluates the scalar at the specified path. Returns Some(val)
@@ -505,7 +505,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
505505
RejectOpWith::WarningWithoutBacktrace => {
506506
this.tcx
507507
.sess
508-
.warn(&format!("{} was made to return an error due to isolation", op_name));
508+
.warn(format!("{op_name} was made to return an error due to isolation"));
509509
Ok(())
510510
}
511511
RejectOpWith::Warning => {

src/tools/miri/src/machine.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ impl interpret::Provenance for Provenance {
191191
Provenance::Concrete { alloc_id, sb } => {
192192
// Forward `alternate` flag to `alloc_id` printing.
193193
if f.alternate() {
194-
write!(f, "[{:#?}]", alloc_id)?;
194+
write!(f, "[{alloc_id:#?}]")?;
195195
} else {
196-
write!(f, "[{:?}]", alloc_id)?;
196+
write!(f, "[{alloc_id:?}]")?;
197197
}
198198
// Print Stacked Borrows tag.
199-
write!(f, "{:?}", sb)?;
199+
write!(f, "{sb:?}")?;
200200
}
201201
Provenance::Wildcard => {
202202
write!(f, "[wildcard]")?;

src/tools/miri/src/range_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<T> RangeMap<T> {
4040
let mut left = 0usize; // inclusive
4141
let mut right = self.v.len(); // exclusive
4242
loop {
43-
debug_assert!(left < right, "find_offset: offset {} is out-of-bounds", offset);
43+
debug_assert!(left < right, "find_offset: offset {offset} is out-of-bounds");
4444
let candidate = left.checked_add(right).unwrap() / 2;
4545
let elem = &self.v[candidate];
4646
if offset < elem.range.start {

src/tools/miri/src/shims/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
321321
return Ok(Some(body));
322322
}
323323

324-
this.handle_unsupported(format!("can't call foreign function: {}", link_name))?;
324+
this.handle_unsupported(format!("can't call foreign function: {link_name}"))?;
325325
return Ok(None);
326326
}
327327
}

src/tools/miri/src/shims/unix/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
621621
return Ok(-1);
622622
}
623623

624-
let fd = options.open(&path).map(|file| {
624+
let fd = options.open(path).map(|file| {
625625
let fh = &mut this.machine.file_handler;
626626
fh.insert_fd(Box::new(FileHandle { file, writable }))
627627
});
@@ -1862,7 +1862,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
18621862

18631863
let possibly_unique = std::env::temp_dir().join::<PathBuf>(p.into());
18641864

1865-
let file = fopts.open(&possibly_unique);
1865+
let file = fopts.open(possibly_unique);
18661866

18671867
match file {
18681868
Ok(f) => {

src/tools/miri/src/shims/unix/linux/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
126126
futex(this, &args[1..], dest)?;
127127
}
128128
id => {
129-
this.handle_unsupported(format!("can't execute syscall with ID {}", id))?;
129+
this.handle_unsupported(format!("can't execute syscall with ID {id}"))?;
130130
return Ok(EmulateByNameResult::AlreadyJumped);
131131
}
132132
}

src/tools/miri/src/stacked_borrows/diagnostics.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ impl Invalidation {
8686
impl fmt::Display for InvalidationCause {
8787
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8888
match self {
89-
InvalidationCause::Access(kind) => write!(f, "{}", kind),
89+
InvalidationCause::Access(kind) => write!(f, "{kind}"),
9090
InvalidationCause::Retag(perm, kind) =>
9191
if *kind == RetagCause::FnEntry {
92-
write!(f, "{:?} FnEntry retag", perm)
92+
write!(f, "{perm:?} FnEntry retag")
9393
} else {
94-
write!(f, "{:?} retag", perm)
94+
write!(f, "{perm:?} retag")
9595
},
9696
}
9797
}
@@ -339,7 +339,7 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir
339339
// this allocation.
340340
if self.history.base.0.tag() == tag {
341341
Some((
342-
format!("{:?} was created here, as the base tag for {:?}", tag, self.history.id),
342+
format!("{tag:?} was created here, as the base tag for {:?}", self.history.id),
343343
self.history.base.1.data()
344344
))
345345
} else {
@@ -381,7 +381,7 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir
381381
self.offset.bytes(),
382382
);
383383
err_sb_ub(
384-
format!("{}{}", action, error_cause(stack, op.orig_tag)),
384+
format!("{action}{}", error_cause(stack, op.orig_tag)),
385385
Some(operation_summary(&op.cause.summary(), self.history.id, op.range)),
386386
op.orig_tag.and_then(|orig_tag| self.get_logs_relevant_to(orig_tag, None)),
387387
)
@@ -401,7 +401,7 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir
401401
offset = self.offset.bytes(),
402402
);
403403
err_sb_ub(
404-
format!("{}{}", action, error_cause(stack, op.tag)),
404+
format!("{action}{}", error_cause(stack, op.tag)),
405405
Some(operation_summary("an access", self.history.id, op.range)),
406406
op.tag.and_then(|tag| self.get_logs_relevant_to(tag, None)),
407407
)

src/tools/miri/src/stacked_borrows/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
11531153
let alloc_extra = this.get_alloc_extra(alloc_id)?;
11541154
let stacks = alloc_extra.stacked_borrows.as_ref().unwrap().borrow();
11551155
for (range, stack) in stacks.stacks.iter_all() {
1156-
print!("{:?}: [", range);
1156+
print!("{range:?}: [");
11571157
for i in 0..stack.len() {
11581158
let item = stack.get(i).unwrap();
11591159
print!(" {:?}{:?}", item.perm(), item.tag());

0 commit comments

Comments
 (0)