diff --git a/compiler/rustc_arena/src/tests.rs b/compiler/rustc_arena/src/tests.rs index bfde8abd5893a..eb9406d691b10 100644 --- a/compiler/rustc_arena/src/tests.rs +++ b/compiler/rustc_arena/src/tests.rs @@ -19,8 +19,8 @@ impl TypedArena { unsafe { // Clear the last chunk, which is partially filled. let mut chunks_borrow = self.chunks.borrow_mut(); - if let Some(mut last_chunk) = chunks_borrow.last_mut() { - self.clear_last_chunk(&mut last_chunk); + if let Some(last_chunk) = chunks_borrow.last_mut() { + self.clear_last_chunk(last_chunk); let len = chunks_borrow.len(); // If `T` is ZST, code below has no effect. for mut chunk in chunks_borrow.drain(..len - 1) { diff --git a/compiler/rustc_fluent_macro/src/fluent.rs b/compiler/rustc_fluent_macro/src/fluent.rs index d58c70674f6aa..e383d085bb3d3 100644 --- a/compiler/rustc_fluent_macro/src/fluent.rs +++ b/compiler/rustc_fluent_macro/src/fluent.rs @@ -265,7 +265,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok Level::Error, format!("referenced message `{mref}` does not exist (in message `{name}`)"), ) - .help(&format!("you may have meant to use a variable reference (`{{${mref}}}`)")) + .help(format!("you may have meant to use a variable reference (`{{${mref}}}`)")) .emit(); } } diff --git a/compiler/rustc_graphviz/src/tests.rs b/compiler/rustc_graphviz/src/tests.rs index bf2f43fde2ee9..6a569d10c34a8 100644 --- a/compiler/rustc_graphviz/src/tests.rs +++ b/compiler/rustc_graphviz/src/tests.rs @@ -63,10 +63,10 @@ impl NodeLabels<&'static str> { } fn len(&self) -> usize { - match self { - &UnlabelledNodes(len) => len, - &AllNodesLabelled(ref lbls) => lbls.len(), - &SomeNodesLabelled(ref lbls) => lbls.len(), + match *self { + UnlabelledNodes(len) => len, + AllNodesLabelled(ref lbls) => lbls.len(), + SomeNodesLabelled(ref lbls) => lbls.len(), } } } diff --git a/compiler/rustc_hashes/src/lib.rs b/compiler/rustc_hashes/src/lib.rs index 3755caaaa2963..c8f3057dac5fc 100644 --- a/compiler/rustc_hashes/src/lib.rs +++ b/compiler/rustc_hashes/src/lib.rs @@ -54,7 +54,7 @@ impl FromStableHash for Hash64 { type Hash = StableHasherHash; #[inline] - fn from(StableHasherHash([_0, __1]): Self::Hash) -> Self { + fn from(StableHasherHash([_0, _]): Self::Hash) -> Self { Self { inner: _0 } } } diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 2cfda7a5fb4b2..d5c43c4fa0661 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -197,7 +197,7 @@ fn main() { // Include path contains host directory, replace it with target if is_crossed && flag.starts_with("-I") { - cfg.flag(&flag.replace(&host, &target)); + cfg.flag(flag.replace(&host, &target)); continue; } diff --git a/compiler/rustc_log/src/lib.rs b/compiler/rustc_log/src/lib.rs index 26475eec1c102..0643d5b23bc51 100644 --- a/compiler/rustc_log/src/lib.rs +++ b/compiler/rustc_log/src/lib.rs @@ -73,7 +73,7 @@ impl LoggerConfig { /// Initialize the logger with the given values for the filter, coloring, and other options env variables. pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> { - init_logger_with_additional_layer(cfg, || Registry::default()) + init_logger_with_additional_layer(cfg, Registry::default) } /// Trait alias for the complex return type of `build_subscriber` in @@ -145,14 +145,11 @@ where .with_thread_ids(verbose_thread_ids) .with_thread_names(verbose_thread_ids); - match cfg.wraptree { - Ok(v) => match v.parse::() { - Ok(v) => { - layer = layer.with_wraparound(v); - } + if let Ok(v) = cfg.wraptree { + match v.parse::() { + Ok(v) => layer = layer.with_wraparound(v), Err(_) => return Err(Error::InvalidWraptree(v)), - }, - Err(_) => {} // no wraptree + } } let subscriber = build_subscriber().with(layer.with_filter(filter)); diff --git a/compiler/rustc_thread_pool/src/registry.rs b/compiler/rustc_thread_pool/src/registry.rs index 22d3a78604523..4a018ea743aea 100644 --- a/compiler/rustc_thread_pool/src/registry.rs +++ b/compiler/rustc_thread_pool/src/registry.rs @@ -808,7 +808,7 @@ impl WorkerThread { latch: &L, mut all_jobs_started: impl FnMut() -> bool, mut is_job: impl FnMut(&JobRef) -> bool, - mut execute_job: impl FnMut(JobRef) -> (), + mut execute_job: impl FnMut(JobRef), ) { let mut jobs = SmallVec::<[JobRef; 8]>::new(); let mut broadcast_jobs = SmallVec::<[JobRef; 8]>::new(); diff --git a/compiler/rustc_thread_pool/src/scope/tests.rs b/compiler/rustc_thread_pool/src/scope/tests.rs index 9b9ac98d066c2..cdd378096c41d 100644 --- a/compiler/rustc_thread_pool/src/scope/tests.rs +++ b/compiler/rustc_thread_pool/src/scope/tests.rs @@ -168,7 +168,7 @@ fn the_final_countdown<'scope>( let top_of_stack = 0; let p = bottom_of_stack as *const i32 as usize; let q = &top_of_stack as *const i32 as usize; - let diff = if p > q { p - q } else { q - p }; + let diff = p.abs_diff(q); let mut data = max.lock().unwrap(); *data = Ord::max(diff, *data); diff --git a/compiler/rustc_thread_pool/src/thread_pool/tests.rs b/compiler/rustc_thread_pool/src/thread_pool/tests.rs index f2baab4c85986..a77af7b73e087 100644 --- a/compiler/rustc_thread_pool/src/thread_pool/tests.rs +++ b/compiler/rustc_thread_pool/src/thread_pool/tests.rs @@ -97,7 +97,7 @@ fn failed_thread_stack() { // macOS and Windows weren't fazed, or at least didn't fail the way we want. // They work with `isize::MAX`, but 32-bit platforms may feasibly allocate a // 2GB stack, so it might not fail until the second thread. - let stack_size = ::std::isize::MAX as usize; + let stack_size = isize::MAX as usize; let (start_count, start_handler) = count_handler(); let (exit_count, exit_handler) = count_handler(); diff --git a/compiler/rustc_thread_pool/src/worker_local.rs b/compiler/rustc_thread_pool/src/worker_local.rs index d108c91f9ee53..912001233bfea 100644 --- a/compiler/rustc_thread_pool/src/worker_local.rs +++ b/compiler/rustc_thread_pool/src/worker_local.rs @@ -43,7 +43,7 @@ impl WorkerLocal { unsafe { let worker_thread = WorkerThread::current(); if worker_thread.is_null() - || &*(*worker_thread).registry as *const _ != &*self.registry as *const _ + || !std::ptr::eq(&*(*worker_thread).registry, &*self.registry) { panic!("WorkerLocal can only be used on the thread pool it was created on") } @@ -55,7 +55,7 @@ impl WorkerLocal { impl WorkerLocal> { /// Joins the elements of all the worker locals into one Vec pub fn join(self) -> Vec { - self.into_inner().into_iter().flat_map(|v| v).collect() + self.into_inner().into_iter().flatten().collect() } } diff --git a/compiler/rustc_type_ir_macros/src/lib.rs b/compiler/rustc_type_ir_macros/src/lib.rs index 3a10d0d41ef32..37617b789dba7 100644 --- a/compiler/rustc_type_ir_macros/src/lib.rs +++ b/compiler/rustc_type_ir_macros/src/lib.rs @@ -197,10 +197,10 @@ fn lift(mut ty: syn::Type) -> syn::Type { impl VisitMut for ItoJ { fn visit_type_path_mut(&mut self, i: &mut syn::TypePath) { if i.qself.is_none() { - if let Some(first) = i.path.segments.first_mut() { - if first.ident == "I" { - *first = parse_quote! { J }; - } + if let Some(first) = i.path.segments.first_mut() + && first.ident == "I" + { + *first = parse_quote! { J }; } } syn::visit_mut::visit_type_path_mut(self, i);