]> git.lizzy.rs Git - rust.git/commitdiff
some clippy-induced cleanup
authorRalf Jung <post@ralfj.de>
Wed, 8 Jun 2022 12:06:32 +0000 (08:06 -0400)
committerRalf Jung <post@ralfj.de>
Wed, 8 Jun 2022 12:06:32 +0000 (08:06 -0400)
src/concurrency/data_race.rs
src/helpers.rs
src/mono_hash_map.rs
src/shims/foreign_items.rs
src/shims/mod.rs
src/shims/unix/foreign_items.rs
src/shims/unix/fs.rs
src/shims/unix/linux/dlsym.rs
src/shims/unix/linux/foreign_items.rs
src/shims/unix/macos/foreign_items.rs
src/shims/windows/foreign_items.rs

index 28b09d2f909a3e9437de5c5a6ea87a67b19648b8..c81eab1ad23e6c956be65993d21cfd63765c0bf0 100644 (file)
@@ -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())
         }
index 4c79633c72deac3821f0faa3350e7c83dc433022..c14aca6c781a74e6627c3211cbd66d81f4ef86b3 100644 (file)
@@ -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.
index 1ae2083d5661c852e377b003044023b4fefa9363..45057632df9b528274b767cbc76c4f87a8eeeb52 100644 (file)
@@ -61,7 +61,7 @@ fn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V>
 
     #[inline(always)]
     fn filter_map_collect<T>(&self, mut f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T> {
-        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
index 12b5b40e69e88b38c86e15d04b8e226238363a59..a81dcdc110f1cc227a6b33981dcfa7ef4fe6a083 100644 (file)
@@ -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!(),
index cdffe2f65b4fce56391b7d059c6ea554782c693c..f2688bb08caa41b00b5e0369667ce74f42a4c80a 100644 (file)
@@ -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
index 32cf7e6f891ff83e7d0d6430a7e7278b32aca0e5..5f59426bc5bcea3281ce4f6fcbe9bacace692da2 100644 (file)
@@ -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)?;
index d02410664bd42a895c2790555609ac9c41136aef..c68845571034585f1331d7f34a577715b3eb17f1 100644 (file)
@@ -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!(
index 72e8c7f16f8530f862f92b0c4aec0612ca995b5a..01bf17db9f09cf7df80b56d230a4c047a07b7967 100644 (file)
@@ -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<Dlsym>> {
-        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.
index 7a9c687fcd764856edee30839bacbf9e8f8f67a6..ab3f39147c60fa0a55613753dbdf07e830f65d77 100644 (file)
@@ -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)?;
index a1adfa0d2fda50c899072bdd397f98f1098e5559..f7dd38f639b0a697c1683da3b947b26d1ae122aa 100644 (file)
@@ -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)?;
index 05f9aed1747651bf9b50b26532a90320db2a4fa6..08a319159bc590c9827428b20f73604724bc5e65 100644 (file)
@@ -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] =