From 91269fa5b8a7272a2a45b0b5e8a6fa4be24fe96a Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Fri, 9 Sep 2022 15:25:29 -0500 Subject: [PATCH] Remove a reference from Inherited --- compiler/rustc_hir_analysis/src/check/check.rs | 2 +- .../src/check/fn_ctxt/mod.rs | 6 +++--- .../rustc_hir_analysis/src/check/inherited.rs | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index b079ddde056..48b06898065 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -78,7 +78,7 @@ pub(super) fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Ab /// * inherited: other fields inherited from the enclosing fn (if any) #[instrument(skip(inherited, body), level = "debug")] pub(super) fn check_fn<'a, 'tcx>( - inherited: &'a Inherited<'a, 'tcx>, + inherited: &'a Inherited<'tcx>, param_env: ty::ParamEnv<'tcx>, fn_sig: ty::FnSig<'tcx>, decl: &'tcx hir::FnDecl<'tcx>, diff --git a/compiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs b/compiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs index 42ec2f41886..51f4cb7e0eb 100644 --- a/compiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs @@ -118,7 +118,7 @@ pub struct FnCtxt<'a, 'tcx> { pub(super) enclosing_breakables: RefCell>, - pub(super) inh: &'a Inherited<'a, 'tcx>, + pub(super) inh: &'a Inherited<'tcx>, /// True if the function or closure's return type is known before /// entering the function/closure, i.e. if the return type is @@ -132,7 +132,7 @@ pub struct FnCtxt<'a, 'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn new( - inh: &'a Inherited<'a, 'tcx>, + inh: &'a Inherited<'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, ) -> FnCtxt<'a, 'tcx> { @@ -184,7 +184,7 @@ pub fn errors_reported_since_creation(&self) -> bool { } impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> { - type Target = Inherited<'a, 'tcx>; + type Target = Inherited<'tcx>; fn deref(&self) -> &Self::Target { &self.inh } diff --git a/compiler/rustc_hir_analysis/src/check/inherited.rs b/compiler/rustc_hir_analysis/src/check/inherited.rs index e273571edbd..7930377abaa 100644 --- a/compiler/rustc_hir_analysis/src/check/inherited.rs +++ b/compiler/rustc_hir_analysis/src/check/inherited.rs @@ -29,10 +29,10 @@ /// Here, the function `foo()` and the closure passed to /// `bar()` will each have their own `FnCtxt`, but they will /// share the inherited fields. -pub struct Inherited<'a, 'tcx> { +pub struct Inherited<'tcx> { pub(super) infcx: InferCtxt<'tcx>, - pub(super) typeck_results: &'a RefCell>, + pub(super) typeck_results: RefCell>, pub(super) locals: RefCell>>, @@ -70,7 +70,7 @@ pub struct Inherited<'a, 'tcx> { pub(super) diverging_type_vars: RefCell>>, } -impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> { +impl<'tcx> Deref for Inherited<'tcx> { type Target = InferCtxt<'tcx>; fn deref(&self) -> &Self::Target { &self.infcx @@ -86,7 +86,7 @@ pub struct InheritedBuilder<'tcx> { typeck_results: RefCell>, } -impl<'tcx> Inherited<'_, 'tcx> { +impl<'tcx> Inherited<'tcx> { pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> { let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner; @@ -124,20 +124,20 @@ pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> { } impl<'tcx> InheritedBuilder<'tcx> { - pub fn enter(&mut self, f: F) -> R + pub fn enter(mut self, f: F) -> R where - F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R, + F: FnOnce(&Inherited<'tcx>) -> R, { let def_id = self.def_id; - self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id, &self.typeck_results))) + self.infcx.enter(|infcx| f(&Inherited::new(infcx, def_id, self.typeck_results))) } } -impl<'a, 'tcx> Inherited<'a, 'tcx> { +impl<'tcx> Inherited<'tcx> { fn new( infcx: InferCtxt<'tcx>, def_id: LocalDefId, - typeck_results: &'a RefCell>, + typeck_results: RefCell>, ) -> Self { let tcx = infcx.tcx; let body_id = tcx.hir().maybe_body_owned_by(def_id);