Remove a reference from Inherited
This commit is contained in:
parent
349415d1c6
commit
91269fa5b8
3 changed files with 13 additions and 13 deletions
|
@ -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)
|
/// * inherited: other fields inherited from the enclosing fn (if any)
|
||||||
#[instrument(skip(inherited, body), level = "debug")]
|
#[instrument(skip(inherited, body), level = "debug")]
|
||||||
pub(super) fn check_fn<'a, 'tcx>(
|
pub(super) fn check_fn<'a, 'tcx>(
|
||||||
inherited: &'a Inherited<'a, 'tcx>,
|
inherited: &'a Inherited<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
fn_sig: ty::FnSig<'tcx>,
|
fn_sig: ty::FnSig<'tcx>,
|
||||||
decl: &'tcx hir::FnDecl<'tcx>,
|
decl: &'tcx hir::FnDecl<'tcx>,
|
||||||
|
|
|
@ -118,7 +118,7 @@ pub struct FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
pub(super) enclosing_breakables: RefCell<EnclosingBreakables<'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
|
/// True if the function or closure's return type is known before
|
||||||
/// entering the function/closure, i.e. if the return type is
|
/// 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> {
|
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
inh: &'a Inherited<'a, 'tcx>,
|
inh: &'a Inherited<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
body_id: hir::HirId,
|
body_id: hir::HirId,
|
||||||
) -> FnCtxt<'a, 'tcx> {
|
) -> FnCtxt<'a, 'tcx> {
|
||||||
|
@ -184,7 +184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Deref for 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 {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.inh
|
&self.inh
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ use std::ops::Deref;
|
||||||
/// Here, the function `foo()` and the closure passed to
|
/// Here, the function `foo()` and the closure passed to
|
||||||
/// `bar()` will each have their own `FnCtxt`, but they will
|
/// `bar()` will each have their own `FnCtxt`, but they will
|
||||||
/// share the inherited fields.
|
/// share the inherited fields.
|
||||||
pub struct Inherited<'a, 'tcx> {
|
pub struct Inherited<'tcx> {
|
||||||
pub(super) infcx: InferCtxt<'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>>>,
|
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ pub struct Inherited<'a, 'tcx> {
|
||||||
pub(super) diverging_type_vars: RefCell<FxHashSet<Ty<'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>;
|
type Target = InferCtxt<'tcx>;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.infcx
|
&self.infcx
|
||||||
|
@ -86,7 +86,7 @@ pub struct InheritedBuilder<'tcx> {
|
||||||
typeck_results: RefCell<ty::TypeckResults<'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> {
|
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;
|
let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner;
|
||||||
|
|
||||||
|
@ -124,20 +124,20 @@ impl<'tcx> Inherited<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> InheritedBuilder<'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
|
where
|
||||||
F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R,
|
F: FnOnce(&Inherited<'tcx>) -> R,
|
||||||
{
|
{
|
||||||
let def_id = self.def_id;
|
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(
|
fn new(
|
||||||
infcx: InferCtxt<'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
def_id: LocalDefId,
|
def_id: LocalDefId,
|
||||||
typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
|
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
let body_id = tcx.hir().maybe_body_owned_by(def_id);
|
let body_id = tcx.hir().maybe_body_owned_by(def_id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue