From a310ccc9a4ff515b6fa8914970f14296caf768bc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 8 Jun 2022 08:06:32 -0400 Subject: [PATCH] some clippy-induced cleanup --- src/concurrency/data_race.rs | 7 ++----- src/helpers.rs | 2 +- src/mono_hash_map.rs | 2 +- src/shims/foreign_items.rs | 14 +++++++------- src/shims/mod.rs | 2 +- src/shims/unix/foreign_items.rs | 2 +- src/shims/unix/fs.rs | 2 +- src/shims/unix/linux/dlsym.rs | 2 +- src/shims/unix/linux/foreign_items.rs | 2 +- src/shims/unix/macos/foreign_items.rs | 2 +- src/shims/windows/foreign_items.rs | 2 +- 11 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/concurrency/data_race.rs b/src/concurrency/data_race.rs index 28b09d2f909..c81eab1ad23 100644 --- a/src/concurrency/data_race.rs +++ b/src/concurrency/data_race.rs @@ -259,10 +259,7 @@ fn new(alloc: VTimestamp, alloc_index: VectorIdx) -> Self { /// Load the internal atomic memory cells if they exist. #[inline] fn atomic(&self) -> Option<&AtomicMemoryCellClocks> { - match &self.atomic_ops { - Some(op) => Some(&*op), - None => None, - } + self.atomic_ops.as_deref() } /// Load or create the internal atomic memory metadata @@ -1482,7 +1479,7 @@ fn print_thread_metadata(&self, vector: VectorIdx) -> String { let thread_name = &self.thread_info.borrow()[thread].thread_name; if let Some(name) = thread_name { let name: &str = name; - format!("Thread(id = {:?}, name = {:?})", thread.to_u32(), &*name) + format!("Thread(id = {:?}, name = {:?})", thread.to_u32(), name) } else { format!("Thread(id = {:?})", thread.to_u32()) } diff --git a/src/helpers.rs b/src/helpers.rs index 4c79633c72d..c14aca6c781 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -255,7 +255,7 @@ fn call_function( } // Push frame. - let mir = &*this.load_mir(f.def, None)?; + let mir = this.load_mir(f.def, None)?; this.push_stack_frame(f, mir, dest, stack_pop)?; // Initialize arguments. diff --git a/src/mono_hash_map.rs b/src/mono_hash_map.rs index 1ae2083d566..45057632df9 100644 --- a/src/mono_hash_map.rs +++ b/src/mono_hash_map.rs @@ -61,7 +61,7 @@ fn remove(&mut self, k: &Q) -> Option #[inline(always)] fn filter_map_collect(&self, mut f: impl FnMut(&K, &V) -> Option) -> Vec { - self.0.borrow().iter().filter_map(move |(k, v)| f(k, &*v)).collect() + self.0.borrow().iter().filter_map(move |(k, v)| f(k, v)).collect() } /// The most interesting method: Providing a shared reference without diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 12b5b40e69e..a81dcdc110f 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -243,7 +243,7 @@ fn emulate_foreign_item( // First: functions that diverge. let ret = match ret { None => - match &*link_name.as_str() { + match link_name.as_str() { "miri_start_panic" => { // `check_shim` happens inside `handle_miri_start_panic`. this.handle_miri_start_panic(abi, link_name, args, unwind)?; @@ -259,7 +259,7 @@ fn emulate_foreign_item( let panic_impl_id = tcx.lang_items().panic_impl().unwrap(); let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id); return Ok(Some(( - &*this.load_mir(panic_impl_instance.def, None)?, + this.load_mir(panic_impl_instance.def, None)?, panic_impl_instance, ))); } @@ -361,7 +361,7 @@ fn emulate_foreign_item_by_name( // Here we dispatch all the shims for foreign functions. If you have a platform specific // shim, add it to the corresponding submodule. - match &*link_name.as_str() { + match link_name.as_str() { // Miri-specific extern functions "miri_static_root" => { let [ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?; @@ -573,7 +573,7 @@ fn emulate_foreign_item_by_name( let [f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; // FIXME: Using host floats. let f = f32::from_bits(this.read_scalar(f)?.to_u32()?); - let f = match &*link_name.as_str() { + let f = match link_name.as_str() { "cbrtf" => f.cbrt(), "coshf" => f.cosh(), "sinhf" => f.sinh(), @@ -596,7 +596,7 @@ fn emulate_foreign_item_by_name( // FIXME: Using host floats. let f1 = f32::from_bits(this.read_scalar(f1)?.to_u32()?); let f2 = f32::from_bits(this.read_scalar(f2)?.to_u32()?); - let n = match &*link_name.as_str() { + let n = match link_name.as_str() { "_hypotf" | "hypotf" => f1.hypot(f2), "atan2f" => f1.atan2(f2), _ => bug!(), @@ -615,7 +615,7 @@ fn emulate_foreign_item_by_name( let [f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; // FIXME: Using host floats. let f = f64::from_bits(this.read_scalar(f)?.to_u64()?); - let f = match &*link_name.as_str() { + let f = match link_name.as_str() { "cbrt" => f.cbrt(), "cosh" => f.cosh(), "sinh" => f.sinh(), @@ -636,7 +636,7 @@ fn emulate_foreign_item_by_name( // FIXME: Using host floats. let f1 = f64::from_bits(this.read_scalar(f1)?.to_u64()?); let f2 = f64::from_bits(this.read_scalar(f2)?.to_u64()?); - let n = match &*link_name.as_str() { + let n = match link_name.as_str() { "_hypot" | "hypot" => f1.hypot(f2), "atan2" => f1.atan2(f2), _ => bug!(), diff --git a/src/shims/mod.rs b/src/shims/mod.rs index cdffe2f65b4..f2688bb08ca 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -55,7 +55,7 @@ fn find_mir_or_eval_fn( } // Otherwise, load the MIR. - Ok(Some((&*this.load_mir(instance.def, None)?, instance))) + Ok(Some((this.load_mir(instance.def, None)?, instance))) } /// Returns `true` if the computation was performed, and `false` if we should just evaluate diff --git a/src/shims/unix/foreign_items.rs b/src/shims/unix/foreign_items.rs index 32cf7e6f891..5f59426bc5b 100644 --- a/src/shims/unix/foreign_items.rs +++ b/src/shims/unix/foreign_items.rs @@ -26,7 +26,7 @@ fn emulate_foreign_item_by_name( ) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> { let this = self.eval_context_mut(); - match &*link_name.as_str() { + match link_name.as_str() { // Environment related shims "getenv" => { let [name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; diff --git a/src/shims/unix/fs.rs b/src/shims/unix/fs.rs index d02410664bd..c6884557103 100644 --- a/src/shims/unix/fs.rs +++ b/src/shims/unix/fs.rs @@ -446,7 +446,7 @@ fn file_type_to_d_type( } } Err(e) => - return match e.raw_os_error() { + match e.raw_os_error() { Some(error) => Ok(error), None => throw_unsup_format!( diff --git a/src/shims/unix/linux/dlsym.rs b/src/shims/unix/linux/dlsym.rs index 72e8c7f16f8..01bf17db9f0 100644 --- a/src/shims/unix/linux/dlsym.rs +++ b/src/shims/unix/linux/dlsym.rs @@ -9,7 +9,7 @@ impl Dlsym { // Returns an error for unsupported symbols, and None if this symbol // should become a NULL pointer (pretend it does not exist). pub fn from_str<'tcx>(name: &str) -> InterpResult<'tcx, Option> { - Ok(match &*name { + Ok(match name { "__pthread_get_minstack" => None, "getrandom" => None, // std falls back to syscall(SYS_getrandom, ...) when this is NULL. "statx" => None, // std falls back to syscall(SYS_statx, ...) when this is NULL. diff --git a/src/shims/unix/linux/foreign_items.rs b/src/shims/unix/linux/foreign_items.rs index 7a9c687fcd7..ab3f39147c6 100644 --- a/src/shims/unix/linux/foreign_items.rs +++ b/src/shims/unix/linux/foreign_items.rs @@ -21,7 +21,7 @@ fn emulate_foreign_item_by_name( ) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> { let this = self.eval_context_mut(); - match &*link_name.as_str() { + match link_name.as_str() { // errno "__errno_location" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; diff --git a/src/shims/unix/macos/foreign_items.rs b/src/shims/unix/macos/foreign_items.rs index a1adfa0d2fd..f7dd38f639b 100644 --- a/src/shims/unix/macos/foreign_items.rs +++ b/src/shims/unix/macos/foreign_items.rs @@ -19,7 +19,7 @@ fn emulate_foreign_item_by_name( ) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> { let this = self.eval_context_mut(); - match &*link_name.as_str() { + match link_name.as_str() { // errno "__error" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; diff --git a/src/shims/windows/foreign_items.rs b/src/shims/windows/foreign_items.rs index 05f9aed1747..08a319159bc 100644 --- a/src/shims/windows/foreign_items.rs +++ b/src/shims/windows/foreign_items.rs @@ -28,7 +28,7 @@ fn emulate_foreign_item_by_name( // DWORD = ULONG = u32 // BOOL = i32 // BOOLEAN = u8 - match &*link_name.as_str() { + match link_name.as_str() { // Environment related shims "GetEnvironmentVariableW" => { let [name, buf, size] = -- 2.44.0