diff --git a/build.rs b/build.rs index 37c626baab58a..0977c0ba016bd 100644 --- a/build.rs +++ b/build.rs @@ -4,5 +4,5 @@ fn main() { // Re-export the TARGET environment variable so it can // be accessed by miri. let target = std::env::var("TARGET").unwrap(); - println!("cargo:rustc-env=TARGET={}", target); + println!("cargo:rustc-env=TARGET={target}"); } diff --git a/cargo-miri/src/phases.rs b/cargo-miri/src/phases.rs index 0c1f039d6cc09..22da80be90211 100644 --- a/cargo-miri/src/phases.rs +++ b/cargo-miri/src/phases.rs @@ -34,7 +34,7 @@ Examples: "#; fn show_help() { - println!("{}", CARGO_MIRI_HELP); + println!("{CARGO_MIRI_HELP}"); } fn show_version() { @@ -52,7 +52,7 @@ fn forward_patched_extern_arg(args: &mut impl Iterator, cmd: &mut let path = args.next().expect("`--extern` should be followed by a filename"); if let Some(lib) = path.strip_suffix(".rlib") { // If this is an rlib, make it an rmeta. - cmd.arg(format!("{}.rmeta", lib)); + cmd.arg(format!("{lib}.rmeta")); } else { // Some other extern file (e.g. a `.so`). Forward unchanged. cmd.arg(path); @@ -336,7 +336,7 @@ pub fn phase_rustc(mut args: impl Iterator, phase: RustcPhase) { "[cargo-miri rustc inside rustdoc] captured input:\n{}", std::str::from_utf8(&env.stdin).unwrap() ); - eprintln!("[cargo-miri rustc inside rustdoc] going to run:\n{:?}", cmd); + eprintln!("[cargo-miri rustc inside rustdoc] going to run:\n{cmd:?}"); } exec_with_pipe(cmd, &env.stdin, format!("{}.stdin", out_filename("", "").display())); @@ -374,7 +374,7 @@ pub fn phase_rustc(mut args: impl Iterator, phase: RustcPhase) { val.push("metadata"); } } - cmd.arg(format!("{}={}", emit_flag, val.join(","))); + cmd.arg(format!("{emit_flag}={}", val.join(","))); } else if arg == "--extern" { // Patch `--extern` filenames, since Cargo sometimes passes stub `.rlib` files: // https://github.com/rust-lang/miri/issues/1705 @@ -535,7 +535,7 @@ pub fn phase_runner(mut binary_args: impl Iterator, phase: Runner // Run it. debug_cmd("[cargo-miri runner]", verbose, &cmd); match phase { - RunnerPhase::Rustdoc => exec_with_pipe(cmd, &info.stdin, format!("{}.stdin", binary)), + RunnerPhase::Rustdoc => exec_with_pipe(cmd, &info.stdin, format!("{binary}.stdin")), RunnerPhase::Cargo => exec(cmd), } } diff --git a/cargo-miri/src/util.rs b/cargo-miri/src/util.rs index aabe5547e5c9a..60f39cb36abaa 100644 --- a/cargo-miri/src/util.rs +++ b/cargo-miri/src/util.rs @@ -83,7 +83,7 @@ pub fn escape_for_toml(s: &str) -> String { // We want to surround this string in quotes `"`. So we first escape all quotes, // and also all backslashes (that are used to escape quotes). let s = s.replace('\\', r#"\\"#).replace('"', r#"\""#); - format!("\"{}\"", s) + format!("\"{s}\"") } /// Returns the path to the `miri` binary @@ -175,7 +175,7 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, text: &str) { let is_ci = env::var_os("CI").is_some() || env::var_os("TF_BUILD").is_some(); if ask && !is_ci { let mut buf = String::new(); - print!("I will run `{:?}` to {}. Proceed? [Y/n] ", cmd, text); + print!("I will run `{cmd:?}` to {text}. Proceed? [Y/n] "); io::stdout().flush().unwrap(); io::stdin().read_line(&mut buf).unwrap(); match buf.trim().to_lowercase().as_ref() { @@ -185,10 +185,10 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, text: &str) { a => show_error!("invalid answer `{}`", a), }; } else { - eprintln!("Running `{:?}` to {}.", cmd, text); + eprintln!("Running `{cmd:?}` to {text}."); } - if cmd.status().unwrap_or_else(|_| panic!("failed to execute {:?}", cmd)).success().not() { + if cmd.status().unwrap_or_else(|_| panic!("failed to execute {cmd:?}")).success().not() { show_error!("failed to {}", text); } } @@ -276,12 +276,12 @@ pub fn debug_cmd(prefix: &str, verbose: usize, cmd: &Command) { // Print only what has been changed for this `cmd`. for (var, val) in cmd.get_envs() { if let Some(val) = val { - writeln!(out, "{}={:?} \\", var.to_string_lossy(), val).unwrap(); + writeln!(out, "{}={val:?} \\", var.to_string_lossy()).unwrap(); } else { writeln!(out, "--unset={}", var.to_string_lossy()).unwrap(); } } } write!(out, "{cmd:?}").unwrap(); - eprintln!("{}", out); + eprintln!("{out}"); } diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 2e114c71d662a..bd01ea655dd70 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -192,7 +192,7 @@ fn init_late_loggers(tcx: TyCtxt<'_>) { if log::Level::from_str(&var).is_ok() { env::set_var( "RUSTC_LOG", - &format!( + format!( "rustc_middle::mir::interpret={0},rustc_const_eval::interpret={0}", var ), @@ -243,7 +243,7 @@ fn host_sysroot() -> Option { ) } } - format!("{}/toolchains/{}", home, toolchain) + format!("{home}/toolchains/{toolchain}") } _ => option_env!("RUST_SYSROOT") .unwrap_or_else(|| { @@ -330,7 +330,7 @@ fn main() { } else if crate_kind == "host" { false } else { - panic!("invalid `MIRI_BE_RUSTC` value: {:?}", crate_kind) + panic!("invalid `MIRI_BE_RUSTC` value: {crate_kind:?}") }; // We cannot use `rustc_driver::main` as we need to adjust the CLI arguments. diff --git a/src/concurrency/vector_clock.rs b/src/concurrency/vector_clock.rs index 32449f8eb1884..e7e5b35ac2cd2 100644 --- a/src/concurrency/vector_clock.rs +++ b/src/concurrency/vector_clock.rs @@ -399,7 +399,7 @@ mod tests { //Test partial_cmp let compare = l.partial_cmp(&r); - assert_eq!(compare, o, "Invalid comparison\n l: {:?}\n r: {:?}", l, r); + assert_eq!(compare, o, "Invalid comparison\n l: {l:?}\n r: {r:?}"); let alt_compare = r.partial_cmp(&l); assert_eq!( alt_compare, diff --git a/src/diagnostics.rs b/src/diagnostics.rs index ecfe0cd3f8a65..ec81ffd3cd5c9 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -263,7 +263,7 @@ pub fn report_error<'tcx, 'mir>( msg.insert(0, e.to_string()); report_msg( DiagLevel::Error, - &if let Some(title) = title { format!("{}: {}", title, msg[0]) } else { msg[0].clone() }, + &if let Some(title) = title { format!("{title}: {}", msg[0]) } else { msg[0].clone() }, msg, vec![], helps, diff --git a/src/helpers.rs b/src/helpers.rs index 15833fe42adc9..4bc38d2dc3647 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -107,7 +107,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { /// Gets an instance for a path. fn resolve_path(&self, path: &[&str]) -> ty::Instance<'tcx> { self.try_resolve_path(path) - .unwrap_or_else(|| panic!("failed to find required Rust item: {:?}", path)) + .unwrap_or_else(|| panic!("failed to find required Rust item: {path:?}")) } /// Evaluates the scalar at the specified path. Returns Some(val) @@ -505,7 +505,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { RejectOpWith::WarningWithoutBacktrace => { this.tcx .sess - .warn(&format!("{} was made to return an error due to isolation", op_name)); + .warn(format!("{op_name} was made to return an error due to isolation")); Ok(()) } RejectOpWith::Warning => { diff --git a/src/machine.rs b/src/machine.rs index fc9a1170d2942..e014e2db1e1f2 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -191,12 +191,12 @@ impl interpret::Provenance for Provenance { Provenance::Concrete { alloc_id, sb } => { // Forward `alternate` flag to `alloc_id` printing. if f.alternate() { - write!(f, "[{:#?}]", alloc_id)?; + write!(f, "[{alloc_id:#?}]")?; } else { - write!(f, "[{:?}]", alloc_id)?; + write!(f, "[{alloc_id:?}]")?; } // Print Stacked Borrows tag. - write!(f, "{:?}", sb)?; + write!(f, "{sb:?}")?; } Provenance::Wildcard => { write!(f, "[wildcard]")?; diff --git a/src/range_map.rs b/src/range_map.rs index 4742a365ec38b..c8ff06a36652d 100644 --- a/src/range_map.rs +++ b/src/range_map.rs @@ -40,7 +40,7 @@ impl RangeMap { let mut left = 0usize; // inclusive let mut right = self.v.len(); // exclusive loop { - debug_assert!(left < right, "find_offset: offset {} is out-of-bounds", offset); + debug_assert!(left < right, "find_offset: offset {offset} is out-of-bounds"); let candidate = left.checked_add(right).unwrap() / 2; let elem = &self.v[candidate]; if offset < elem.range.start { diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index a49e6ba4ce386..9d0e47cd06f34 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -321,7 +321,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { return Ok(Some(body)); } - this.handle_unsupported(format!("can't call foreign function: {}", link_name))?; + this.handle_unsupported(format!("can't call foreign function: {link_name}"))?; return Ok(None); } } diff --git a/src/shims/unix/fs.rs b/src/shims/unix/fs.rs index 0610f65db113f..b152082b4deb8 100644 --- a/src/shims/unix/fs.rs +++ b/src/shims/unix/fs.rs @@ -621,7 +621,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { return Ok(-1); } - let fd = options.open(&path).map(|file| { + let fd = options.open(path).map(|file| { let fh = &mut this.machine.file_handler; fh.insert_fd(Box::new(FileHandle { file, writable })) }); @@ -1862,7 +1862,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let possibly_unique = std::env::temp_dir().join::(p.into()); - let file = fopts.open(&possibly_unique); + let file = fopts.open(possibly_unique); match file { Ok(f) => { diff --git a/src/shims/unix/linux/foreign_items.rs b/src/shims/unix/linux/foreign_items.rs index 5d000f9d121d4..dd382fff029cf 100644 --- a/src/shims/unix/linux/foreign_items.rs +++ b/src/shims/unix/linux/foreign_items.rs @@ -126,7 +126,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { futex(this, &args[1..], dest)?; } id => { - this.handle_unsupported(format!("can't execute syscall with ID {}", id))?; + this.handle_unsupported(format!("can't execute syscall with ID {id}"))?; return Ok(EmulateByNameResult::AlreadyJumped); } } diff --git a/src/stacked_borrows/diagnostics.rs b/src/stacked_borrows/diagnostics.rs index 2cc7a88704ea3..d3843b030347f 100644 --- a/src/stacked_borrows/diagnostics.rs +++ b/src/stacked_borrows/diagnostics.rs @@ -86,12 +86,12 @@ impl Invalidation { impl fmt::Display for InvalidationCause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - InvalidationCause::Access(kind) => write!(f, "{}", kind), + InvalidationCause::Access(kind) => write!(f, "{kind}"), InvalidationCause::Retag(perm, kind) => if *kind == RetagCause::FnEntry { - write!(f, "{:?} FnEntry retag", perm) + write!(f, "{perm:?} FnEntry retag") } else { - write!(f, "{:?} retag", perm) + write!(f, "{perm:?} retag") }, } } @@ -339,7 +339,7 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir // this allocation. if self.history.base.0.tag() == tag { Some(( - format!("{:?} was created here, as the base tag for {:?}", tag, self.history.id), + format!("{tag:?} was created here, as the base tag for {:?}", self.history.id), self.history.base.1.data() )) } else { @@ -381,7 +381,7 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir self.offset.bytes(), ); err_sb_ub( - format!("{}{}", action, error_cause(stack, op.orig_tag)), + format!("{action}{}", error_cause(stack, op.orig_tag)), Some(operation_summary(&op.cause.summary(), self.history.id, op.range)), op.orig_tag.and_then(|orig_tag| self.get_logs_relevant_to(orig_tag, None)), ) @@ -401,7 +401,7 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir offset = self.offset.bytes(), ); err_sb_ub( - format!("{}{}", action, error_cause(stack, op.tag)), + format!("{action}{}", error_cause(stack, op.tag)), Some(operation_summary("an access", self.history.id, op.range)), op.tag.and_then(|tag| self.get_logs_relevant_to(tag, None)), ) diff --git a/src/stacked_borrows/mod.rs b/src/stacked_borrows/mod.rs index 959e351d1a145..a2f003e6cc800 100644 --- a/src/stacked_borrows/mod.rs +++ b/src/stacked_borrows/mod.rs @@ -1153,7 +1153,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let alloc_extra = this.get_alloc_extra(alloc_id)?; let stacks = alloc_extra.stacked_borrows.as_ref().unwrap().borrow(); for (range, stack) in stacks.stacks.iter_all() { - print!("{:?}: [", range); + print!("{range:?}: ["); for i in 0..stack.len() { let item = stack.get(i).unwrap(); print!(" {:?}{:?}", item.perm(), item.tag());