diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index b6e18240cbab1..738e3330254b7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -626,7 +626,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let predicates = match parent.kind { hir::ExprKind::Call(callee, _) => { let ty = typeck_result.node_type_opt(callee.hir_id)?; - let ty::FnDef(fn_def_id, args) = ty.kind() else { return None }; + let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None }; tcx.predicates_of(fn_def_id).instantiate(tcx, args) } hir::ExprKind::MethodCall(..) => { diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 824125099cfde..a0e53248c9047 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -614,7 +614,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } _ => { let local = &self.body.local_decls[local]; - match local.local_info() { + match *local.local_info() { LocalInfo::StaticRef { def_id, .. } => { let span = self.infcx.tcx.def_span(def_id); err.span_label(span, format!("this `static` cannot be {acted_on}")); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index a9c00660c3a20..a3738689ed05f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -926,7 +926,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let tcx = self.infcx.tcx; let ConstraintCategory::CallArgument(Some(func_ty)) = category else { return }; - let ty::FnDef(fn_did, args) = func_ty.kind() else { return }; + let ty::FnDef(fn_did, args) = *func_ty.kind() else { return }; debug!(?fn_did, ?args); // Only suggest this on function calls, not closures @@ -938,7 +938,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let Ok(Some(instance)) = ty::Instance::try_resolve( tcx, self.infcx.typing_env(self.infcx.param_env), - *fn_did, + fn_did, self.infcx.resolve_vars_if_possible(args), ) else { return; diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 2935559147b7e..29d38af472c22 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1013,12 +1013,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { let is_implicit_coercion = coercion_source == CoercionSource::Implicit; let src_ty = op.ty(self.body, tcx); let mut src_sig = src_ty.fn_sig(tcx); - if let ty::FnDef(def_id, _) = src_ty.kind() + if let ty::FnDef(def_id, _) = *src_ty.kind() && let ty::FnPtr(_, target_hdr) = *ty.kind() && tcx.codegen_fn_attrs(def_id).safe_target_features && target_hdr.safety.is_safe() && let Some(safe_sig) = tcx.adjust_target_feature_sig( - *def_id, + def_id, src_sig, self.body.source.def_id(), ) diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index e4f99be339df5..43a4c41eaeffc 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -577,7 +577,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::Aggregate(kind, ..) => { if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref() - && let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id) + && let Some(coroutine_kind) = self.tcx.coroutine_kind(*def_id) { self.check_op(ops::Coroutine(coroutine_kind)); } diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 04773ad3f8bc1..349ad4f7fc43b 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1221,7 +1221,7 @@ fn check_impl_items_against_trait<'tcx>( match impl_trait_header.polarity { ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {} ty::ImplPolarity::Negative => { - if let [first_item_ref, ..] = impl_item_refs { + if let [first_item_ref, ..] = *impl_item_refs { let first_item_span = tcx.def_span(first_item_ref); struct_span_code_err!( tcx.dcx(), diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index c29ebe67a158e..43a4f0574f5b0 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1333,7 +1333,7 @@ fn check_region_late_boundedness<'tcx>( .iter() .map(|param| { let (LateEarlyMismatch::EarlyInImpl(impl_param_def_id, ..) - | LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = param; + | LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = *param; tcx.def_span(impl_param_def_id) }) .collect(); diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index ff919bd58ba16..18244d62f2ae6 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -2445,12 +2445,12 @@ fn is_late_bound_map( )) => { // See comments on `ConstrainedCollectorPostHirTyLowering` for why this arm does not // just consider args to be unconstrained. - let generics = self.tcx.generics_of(alias_def); + let generics = self.tcx.generics_of(*alias_def); let mut walker = ConstrainedCollectorPostHirTyLowering { arg_is_constrained: vec![false; generics.own_params.len()] .into_boxed_slice(), }; - walker.visit_ty(self.tcx.type_of(alias_def).instantiate_identity()); + walker.visit_ty(self.tcx.type_of(*alias_def).instantiate_identity()); match segments.last() { Some(hir::PathSegment { args: Some(args), .. }) => { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 2b23abce894c1..52e5cce140ad8 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -214,7 +214,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { if let [best_trait] = visible_traits .iter() .copied() - .filter(|trait_def_id| { + .filter(|&trait_def_id| { tcx.associated_items(trait_def_id) .filter_by_name_unhygienic(suggested_name) .any(|item| item.tag() == assoc_tag) @@ -1234,7 +1234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { && let name = Symbol::intern(&format!("{ident2}_{ident3}")) && let Some(item) = inherent_impls .iter() - .flat_map(|inherent_impl| { + .flat_map(|&inherent_impl| { tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name) }) .next() diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index f5c77c6800003..312b01d70f00e 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -101,7 +101,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained( let lifetimes_in_associated_types: FxHashSet<_> = tcx .associated_item_def_ids(impl_def_id) .iter() - .flat_map(|def_id| { + .flat_map(|&def_id| { let item = tcx.associated_item(def_id); match item.kind { ty::AssocKind::Type { .. } => { diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 8df75148346a7..3d044c1086b06 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef); } - match autoderef.final_ty().kind() { + match *autoderef.final_ty().kind() { ty::FnDef(def_id, _) => { let abi = self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi; self.check_call_abi(abi, call_expr.span); @@ -430,11 +430,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool { - if let ty::FnDef(def_id, _) = callee_ty.kind() + if let ty::FnDef(def_id, _) = *callee_ty.kind() && let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id) { self.tcx - .opt_parent(*def_id) + .opt_parent(def_id) .and_then(|id| self.tcx.adt_def(id).repr().scalable) .is_some() } else { diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 8baa671972139..f3ca04c6bbe27 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -2448,7 +2448,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .tcx .inherent_impls(def_id) .into_iter() - .flat_map(|i| self.tcx.associated_items(i).in_definition_order()) + .flat_map(|&i| self.tcx.associated_items(i).in_definition_order()) // Only assoc fn with no receivers. .filter(|item| item.is_fn() && !item.is_method()) .filter_map(|item| { @@ -3183,7 +3183,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check if there is an associated function with the same name. if let Some(def_id) = base_ty.peel_refs().ty_adt_def().map(|d| d.did()) { - for impl_def_id in self.tcx.inherent_impls(def_id) { + for &impl_def_id in self.tcx.inherent_impls(def_id) { for item in self.tcx.associated_items(impl_def_id).in_definition_order() { if let ExprKind::Field(base_expr, _) = expr.kind && item.name() == field.name diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index e8d5ff017cf8c..1931222bba30e 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1118,7 +1118,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // error in `validate_res_from_ribs` -- it's just difficult to tell whether the // self type has any generic types during rustc_resolve, which is what we use // to determine if this is a hard error or warning. - if std::iter::successors(Some(self.body_id.to_def_id()), |def_id| { + if std::iter::successors(Some(self.body_id.to_def_id()), |&def_id| { self.tcx.generics_of(def_id).parent }) .all(|def_id| def_id != impl_def_id) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index bdc991abf34b8..c82a779ca8326 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -567,7 +567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } if self.may_coerce(Ty::new_box(self.tcx, found), expected) { - let suggest_boxing = match found.kind() { + let suggest_boxing = match *found.kind() { ty::Tuple(tuple) if tuple.is_empty() => { errors::SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span } } diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index c5e055e68aea1..862a51288730d 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1414,7 +1414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }) .collect::>(); if !inherent_impls_candidate.is_empty() { - inherent_impls_candidate.sort_by_key(|id| self.tcx.def_path_str(id)); + inherent_impls_candidate.sort_by_key(|&id| self.tcx.def_path_str(id)); inherent_impls_candidate.dedup(); // number of types to show at most @@ -2256,7 +2256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { call_args: Option>>, ) -> Option { if let ty::Adt(adt, adt_args) = rcvr_ty.kind() { - for inherent_impl_did in self.tcx.inherent_impls(adt.did()).into_iter() { + for &inherent_impl_did in self.tcx.inherent_impls(adt.did()).into_iter() { for inherent_method in self.tcx.associated_items(inherent_impl_did).in_definition_order() { @@ -2315,7 +2315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sources: &mut Vec, sugg_span: Option, ) { - sources.sort_by_key(|source| match source { + sources.sort_by_key(|source| match *source { CandidateSource::Trait(id) => (0, self.tcx.def_path_str(id)), CandidateSource::Impl(id) => (1, self.tcx.def_path_str(id)), }); @@ -2468,7 +2468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .tcx .inherent_impls(adt_def.did()) .iter() - .flat_map(|i| self.tcx.associated_items(i).in_definition_order()) + .flat_map(|&i| self.tcx.associated_items(i).in_definition_order()) // Only assoc fn with no receivers and only if // they are resolvable .filter(|item| { @@ -2521,7 +2521,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { String::new() }; - match &items[..] { + match items[..] { [] => {} [(def_id, ret_ty)] => { err.span_note( @@ -2536,7 +2536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => { let span: MultiSpan = items .iter() - .map(|(def_id, _)| self.tcx.def_span(def_id)) + .map(|&(def_id, _)| self.tcx.def_span(def_id)) .collect::>() .into(); err.span_note( @@ -2546,7 +2546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { following associated functions:\n{}{post}", items .iter() - .map(|(def_id, _ret_ty)| self.tcx.def_path_str(def_id)) + .map(|&(def_id, _ret_ty)| self.tcx.def_path_str(def_id)) .collect::>() .join("\n") ), @@ -3518,7 +3518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { traits.push(trait_pred.def_id()); } } - traits.sort_by_key(|id| self.tcx.def_path_str(id)); + traits.sort_by_key(|&id| self.tcx.def_path_str(id)); traits.dedup(); let len = traits.len(); @@ -3920,7 +3920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { valid_out_of_scope_traits.retain(|id| self.tcx.is_user_visible_dep(id.krate)); if !valid_out_of_scope_traits.is_empty() { let mut candidates = valid_out_of_scope_traits; - candidates.sort_by_key(|id| self.tcx.def_path_str(id)); + candidates.sort_by_key(|&id| self.tcx.def_path_str(id)); candidates.dedup(); // `TryFrom` and `FromIterator` have no methods diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index cb75e8a943b3e..e9d79a2ece2ec 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -380,8 +380,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx .associated_item_def_ids(def_id) .iter() - .find(|item_def_id| { - self.tcx.associated_item(*item_def_id).name() == sym::Output + .find(|&&item_def_id| { + self.tcx.associated_item(item_def_id).name() == sym::Output }) .cloned() }); diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 5e5f9b6f097fa..c7fa779447a49 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -308,7 +308,7 @@ where return true; }; // We only computed variance of lifetimes... - debug_assert_matches!(self.tcx.def_kind(def_id), DefKind::LifetimeParam); + debug_assert_matches!(self.tcx.def_kind(*def_id), DefKind::LifetimeParam); let uncaptured = match *kind { ParamKind::Early(name, index) => ty::Region::new_early_param( self.tcx, @@ -342,7 +342,7 @@ where let uncaptured_spans: Vec<_> = uncaptured_args .into_iter() - .map(|(def_id, _)| self.tcx.def_span(def_id)) + .map(|(&def_id, _)| self.tcx.def_span(def_id)) .collect(); self.tcx.emit_node_span_lint( diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 87c36f41afab1..0723395d6d1cd 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -282,9 +282,9 @@ fn lint_ty_kind_usage(cx: &LateContext<'_>, res: &Res) -> bool { } fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, path: &hir::Path<'_>) -> Option { - match &path.res { + match path.res { Res::Def(_, def_id) => { - if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(*def_id) { + if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(def_id) { return Some(format!("{}{}", name, gen_args(path.segments.last().unwrap()))); } } diff --git a/compiler/rustc_middle/src/mir/graphviz.rs b/compiler/rustc_middle/src/mir/graphviz.rs index cbfeae2051777..30a781b025fd5 100644 --- a/compiler/rustc_middle/src/mir/graphviz.rs +++ b/compiler/rustc_middle/src/mir/graphviz.rs @@ -16,12 +16,12 @@ where let mirs = def_ids .iter() - .filter(|def_id| !tcx.is_trivial_const(*def_id)) - .flat_map(|def_id| { - if tcx.is_const_fn(*def_id) { - vec![tcx.optimized_mir(*def_id), tcx.mir_for_ctfe(*def_id)] + .filter(|&&def_id| !tcx.is_trivial_const(def_id)) + .flat_map(|&def_id| { + if tcx.is_const_fn(def_id) { + vec![tcx.optimized_mir(def_id), tcx.mir_for_ctfe(def_id)] } else { - vec![tcx.instance_mir(ty::InstanceKind::Item(*def_id))] + vec![tcx.instance_mir(ty::InstanceKind::Item(def_id))] } }) .collect::>(); diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index a4ab1f364c168..654404f9790cb 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -309,7 +309,7 @@ impl<'tcx> GlobalAlloc<'tcx> { pub fn mutability(&self, tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> Mutability { // Let's see what kind of memory we are. - match self { + match *self { GlobalAlloc::Static(did) => { let DefKind::Static { safety: _, mutability, nested } = tcx.def_kind(did) else { bug!() @@ -351,7 +351,7 @@ impl<'tcx> GlobalAlloc<'tcx> { tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, ) -> (Size, Align) { - match self { + match *self { GlobalAlloc::Static(def_id) => { let DefKind::Static { nested, .. } = tcx.def_kind(def_id) else { bug!("GlobalAlloc::Static is not a static") diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 03618ee6acd46..6b19bf23edc2f 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -633,13 +633,6 @@ mod sealed { } } - impl<'a, P: Copy> IntoQueryParam

for &'a P { - #[inline(always)] - fn into_query_param(self) -> P { - *self - } - } - impl IntoQueryParam for OwnerId { #[inline(always)] fn into_query_param(self) -> LocalDefId { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 47843a260440e..be8a6083b0cde 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2086,7 +2086,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Given a `ty`, return whether it's an `impl Future<...>`. pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool { - let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false }; + let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *ty.kind() else { return false }; let future_trait = self.require_lang_item(LangItem::Future, DUMMY_SP); self.explicit_item_self_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| { diff --git a/compiler/rustc_middle/src/ty/significant_drop_order.rs b/compiler/rustc_middle/src/ty/significant_drop_order.rs index f1aa7076d98ac..5035127b8c9ca 100644 --- a/compiler/rustc_middle/src/ty/significant_drop_order.rs +++ b/compiler/rustc_middle/src/ty/significant_drop_order.rs @@ -119,7 +119,7 @@ pub fn extract_component_with_significant_dtor<'tcx>( /// when we are working with current local crate. #[instrument(level = "trace", skip(tcx))] pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { - match ty.kind() { + match *ty.kind() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index c3be0b630d6ed..c29f3e7458e54 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -417,7 +417,7 @@ impl<'tcx> TyCtxt<'tcx> { continue; } - let Some(item_id) = self.associated_item_def_ids(impl_did).first() else { + let Some(&item_id) = self.associated_item_def_ids(impl_did).first() else { self.dcx() .span_delayed_bug(self.def_span(impl_did), "Drop impl without drop function"); continue; @@ -435,7 +435,7 @@ impl<'tcx> TyCtxt<'tcx> { .delay_as_bug(); } - dtor_candidate = Some(*item_id); + dtor_candidate = Some(item_id); } let did = dtor_candidate?; diff --git a/compiler/rustc_mir_build/src/builder/expr/into.rs b/compiler/rustc_mir_build/src/builder/expr/into.rs index e8427b5d6e1eb..24d184121ffd0 100644 --- a/compiler/rustc_mir_build/src/builder/expr/into.rs +++ b/compiler/rustc_mir_build/src/builder/expr/into.rs @@ -370,7 +370,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Some intrinsics are handled here because they desperately want to avoid introducing // unnecessary copies. ExprKind::Call { ty, fun, ref args, .. } - if let ty::FnDef(def_id, generic_args) = ty.kind() + if let ty::FnDef(def_id, generic_args) = *ty.kind() && let Some(intrinsic) = this.tcx.intrinsic(def_id) && matches!(intrinsic.name, sym::write_via_move | sym::write_box_via_move) => { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 001c4338ad0e1..24c85b7ec3f5d 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -471,7 +471,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => { let fn_ty = self.thir[fun].ty; let sig = fn_ty.fn_sig(self.tcx); - let (callee_features, safe_target_features): (&[_], _) = match fn_ty.kind() { + let (callee_features, safe_target_features): (&[_], _) = match *fn_ty.kind() { ty::FnDef(func_id, ..) => { let cg_attrs = self.tcx.codegen_fn_attrs(func_id); (&cg_attrs.target_features, cg_attrs.safe_target_features) diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index 8998be26412d5..f33e43162c3f4 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -251,19 +251,16 @@ where // impl_item_refs may be empty if drop fn is not implemented in 'impl AsyncDrop for ...' // (#140974). // Such code will report error, so just generate sync drop here and return - let Some(drop_fn_def_id) = tcx - .associated_item_def_ids(drop_trait) - .first() - .and_then(|def_id| { + let Some(drop_fn_def_id) = + tcx.associated_item_def_ids(drop_trait).first().and_then(|&def_id| { if tcx.def_kind(def_id) == DefKind::AssocFn - && tcx.check_args_compatible(*def_id, trait_args) + && tcx.check_args_compatible(def_id, trait_args) { Some(def_id) } else { None } }) - .copied() else { tcx.dcx().span_delayed_bug( self.elaborator.body().span, diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 78c161ebd58c9..656b74e15f727 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -440,7 +440,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { } } - if let ty::FnDef(did, ..) = func.ty(&self.body.local_decls, self.tcx).kind() + if let ty::FnDef(did, ..) = *func.ty(&self.body.local_decls, self.tcx).kind() && self.body.phase >= MirPhase::Runtime(RuntimePhase::Optimized) && matches!(self.tcx.codegen_fn_attrs(did).inline, InlineAttr::Force { .. }) { diff --git a/compiler/rustc_monomorphize/src/collector/autodiff.rs b/compiler/rustc_monomorphize/src/collector/autodiff.rs index e3646596e75e6..67d4b8c8afff2 100644 --- a/compiler/rustc_monomorphize/src/collector/autodiff.rs +++ b/compiler/rustc_monomorphize/src/collector/autodiff.rs @@ -28,13 +28,13 @@ fn collect_autodiff_fn_from_arg<'tcx>( output: &mut MonoItems<'tcx>, ) { let (instance, span) = match arg.kind() { - ty::GenericArgKind::Type(ty) => match ty.kind() { + ty::GenericArgKind::Type(ty) => match *ty.kind() { ty::FnDef(def_id, substs) => { let span = tcx.def_span(def_id); let instance = ty::Instance::expect_resolve( tcx, ty::TypingEnv::non_body_analysis(tcx, def_id), - *def_id, + def_id, substs, span, ); diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index 249c5e6397461..abe63e073ad78 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -37,7 +37,7 @@ fn custom_coerce_unsize_info<'tcx>( Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData { impl_def_id, .. - })) => Ok(tcx.coerce_unsized_info(impl_def_id)?.custom_kind.unwrap()), + })) => Ok(tcx.coerce_unsized_info(*impl_def_id)?.custom_kind.unwrap()), impl_source => { bug!( "invalid `CoerceUnsized` from {source_ty} to {target_ty}: impl_source: {:?}", diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs index 0adf1b089b53e..a8f3104c0d98d 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs @@ -190,7 +190,7 @@ impl<'tcx> MoveCheckVisitor<'tcx> { } fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option { - for impl_def_id in tcx.inherent_impls(def_id) { + for &impl_def_id in tcx.inherent_impls(def_id) { if let Some(new) = tcx.associated_items(impl_def_id).find_by_ident_and_kind( tcx, fn_ident, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index ad667df47123f..b01afe550e74f 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2207,7 +2207,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }) }) .collect(); - if let Some(def_id) = path.get(0) + if let Some(&def_id) = path.get(0) && let Some(path) = path_names { if let Some(def_id) = def_id.as_local() { diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 59a5c0728a753..0fba8295afbac 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1295,7 +1295,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { .tcx .associated_item_def_ids(def_id) .iter() - .map(|field_id| self.tcx.visibility(field_id)) + .map(|&field_id| self.tcx.visibility(field_id)) .collect(); (ctor_res, ctor_vis, field_visibilities) }) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index b1d6e3526d9cd..9f5196d894893 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2359,7 +2359,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .tcx .associated_item_def_ids(def_id) .iter() - .map(|field_id| self.r.tcx.visibility(field_id)) + .map(|&field_id| self.r.tcx.visibility(field_id)) .collect(); (ctor_res, ctor_vis, field_visibilities) }) @@ -2594,7 +2594,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .tcx .inherent_impls(def_id) .iter() - .flat_map(|i| self.r.tcx.associated_items(i).in_definition_order()) + .flat_map(|&i| self.r.tcx.associated_items(i).in_definition_order()) // Only assoc fn with no receivers. .filter(|item| item.is_fn() && !item.is_method()) .filter_map(|item| { @@ -2702,7 +2702,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .tcx .associated_item_def_ids(def_id) .iter() - .map(|field_id| self.r.tcx.visibility(field_id)) + .map(|&field_id| self.r.tcx.visibility(field_id)) .collect(), ), }; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs index 16c4ac68cdf0c..060204946d014 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs @@ -362,7 +362,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { && self.tcx.trait_of_assoc(*item_id) == Some(*trait_id) && let None = self.tainted_by_errors() { - let assoc_item = self.tcx.associated_item(item_id); + let assoc_item = self.tcx.associated_item(*item_id); let (verb, noun) = match assoc_item.kind { ty::AssocKind::Const { .. } => ("refer to the", "constant"), ty::AssocKind::Fn { .. } => ("call", "function"), @@ -394,7 +394,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let trait_impls = self.tcx.trait_impls_of(data.trait_ref.def_id); - if let Some(impl_def_id) = + if let Some(&impl_def_id) = trait_impls.non_blanket_impls().values().flatten().next() { let non_blanket_impl_count = @@ -418,7 +418,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { .non_blanket_impls() .values() .flatten() - .map(|id| { + .map(|&id| { format!( "{}", self.tcx.type_of(id).instantiate_identity() diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 2c7105ab4ebea..983890f6b48db 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1799,7 +1799,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { with_forced_trimmed_paths! { if self.tcx.is_lang_item(projection_term.def_id, LangItem::FnOnceOutput) { - let (span, closure_span) = if let ty::Closure(def_id, _) = self_ty.kind() { + let (span, closure_span) = if let ty::Closure(def_id, _) = *self_ty.kind() { let def_span = self.tcx.def_span(def_id); if let Some(local_def_id) = def_id.as_local() && let node = self.tcx.hir_node_by_def_id(local_def_id) @@ -2305,7 +2305,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; if candidates.len() < 5 { let spans: Vec<_> = - candidates.iter().map(|(_, def_id)| self.tcx.def_span(def_id)).collect(); + candidates.iter().map(|&(_, def_id)| self.tcx.def_span(def_id)).collect(); let mut span: MultiSpan = spans.into(); for (c, def_id) in &candidates { let msg = if all_traits_equal { @@ -2317,7 +2317,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx.short_string(c.print_only_trait_path(), err.long_ty_path()), ) }; - span.push_span_label(self.tcx.def_span(def_id), msg); + span.push_span_label(self.tcx.def_span(*def_id), msg); } err.span_help( span, @@ -2631,16 +2631,16 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ) }; let trait_name = self.tcx.item_name(trait_def_id); - if let Some(other_trait_def_id) = self.tcx.all_traits_including_private().find(|def_id| { - trait_def_id != *def_id + if let Some(other_trait_def_id) = self.tcx.all_traits_including_private().find(|&def_id| { + trait_def_id != def_id && trait_name == self.tcx.item_name(def_id) - && trait_has_same_params(*def_id) + && trait_has_same_params(def_id) && self.predicate_must_hold_modulo_regions(&Obligation::new( self.tcx, obligation.cause.clone(), obligation.param_env, trait_pred.map_bound(|tr| ty::TraitPredicate { - trait_ref: ty::TraitRef::new(self.tcx, *def_id, tr.trait_ref.args), + trait_ref: ty::TraitRef::new(self.tcx, def_id, tr.trait_ref.args), ..tr }), )) @@ -3314,7 +3314,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { terr: TypeError<'tcx>, ) -> Diag<'a> { let self_ty = found_trait_ref.self_ty(); - let (cause, terr) = if let ty::Closure(def_id, _) = self_ty.kind() { + let (cause, terr) = if let ty::Closure(def_id, _) = *self_ty.kind() { ( ObligationCause::dummy_with_span(self.tcx.def_span(def_id)), TypeError::CyclicTy(self_ty), diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index a7a685d62b345..c239f0b56c83f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -373,12 +373,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx.extern_crate(trait_def_id.krate), ) { ( - Some(ExternCrate { + Some(&ExternCrate { src: ExternCrateSource::Extern(expected_def_id), dependency_of: LOCAL_CRATE, .. }), - Some(ExternCrate { + Some(&ExternCrate { src: ExternCrateSource::Extern(trait_def_id), dependency_of: LOCAL_CRATE, .. @@ -402,9 +402,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let krate = self.tcx.crate_name(expected_did.krate); let name = self.tcx.item_name(expected_did); let definitions_with_same_path: UnordSet<_> = found_dids - .filter(|def_id| { + .filter(|&def_id| { def_id.krate != expected_did.krate - && (self.extern_crates_with_the_same_name(expected_did, *def_id) + && (self.extern_crates_with_the_same_name(expected_did, def_id) || self.tcx.crate_name(def_id.krate) == krate) && self.tcx.item_name(def_id) == name }) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs index 9c146d7326135..0af7b0e3253dd 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs @@ -207,7 +207,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if self_ty.is_fn() { let fn_sig = self_ty.fn_sig(self.tcx); - let shortname = if let ty::FnDef(def_id, _) = self_ty.kind() + let shortname = if let ty::FnDef(def_id, _) = *self_ty.kind() && self.tcx.codegen_fn_attrs(def_id).safe_target_features { "#[target_feature] fn" diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs index 8488d76e2c773..360a01a8a3759 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs @@ -231,7 +231,7 @@ fn parse_arg<'tcx>( is_source_literal: bool, ) -> FormatArg { let (Ctx::RustcOnUnimplemented { tcx, trait_def_id } - | Ctx::DiagnosticOnUnimplemented { tcx, trait_def_id }) = ctx; + | Ctx::DiagnosticOnUnimplemented { tcx, trait_def_id }) = *ctx; let span = slice_span(input_span, arg.position_span.clone(), is_source_literal); diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 18b926ad28c89..176cc8c4c2cab 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -2244,9 +2244,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // First, look for an `WhereClauseInExpr`, which means we can get // the uninstantiated predicate list of the called function. And check // that the predicate that we failed to satisfy is a `Fn`-like trait. - if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = cause + if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = *cause && let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx) - && let Some(pred) = predicates.predicates.get(*idx) + && let Some(pred) = predicates.predicates.get(idx) && let ty::ClauseKind::Trait(trait_pred) = pred.kind().skip_binder() && self.tcx.is_fn_trait(trait_pred.def_id()) { @@ -2257,7 +2257,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // Find another predicate whose self-type is equal to the expected self type, // but whose args don't match. - let other_pred = predicates.into_iter().enumerate().find(|(other_idx, (pred, _))| { + let other_pred = predicates.into_iter().enumerate().find(|&(other_idx, (pred, _))| { match pred.kind().skip_binder() { ty::ClauseKind::Trait(trait_pred) if self.tcx.is_fn_trait(trait_pred.def_id()) @@ -3029,10 +3029,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let len = impls.len(); let mut types = impls .iter() - .map(|t| { + .map(|&&t| { with_no_trimmed_paths!(format!( " {}", - tcx.type_of(*t).instantiate_identity(), + tcx.type_of(t).instantiate_identity(), )) }) .collect::>(); @@ -3421,7 +3421,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let ty_str = tcx.short_string(ty, err.long_ty_path()); format!("required because it appears within the type `{ty_str}`") }; - match ty.kind() { + match *ty.kind() { ty::Adt(def, _) => { let msg = msg(); match tcx.opt_item_ident(def.did()) { @@ -4216,11 +4216,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // to an associated type (as seen from `trait_pred`) in the predicate. Like in // trait_pred `S: Sum<::Item>` and predicate `i32: Sum<&()>` let mut type_diffs = vec![]; - if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = parent_code + if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = *parent_code && let Some(node_args) = typeck_results.node_args_opt(call_hir_id) && let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args) - && let Some(where_pred) = where_clauses.predicates.get(*idx) + && let Some(where_pred) = where_clauses.predicates.get(idx) { if let Some(where_pred) = where_pred.as_trait_clause() && let Some(failed_pred) = failed_pred.as_trait_clause() diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs index 2e60805cd10a5..8a61d9a021752 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -267,7 +267,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( return; } - match ty.kind() { + match *ty.kind() { ty::Bool | ty::Char | ty::Int(_) @@ -287,7 +287,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( ty::Pat(ety, _) | ty::Array(ety, _) | ty::Slice(ety) => { // single-element containers, behave like their element rustc_data_structures::stack::ensure_sufficient_stack(|| { - dtorck_constraint_for_ty_inner(tcx, typing_env, span, depth + 1, *ety, constraints) + dtorck_constraint_for_ty_inner(tcx, typing_env, span, depth + 1, ety, constraints) }); } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 9c7685ca30bc9..fb0dbac7c41df 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -191,7 +191,7 @@ pub(crate) fn try_inline_glob( .iter() .filter(|child| !child.reexport_chain.is_empty()) .filter_map(|child| child.res.opt_def_id()) - .filter(|def_id| !cx.tcx.is_doc_hidden(def_id)) + .filter(|&def_id| !cx.tcx.is_doc_hidden(def_id)) .collect(); let attrs = cx.tcx.hir_attrs(import.hir_id()); let mut items = build_module_items( diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 927a7e0f07159..b58daceed0702 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -94,7 +94,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> // While the `impl` blocks themselves are only in `libcore`, the module with `doc` // attached is directly included in `libstd` as well. if did.is_local() { - for def_id in prim.impls(tcx).filter(|def_id| { + for def_id in prim.impls(tcx).filter(|&def_id| { // Avoid including impl blocks with filled-in generics. // https://github.com/rust-lang/rust/issues/94937 // diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index bb94a111f7a14..20cf3796c8be9 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -150,16 +150,16 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx let callee_ty_adjustments = typeck.expr_adjustments(callee); let callee_ty_adjusted = callee_ty_adjustments.last().map_or(callee_ty, |a| a.target); - let sig = match callee_ty_adjusted.kind() { + let sig = match *callee_ty_adjusted.kind() { ty::FnDef(def, _) => { // Rewriting `x(|| f())` to `x(f)` where f is marked `#[track_caller]` moves the `Location` - if find_attr!(cx.tcx, *def, TrackCaller(..)) { + if find_attr!(cx.tcx, def, TrackCaller(..)) { return; } cx.tcx.fn_sig(def).skip_binder().skip_binder() }, - ty::FnPtr(sig_tys, hdr) => sig_tys.with(*hdr).skip_binder(), + ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr).skip_binder(), ty::Closure(_, subs) => cx .tcx .signature_unclosure(subs.as_closure().sig(), Safety::Safe) diff --git a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs index aed4a0075c2fd..832197d36cc65 100644 --- a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs +++ b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs @@ -133,7 +133,7 @@ fn check_unwrap_or_default( let output_type_implements_default = |fun| { let fun_ty = cx.typeck_results().expr_ty(fun); - if let ty::FnDef(def_id, args) = fun_ty.kind() { + if let ty::FnDef(def_id, args) = *fun_ty.kind() { let output_ty = cx.tcx.fn_sig(def_id).instantiate(cx.tcx, args).skip_binder().output(); cx.tcx .get_diagnostic_item(sym::Default) @@ -153,7 +153,7 @@ fn check_unwrap_or_default( cx.tcx .inherent_impls(adt_def.did()) .iter() - .flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg)) + .flat_map(|&impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg)) .find_map(|assoc| { if assoc.is_method() && cx.tcx.fn_sig(assoc.def_id).skip_binder().inputs().skip_binder().len() == 1 { Some(assoc.def_id) diff --git a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs index 43c62e1e131a3..92515bd3fb804 100644 --- a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs +++ b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs @@ -287,7 +287,7 @@ fn is_assoc_fn_without_type_instance<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<' .. }, )) = func.kind - && let output_ty = cx.tcx.fn_sig(def_id).instantiate_identity().skip_binder().output() + && let output_ty = cx.tcx.fn_sig(*def_id).instantiate_identity().skip_binder().output() && let ty::Param(ty::ParamTy { name: kw::SelfUpper, .. }) = output_ty.kind() diff --git a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs index c1e03b7e8c705..1b7d7fd6c68cb 100644 --- a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs @@ -335,8 +335,8 @@ impl UnconditionalRecursion { let impls = cx.tcx.trait_impls_of(default_trait_id); for (ty, impl_def_ids) in impls.non_blanket_impls() { let Some(self_def_id) = ty.def() else { continue }; - for impl_def_id in impl_def_ids { - if !cx.tcx.is_automatically_derived(*impl_def_id) && + for &impl_def_id in impl_def_ids { + if !cx.tcx.is_automatically_derived(impl_def_id) && let Some(assoc_item) = cx .tcx .associated_items(impl_def_id) diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 9a49845d9d46b..fdd270c2774af 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -601,9 +601,9 @@ pub fn is_default_equivalent_call( && let StatementKind::Assign(assign) = &block_data.statements[0].kind && assign.0.local == RETURN_PLACE && let Rvalue::Aggregate(kind, _places) = &assign.1 - && let AggregateKind::Adt(did, variant_index, _, _, _) = &**kind + && let AggregateKind::Adt(did, variant_index, _, _, _) = **kind && let def = cx.tcx.adt_def(did) - && let variant = &def.variant(*variant_index) + && let variant = &def.variant(variant_index) && variant.fields.is_empty() && let Some((_, did)) = variant.ctor && did == repl_def_id diff --git a/src/tools/clippy/clippy_utils/src/paths.rs b/src/tools/clippy/clippy_utils/src/paths.rs index 8aa663163caf1..e6593aa8b5541 100644 --- a/src/tools/clippy/clippy_utils/src/paths.rs +++ b/src/tools/clippy/clippy_utils/src/paths.rs @@ -335,7 +335,7 @@ fn non_local_item_child_by_name(tcx: TyCtxt<'_>, def_id: DefId, ns: PathNS, name .associated_item_def_ids(def_id) .iter() .copied() - .find(|assoc_def_id| tcx.item_name(*assoc_def_id) == name && ns.matches(tcx.def_kind(assoc_def_id).ns())), + .find(|&assoc_def_id| tcx.item_name(assoc_def_id) == name && ns.matches(tcx.def_kind(assoc_def_id).ns())), _ => None, } } diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index 3e1ad6c0ef515..36410a81fbf65 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -310,13 +310,13 @@ pub fn has_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { // Returns whether the type has #[must_use] attribute pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match *ty.kind() { ty::Adt(adt, _) => find_attr!(cx.tcx, adt.did(), MustUse { .. }), - ty::Foreign(did) => find_attr!(cx.tcx, *did, MustUse { .. }), + ty::Foreign(did) => find_attr!(cx.tcx, did, MustUse { .. }), ty::Slice(ty) | ty::Array(ty, _) | ty::RawPtr(ty, _) | ty::Ref(_, ty, _) => { // for the Array case we don't need to care for the len == 0 case // because we don't want to lint functions returning empty arrays - is_must_use_ty(cx, *ty) + is_must_use_ty(cx, ty) }, ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)), ty::Alias(ty::Opaque, AliasTy { def_id, .. }) => { @@ -330,7 +330,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { false }, ty::Dynamic(binder, _) => { - for predicate in *binder { + for predicate in binder { if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() && find_attr!(cx.tcx, trait_ref.def_id, MustUse { .. }) { diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 5dcd2d9ec2084..facfade026be8 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -62,7 +62,7 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option) // Go over the modules. for &segment in modules { let Some(next_item) = find_children(tcx, cur_item, segment) - .find(|item| tcx.def_kind(item) == DefKind::Mod) + .find(|&item| tcx.def_kind(item) == DefKind::Mod) else { continue 'crates; }; @@ -72,7 +72,7 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option) match item { Some((item_name, namespace)) => { let Some(item) = find_children(tcx, cur_item, item_name) - .find(|item| tcx.def_kind(item).ns() == Some(namespace)) + .find(|&item| tcx.def_kind(item).ns() == Some(namespace)) else { continue 'crates; };