From d36e390d8176babedcf326581959958d447170cd Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 26 Mar 2023 16:18:30 +0200 Subject: [PATCH] Remove and fix useless drop of reference --- compiler/rustc_infer/src/infer/nll_relate/mod.rs | 2 +- compiler/rustc_middle/src/mir/visit.rs | 3 +-- library/std/src/sys/sgx/waitqueue/mod.rs | 2 +- library/std/src/sys/unix/fs.rs | 2 +- library/std/src/thread/tests.rs | 4 +++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_infer/src/infer/nll_relate/mod.rs b/compiler/rustc_infer/src/infer/nll_relate/mod.rs index 88a0a81e276..9c139d17c18 100644 --- a/compiler/rustc_infer/src/infer/nll_relate/mod.rs +++ b/compiler/rustc_infer/src/infer/nll_relate/mod.rs @@ -828,7 +828,7 @@ fn tys(&mut self, a: Ty<'tcx>, _: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { } else { match variables.probe(vid) { TypeVariableValue::Known { value: u } => { - drop(variables); + drop(inner); self.relate(u, u) } TypeVariableValue::Unknown { universe: _universe } => { diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 6718605ed0b..d13b846d96a 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -880,12 +880,11 @@ fn super_constant( ) { let Constant { span, - user_ty, + user_ty: _, // no visit method for this literal, } = constant; self.visit_span($(& $mutability)? *span); - drop(user_ty); // no visit method for this match literal { ConstantKind::Ty(ct) => self.visit_ty_const($(&$mutability)? *ct, location), ConstantKind::Val(_, ty) => self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)), diff --git a/library/std/src/sys/sgx/waitqueue/mod.rs b/library/std/src/sys/sgx/waitqueue/mod.rs index 61bb11d9a6f..ca649ebd9d5 100644 --- a/library/std/src/sys/sgx/waitqueue/mod.rs +++ b/library/std/src/sys/sgx/waitqueue/mod.rs @@ -207,7 +207,7 @@ pub fn notify_one( let mut entry_guard = entry.lock(); let tcs = entry_guard.tcs; entry_guard.wake = true; - drop(entry); + drop(entry_guard); Ok(WaitGuard { mutex_guard: Some(guard), notified_tcs: NotifiedTcs::Single(tcs) }) } else { Err(guard) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 22d2ae39713..09db5b11dbf 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1210,7 +1210,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> { // Redox doesn't appear to support `UTIME_OMIT`. // ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore // the same as for Redox. - drop(times); + let _ = times; Err(io::const_io_error!( io::ErrorKind::Unsupported, "setting file times not supported", diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 6c9ce6fa0dd..b65e2572cc5 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -375,7 +375,9 @@ fn test_scoped_threads_nll() { // this is mostly a *compilation test* for this exact function: fn foo(x: &u8) { thread::scope(|s| { - s.spawn(|| drop(x)); + s.spawn(|| match x { + _ => (), + }); }); } // let's also run it for good measure