Skip to content

Commit

Permalink
Remove a reference from Inherited
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Oct 7, 2022
1 parent 349415d commit 91269fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub struct FnCtxt<'a, 'tcx> {

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

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
Expand All @@ -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> {
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {
type Target = Inherited<'a, 'tcx>;
type Target = Inherited<'tcx>;
fn deref(&self) -> &Self::Target {
&self.inh
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_hir_analysis/src/check/inherited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ use std::ops::Deref;
/// 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<ty::TypeckResults<'tcx>>,
pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,

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

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

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
Expand All @@ -86,7 +86,7 @@ pub struct InheritedBuilder<'tcx> {
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
}

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;

Expand Down Expand Up @@ -124,20 +124,20 @@ impl<'tcx> Inherited<'_, 'tcx> {
}

impl<'tcx> InheritedBuilder<'tcx> {
pub fn enter<F, R>(&mut self, f: F) -> R
pub fn enter<F, R>(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<ty::TypeckResults<'tcx>>,
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
) -> Self {
let tcx = infcx.tcx;
let body_id = tcx.hir().maybe_body_owned_by(def_id);
Expand Down

0 comments on commit 91269fa

Please sign in to comment.