diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 1bfb54a7bb7..511313cca6f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1525,7 +1525,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { matches!( adj.kind, ty::adjustment::Adjust::Borrow(ty::adjustment::AutoBorrow::Ref( - _, ty::adjustment::AutoBorrowMutability::Not | ty::adjustment::AutoBorrowMutability::Mut { allow_two_phase_borrow: ty::adjustment::AllowTwoPhase::No diff --git a/compiler/rustc_hir_typeck/src/autoderef.rs b/compiler/rustc_hir_typeck/src/autoderef.rs index c3e095b0554..7af26623ce7 100644 --- a/compiler/rustc_hir_typeck/src/autoderef.rs +++ b/compiler/rustc_hir_typeck/src/autoderef.rs @@ -50,8 +50,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.try_overloaded_deref(autoderef.span(), source).and_then( |InferOk { value: method, obligations: o }| { obligations.extend(o); - if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() { - Some(OverloadedDeref { region, mutbl, span: autoderef.span() }) + // FIXME: we should assert the sig is &T here... there's no reason for this to be fallible. + if let ty::Ref(_, _, mutbl) = *method.sig.output().kind() { + Some(OverloadedDeref { mutbl, span: autoderef.span() }) } else { None } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 6eb6792a119..f9a21a9bef3 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -307,7 +307,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if borrow { // Check for &self vs &mut self in the method signature. Since this is either // the Fn or FnMut trait, it should be one of those. - let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() else { + let ty::Ref(_, _, mutbl) = method.sig.inputs()[0].kind() else { bug!("Expected `FnMut`/`Fn` to take receiver by-ref/by-mut") }; @@ -317,7 +317,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::No); autoref = Some(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: method.sig.inputs()[0], }); } diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 6fa958d9496..87798ca3fd9 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -113,7 +113,7 @@ fn identity(_: Ty<'_>) -> Vec> { vec![] } -fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec> { +fn simple<'tcx>(kind: Adjust) -> impl FnOnce(Ty<'tcx>) -> Vec> { move |target| vec![Adjustment { kind, target }] } @@ -484,14 +484,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Now apply the autoref. We have to extract the region out of // the final ref type we got. - let ty::Ref(r_borrow, _, _) = ty.kind() else { + let ty::Ref(..) = ty.kind() else { span_bug!(span, "expected a ref type, got {:?}", ty); }; let mutbl = AutoBorrowMutability::new(mutbl_b, self.allow_two_phase); - adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*r_borrow, mutbl)), - target: ty, - }); + adjustments.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: ty }); debug!("coerce_borrowed_pointer: succeeded ty={:?} adjustments={:?}", ty, adjustments); @@ -547,7 +544,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let mutbl = AutoBorrowMutability::new(mutbl_b, AllowTwoPhase::No); Some((Adjustment { kind: Adjust::Deref(None), target: ty_a }, Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: Ty::new_ref(self.tcx, r_borrow, ty_a, mutbl_b), })) } @@ -827,7 +824,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { }; let (pin, a_region, a_ty, mut_a) = extract_pin_mut(a)?; - let (_, b_region, _b_ty, mut_b) = extract_pin_mut(b)?; + let (_, _, _b_ty, mut_b) = extract_pin_mut(b)?; coerce_mutbls(mut_a, mut_b)?; @@ -841,7 +838,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // To complete the reborrow, we need to make sure we can unify the inner types, and if so we // add the adjustments. self.unify_and(a, b, |_inner_ty| { - vec![Adjustment { kind: Adjust::ReborrowPin(b_region, mut_b), target: b }] + vec![Adjustment { kind: Adjust::ReborrowPin(mut_b), target: b }] }) } @@ -1321,7 +1318,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let noop = match self.typeck_results.borrow().expr_adjustments(expr) { &[ Adjustment { kind: Adjust::Deref(_), .. }, - Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. }, + Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl_adj)), .. }, ] => { match *self.node_ty(expr.hir_id).kind() { ty::Ref(_, _, mt_orig) => { diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index bb5f3511373..041ccfcddbb 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -781,7 +781,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx self.walk_autoref(expr, &place_with_id, autoref); } - adjustment::Adjust::ReborrowPin(_, mutbl) => { + adjustment::Adjust::ReborrowPin(mutbl) => { // Reborrowing a Pin is like a combinations of a deref and a borrow, so we do // both. let bk = match mutbl { @@ -804,7 +804,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx &self, expr: &hir::Expr<'_>, base_place: &PlaceWithHirId<'tcx>, - autoref: &adjustment::AutoBorrow<'tcx>, + autoref: &adjustment::AutoBorrow, ) { debug!( "walk_autoref(expr.hir_id={} base_place={:?} autoref={:?})", @@ -812,7 +812,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx ); match *autoref { - adjustment::AutoBorrow::Ref(_, m) => { + adjustment::AutoBorrow::Ref(m) => { self.delegate.borrow_mut().borrow( base_place, base_place.hir_id, @@ -1283,7 +1283,12 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx adjustment::Adjust::Deref(overloaded) => { // Equivalent to *expr or something similar. let base = if let Some(deref) = overloaded { - let ref_ty = Ty::new_ref(self.cx.tcx(), deref.region, target, deref.mutbl); + let ref_ty = Ty::new_ref( + self.cx.tcx(), + self.cx.tcx().lifetimes.re_erased, + target, + deref.mutbl, + ); self.cat_rvalue(expr.hir_id, ref_ty) } else { previous()? diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 0fc566c58f7..a1a78371fbd 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -264,7 +264,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let autoborrow_mut = adj.iter().any(|adj| { matches!(adj, &Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Mut { .. })), + kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Mut { .. })), .. }) }); diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 92b504d10bc..3754fd02428 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -200,10 +200,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // for two-phase borrows. let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::Yes); - adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), - target, - }); + adjustments + .push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target }); if unsize { let unsized_ty = if let ty::Array(elem_ty, _) = base_ty.kind() { @@ -250,7 +248,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { _ => bug!("Cannot adjust receiver type for reborrowing pin of {target:?}"), }; - adjustments.push(Adjustment { kind: Adjust::ReborrowPin(region, mutbl), target }); + adjustments.push(Adjustment { kind: Adjust::ReborrowPin(mutbl), target }); } None => {} } diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index 57ac7f7d2cd..9c1459ee188 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -256,23 +256,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(method) => { let by_ref_binop = !op.node.is_by_value(); if is_assign == IsAssign::Yes || by_ref_binop { - if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() { + if let ty::Ref(_, _, mutbl) = method.sig.inputs()[0].kind() { let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::Yes); let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: method.sig.inputs()[0], }; self.apply_adjustments(lhs_expr, vec![autoref]); } } if by_ref_binop { - if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].kind() { + if let ty::Ref(_, _, mutbl) = method.sig.inputs()[1].kind() { // Allow two-phase borrows for binops in initial deployment // since they desugar to methods let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::Yes); let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: method.sig.inputs()[1], }; // HACK(eddyb) Bypass checks due to reborrows being in diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs index 5dd51721022..d5c7fe5fff3 100644 --- a/compiler/rustc_hir_typeck/src/place_op.rs +++ b/compiler/rustc_hir_typeck/src/place_op.rs @@ -29,9 +29,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ok = self.try_overloaded_deref(expr.span, oprnd_ty)?; let method = self.register_infer_ok_obligations(ok); - if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() { + if let ty::Ref(_, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() { self.apply_adjustments(oprnd_expr, vec![Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, AutoBorrowMutability::Not)), + kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Not)), target: method.sig.inputs()[0], }]); } else { @@ -158,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut adjustments = self.adjust_steps(autoderef); if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() { adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, AutoBorrowMutability::Not)), + kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Not)), target: Ty::new_imm_ref(self.tcx, *region, adjusted_ty), }); } else { @@ -289,9 +289,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let method = self.register_infer_ok_obligations(ok); - if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() { - *deref = OverloadedDeref { region, mutbl, span: deref.span }; - } + let ty::Ref(_, _, mutbl) = *method.sig.output().kind() else { + span_bug!( + self.tcx.def_span(method.def_id), + "expected DerefMut to return a &mut" + ); + }; + *deref = OverloadedDeref { mutbl, span: deref.span }; // If this is a union field, also throw an error for `DerefMut` of `ManuallyDrop` (see RFC 2514). // This helps avoid accidental drops. if inside_union @@ -390,7 +394,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // not the case today. allow_two_phase_borrow: AllowTwoPhase::No, }; - adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)); + adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(mutbl)); adjustment.target = Ty::new_ref(self.tcx, *region, source, mutbl.into()); } source = adjustment.target; diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index bbb290c9459..b50a95e7d2b 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1610,7 +1610,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation { } for adj in cx.typeck_results().expr_adjustments(e) { - if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind { + if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(m)) = adj.kind { match m { adjustment::AutoBorrowMutability::Not => { cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag); diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs index 71833eea5c0..c56038d358c 100644 --- a/compiler/rustc_middle/src/ty/adjustment.rs +++ b/compiler/rustc_middle/src/ty/adjustment.rs @@ -82,7 +82,7 @@ pub enum PointerCoercion { /// `Box<[i32]>` is an `Adjust::Unsize` with the target `Box<[i32]>`. #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] pub struct Adjustment<'tcx> { - pub kind: Adjust<'tcx>, + pub kind: Adjust, pub target: Ty<'tcx>, } @@ -93,20 +93,20 @@ impl<'tcx> Adjustment<'tcx> { } #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] -pub enum Adjust<'tcx> { +pub enum Adjust { /// Go from ! to any type. NeverToAny, /// Dereference once, producing a place. - Deref(Option>), + Deref(Option), /// Take the address and produce either a `&` or `*` pointer. - Borrow(AutoBorrow<'tcx>), + Borrow(AutoBorrow), Pointer(PointerCoercion), /// Take a pinned reference and reborrow as a `Pin<&mut T>` or `Pin<&T>`. - ReborrowPin(ty::Region<'tcx>, hir::Mutability), + ReborrowPin(hir::Mutability), } /// An overloaded autoderef step, representing a `Deref(Mut)::deref(_mut)` @@ -115,17 +115,16 @@ pub enum Adjust<'tcx> { /// being those shared by both the receiver and the returned reference. #[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)] #[derive(TypeFoldable, TypeVisitable)] -pub struct OverloadedDeref<'tcx> { - pub region: ty::Region<'tcx>, +pub struct OverloadedDeref { pub mutbl: hir::Mutability, /// The `Span` associated with the field access or method call /// that triggered this overloaded deref. pub span: Span, } -impl<'tcx> OverloadedDeref<'tcx> { +impl OverloadedDeref { /// Get the zst function item type for this method call. - pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> Ty<'tcx> { + pub fn method_call<'tcx>(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> Ty<'tcx> { let trait_def_id = match self.mutbl { hir::Mutability::Not => tcx.require_lang_item(LangItem::Deref, None), hir::Mutability::Mut => tcx.require_lang_item(LangItem::DerefMut, None), @@ -187,9 +186,9 @@ impl From for hir::Mutability { #[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)] #[derive(TypeFoldable, TypeVisitable)] -pub enum AutoBorrow<'tcx> { +pub enum AutoBorrow { /// Converts from T to &T. - Ref(ty::Region<'tcx>, AutoBorrowMutability), + Ref(AutoBorrowMutability), /// Converts from T to *T. RawPtr(hir::Mutability), diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index d20e5fcf4ec..8e1eb85bbef 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -140,7 +140,7 @@ impl<'tcx> Cx<'tcx> { expr = Expr { temp_lifetime, - ty: Ty::new_ref(self.tcx, deref.region, expr.ty, deref.mutbl), + ty: Ty::new_ref(self.tcx, self.tcx.lifetimes.re_erased, expr.ty, deref.mutbl), span, kind: ExprKind::Borrow { borrow_kind: deref.mutbl.to_borrow_kind(), @@ -152,14 +152,14 @@ impl<'tcx> Cx<'tcx> { self.overloaded_place(hir_expr, adjustment.target, Some(call), expr, deref.span) } - Adjust::Borrow(AutoBorrow::Ref(_, m)) => ExprKind::Borrow { + Adjust::Borrow(AutoBorrow::Ref(m)) => ExprKind::Borrow { borrow_kind: m.to_borrow_kind(), arg: self.thir.exprs.push(expr), }, Adjust::Borrow(AutoBorrow::RawPtr(mutability)) => { ExprKind::RawBorrow { mutability, arg: self.thir.exprs.push(expr) } } - Adjust::ReborrowPin(region, mutbl) => { + Adjust::ReborrowPin(mutbl) => { debug!("apply ReborrowPin adjustment"); // Rewrite `$expr` as `Pin { __pointer: &(mut)? *($expr).__pointer }` @@ -197,7 +197,8 @@ impl<'tcx> Cx<'tcx> { hir::Mutability::Mut => BorrowKind::Mut { kind: mir::MutBorrowKind::Default }, hir::Mutability::Not => BorrowKind::Shared, }; - let new_pin_target = Ty::new_ref(self.tcx, region, ptr_target_ty, mutbl); + let new_pin_target = + Ty::new_ref(self.tcx, self.tcx.lifetimes.re_erased, ptr_target_ty, mutbl); let expr = self.thir.exprs.push(Expr { temp_lifetime, ty: new_pin_target, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index a6474f10d5b..af3b5e0d5d4 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -551,10 +551,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ] => "", [ .., - Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, mut_)), - target: _, - }, + Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mut_)), target: _ }, ] => hir::Mutability::from(*mut_).ref_prefix_str(), _ => "", }; diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index f34f5e05606..b167d7f2208 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -418,7 +418,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { let (required_refs, msg) = if can_auto_borrow { (1, if deref_count == 1 { borrow_msg } else { deref_msg }) } else if let Some(&Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, mutability)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutability)), .. }) = next_adjust && matches!(mutability, AutoBorrowMutability::Mut { .. }) diff --git a/src/tools/clippy/clippy_lints/src/loops/explicit_into_iter_loop.rs b/src/tools/clippy/clippy_lints/src/loops/explicit_into_iter_loop.rs index 93d6b808646..d5ddc33e928 100644 --- a/src/tools/clippy/clippy_lints/src/loops/explicit_into_iter_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/explicit_into_iter_loop.rs @@ -53,7 +53,7 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr< [] => AdjustKind::None, &[ Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), .. }, ] => AdjustKind::borrow(mutbl), @@ -62,7 +62,7 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr< kind: Adjust::Deref(_), .. }, Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target, }, ] => { diff --git a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs index 022c6bcc70b..119e410b91c 100644 --- a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs @@ -199,7 +199,7 @@ fn is_ref_iterable<'tcx>( kind: Adjust::Deref(_), .. }, Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target, }, .., @@ -236,7 +236,7 @@ fn is_ref_iterable<'tcx>( }, &[ Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target, }, .., diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs b/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs index 64c19c327b2..223b0630bfd 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs @@ -137,7 +137,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name: _ if matches!( typeck.expr_adjustments(prev_expr).first(), Some(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Not)) + kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Not)) | Adjust::Deref(_), .. }) @@ -230,7 +230,7 @@ fn check_use<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> (UseKind<'tcx>, if use_cx .adjustments .first() - .is_some_and(|a| matches!(a.kind, Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Not)))) => + .is_some_and(|a| matches!(a.kind, Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Not)))) => { UseKind::AutoBorrowed }, diff --git a/src/tools/clippy/clippy_lints/src/redundant_slicing.rs b/src/tools/clippy/clippy_lints/src/redundant_slicing.rs index 1c10e84d3ca..030df535c35 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_slicing.rs @@ -110,7 +110,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing { ) || cx.typeck_results().expr_adjustments(expr).first().map_or(false, |a| { matches!( a.kind, - Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Mut { .. })) + Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Mut { .. })) ) }) || (matches!( cx.typeck_results().expr_ty(indexed).ref_mutability(),