diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 083918de0f3..dfb5a5a9891 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -115,7 +115,7 @@ fn list_targets() -> impl Iterator { get_arg_flag_value("--manifest-path").map(|m| Path::new(&m).canonicalize().unwrap()); let mut cmd = cargo_metadata::MetadataCommand::new(); - if let Some(ref manifest_path) = manifest_path { + if let Some(manifest_path) = manifest_path.as_ref() { cmd.manifest_path(manifest_path); } let mut metadata = if let Ok(metadata) = cmd.exec() { @@ -131,7 +131,7 @@ fn list_targets() -> impl Iterator { .iter() .position(|package| { let package_manifest_path = Path::new(&package.manifest_path); - if let Some(ref manifest_path) = manifest_path { + if let Some(manifest_path) = manifest_path.as_ref() { package_manifest_path == manifest_path } else { let current_dir = current_dir.as_ref().expect("could not read current directory"); @@ -368,7 +368,7 @@ path = "lib.rs" command.env("XARGO_HOME", &dir); command.env("XARGO_RUST_SRC", &rust_src); // Handle target flag. - if let Some(ref target) = target { + if let Some(target) = target.as_ref() { command.arg("--target").arg(&target); } // Finally run it! @@ -379,9 +379,9 @@ path = "lib.rs" // That should be it! But we need to figure out where xargo built stuff. // Unfortunately, it puts things into a different directory when the // architecture matches the host. - let is_host = match target { + let is_host = match target.as_ref() { None => true, - Some(target) => target == rustc_version::version_meta().unwrap().host, + Some(target) => target == &rustc_version::version_meta().unwrap().host, }; let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags @@ -583,6 +583,6 @@ fn inside_cargo_rustc() { if !exit.success() { std::process::exit(exit.code().unwrap_or(42)); }, - Err(ref e) => panic!("error running {:?}:\n{:?}", command, e), + Err(e) => panic!("error running {:?}:\n{:?}", command, e), } } diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 24e68934c66..90e532321e4 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -51,8 +51,8 @@ pub fn report_error<'tcx, 'mir>( ) -> Option { use InterpError::*; - let (title, helps) = match e.kind { - MachineStop(ref info) => { + let (title, helps) = match &e.kind { + MachineStop(info) => { let info = info.downcast_ref::().expect("invalid MachineStop payload"); use TerminationInfo::*; let title = match info { diff --git a/src/machine.rs b/src/machine.rs index 3c598373050..612f1bb328c 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -518,7 +518,7 @@ impl AllocationExtra for AllocExtra { ptr: Pointer, size: Size, ) -> InterpResult<'tcx> { - if let Some(ref stacked_borrows) = alloc.extra.stacked_borrows { + if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_ref() { stacked_borrows.memory_read(ptr, size) } else { Ok(()) @@ -531,7 +531,7 @@ impl AllocationExtra for AllocExtra { ptr: Pointer, size: Size, ) -> InterpResult<'tcx> { - if let Some(ref mut stacked_borrows) = alloc.extra.stacked_borrows { + if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_mut() { stacked_borrows.memory_written(ptr, size) } else { Ok(()) @@ -544,7 +544,7 @@ impl AllocationExtra for AllocExtra { ptr: Pointer, size: Size, ) -> InterpResult<'tcx> { - if let Some(ref mut stacked_borrows) = alloc.extra.stacked_borrows { + if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_mut() { stacked_borrows.memory_deallocated(ptr, size) } else { Ok(()) diff --git a/src/mono_hash_map.rs b/src/mono_hash_map.rs index fc33126aa2e..fb0169920ee 100644 --- a/src/mono_hash_map.rs +++ b/src/mono_hash_map.rs @@ -64,7 +64,7 @@ impl AllocMap for MonoHashMap { self.0.borrow().iter().filter_map(move |(k, v)| f(k, &*v)).collect() } - /// The most interesting method: Providing a shared ref without + /// The most interesting method: Providing a shared reference without /// holding the `RefCell` open, and inserting new data if the key /// is not used yet. /// `vacant` is called if the key is not found in the map; diff --git a/src/shims/panic.rs b/src/shims/panic.rs index 33e47147a33..281fe1e671b 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -191,7 +191,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let this = self.eval_context_mut(); match msg { - BoundsCheck { ref index, ref len } => { + BoundsCheck { index, len } => { // Forward to `panic_bounds_check` lang item. // First arg: index. diff --git a/src/shims/tls.rs b/src/shims/tls.rs index 36ad4bd9b69..cba7dde53d8 100644 --- a/src/shims/tls.rs +++ b/src/shims/tls.rs @@ -87,7 +87,7 @@ impl<'tcx> TlsData<'tcx> { pub fn store_tls(&mut self, key: TlsKey, new_data: Option>) -> InterpResult<'tcx> { match self.keys.get_mut(&key) { - Some(&mut TlsEntry { ref mut data, .. }) => { + Some(TlsEntry { data, .. }) => { trace!("TLS key {} stored: {:?}", key, new_data); *data = new_data; Ok(()) @@ -139,12 +139,12 @@ impl<'tcx> TlsData<'tcx> { Some(key) => Excluded(key), None => Unbounded, }; - for (&key, &mut TlsEntry { ref mut data, dtor }) in + for (&key, TlsEntry { data, dtor }) in thread_local.range_mut((start, Unbounded)) { if let Some(data_scalar) = *data { if let Some(dtor) = dtor { - let ret = Some((dtor, data_scalar, key)); + let ret = Some((*dtor, data_scalar, key)); *data = None; return ret; }