Skip to content

Commit 91269fa

Browse files
committed
Remove a reference from Inherited
1 parent 349415d commit 91269fa

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(super) fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Ab
7878
/// * inherited: other fields inherited from the enclosing fn (if any)
7979
#[instrument(skip(inherited, body), level = "debug")]
8080
pub(super) fn check_fn<'a, 'tcx>(
81-
inherited: &'a Inherited<'a, 'tcx>,
81+
inherited: &'a Inherited<'tcx>,
8282
param_env: ty::ParamEnv<'tcx>,
8383
fn_sig: ty::FnSig<'tcx>,
8484
decl: &'tcx hir::FnDecl<'tcx>,

compiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub struct FnCtxt<'a, 'tcx> {
118118

119119
pub(super) enclosing_breakables: RefCell<EnclosingBreakables<'tcx>>,
120120

121-
pub(super) inh: &'a Inherited<'a, 'tcx>,
121+
pub(super) inh: &'a Inherited<'tcx>,
122122

123123
/// True if the function or closure's return type is known before
124124
/// entering the function/closure, i.e. if the return type is
@@ -132,7 +132,7 @@ pub struct FnCtxt<'a, 'tcx> {
132132

133133
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
134134
pub fn new(
135-
inh: &'a Inherited<'a, 'tcx>,
135+
inh: &'a Inherited<'tcx>,
136136
param_env: ty::ParamEnv<'tcx>,
137137
body_id: hir::HirId,
138138
) -> FnCtxt<'a, 'tcx> {
@@ -184,7 +184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
184184
}
185185

186186
impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {
187-
type Target = Inherited<'a, 'tcx>;
187+
type Target = Inherited<'tcx>;
188188
fn deref(&self) -> &Self::Target {
189189
&self.inh
190190
}

compiler/rustc_hir_analysis/src/check/inherited.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ use std::ops::Deref;
2929
/// Here, the function `foo()` and the closure passed to
3030
/// `bar()` will each have their own `FnCtxt`, but they will
3131
/// share the inherited fields.
32-
pub struct Inherited<'a, 'tcx> {
32+
pub struct Inherited<'tcx> {
3333
pub(super) infcx: InferCtxt<'tcx>,
3434

35-
pub(super) typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
35+
pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
3636

3737
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
3838

@@ -70,7 +70,7 @@ pub struct Inherited<'a, 'tcx> {
7070
pub(super) diverging_type_vars: RefCell<FxHashSet<Ty<'tcx>>>,
7171
}
7272

73-
impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> {
73+
impl<'tcx> Deref for Inherited<'tcx> {
7474
type Target = InferCtxt<'tcx>;
7575
fn deref(&self) -> &Self::Target {
7676
&self.infcx
@@ -86,7 +86,7 @@ pub struct InheritedBuilder<'tcx> {
8686
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
8787
}
8888

89-
impl<'tcx> Inherited<'_, 'tcx> {
89+
impl<'tcx> Inherited<'tcx> {
9090
pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> {
9191
let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner;
9292

@@ -124,20 +124,20 @@ impl<'tcx> Inherited<'_, 'tcx> {
124124
}
125125

126126
impl<'tcx> InheritedBuilder<'tcx> {
127-
pub fn enter<F, R>(&mut self, f: F) -> R
127+
pub fn enter<F, R>(mut self, f: F) -> R
128128
where
129-
F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R,
129+
F: FnOnce(&Inherited<'tcx>) -> R,
130130
{
131131
let def_id = self.def_id;
132-
self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id, &self.typeck_results)))
132+
self.infcx.enter(|infcx| f(&Inherited::new(infcx, def_id, self.typeck_results)))
133133
}
134134
}
135135

136-
impl<'a, 'tcx> Inherited<'a, 'tcx> {
136+
impl<'tcx> Inherited<'tcx> {
137137
fn new(
138138
infcx: InferCtxt<'tcx>,
139139
def_id: LocalDefId,
140-
typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
140+
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
141141
) -> Self {
142142
let tcx = infcx.tcx;
143143
let body_id = tcx.hir().maybe_body_owned_by(def_id);

0 commit comments

Comments
 (0)