remove unused field from infcx

This commit is contained in:
lcnr 2022-03-31 16:52:47 +02:00
parent e730969b0d
commit a5c68d747e
4 changed files with 3 additions and 34 deletions

View file

@ -65,7 +65,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
Self { Self {
tcx: self.tcx.clone(), tcx: self.tcx.clone(),
defining_use_anchor: self.defining_use_anchor.clone(), defining_use_anchor: self.defining_use_anchor.clone(),
reveal_defining_opaque_types: self.reveal_defining_opaque_types.clone(),
in_progress_typeck_results: self.in_progress_typeck_results.clone(), in_progress_typeck_results: self.in_progress_typeck_results.clone(),
inner: self.inner.clone(), inner: self.inner.clone(),
skip_leak_check: self.skip_leak_check.clone(), skip_leak_check: self.skip_leak_check.clone(),

View file

@ -290,10 +290,6 @@ pub struct InferCtxt<'a, 'tcx> {
/// to the outside until the end up in an `InferCtxt` for typeck or borrowck. /// to the outside until the end up in an `InferCtxt` for typeck or borrowck.
pub defining_use_anchor: Option<LocalDefId>, pub defining_use_anchor: Option<LocalDefId>,
/// Used by WF-checking to not have to figure out hidden types itself, but
/// to just invoke type_of to get the already computed hidden type from typeck.
pub reveal_defining_opaque_types: bool,
/// During type-checking/inference of a body, `in_progress_typeck_results` /// During type-checking/inference of a body, `in_progress_typeck_results`
/// contains a reference to the typeck results being built up, which are /// contains a reference to the typeck results being built up, which are
/// used for reading closure kinds/signatures as they are inferred, /// used for reading closure kinds/signatures as they are inferred,
@ -569,7 +565,6 @@ pub struct InferCtxtBuilder<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>, fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
defining_use_anchor: Option<LocalDefId>, defining_use_anchor: Option<LocalDefId>,
reveal_defining_opaque_types: bool,
} }
pub trait TyCtxtInferExt<'tcx> { pub trait TyCtxtInferExt<'tcx> {
@ -578,12 +573,7 @@ pub trait TyCtxtInferExt<'tcx> {
impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> { impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> { fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
InferCtxtBuilder { InferCtxtBuilder { tcx: self, defining_use_anchor: None, fresh_typeck_results: None }
tcx: self,
defining_use_anchor: None,
fresh_typeck_results: None,
reveal_defining_opaque_types: false,
}
} }
} }
@ -607,13 +597,6 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
self self
} }
/// WF-checking doesn't need to recompute opaque types and can instead use
/// the type_of query to get them from typeck.
pub fn reveal_defining_opaque_types(mut self) -> Self {
self.reveal_defining_opaque_types = true;
self
}
/// Given a canonical value `C` as a starting point, create an /// Given a canonical value `C` as a starting point, create an
/// inference context that contains each of the bound values /// inference context that contains each of the bound values
/// within instantiated as a fresh variable. The `f` closure is /// within instantiated as a fresh variable. The `f` closure is
@ -638,17 +621,11 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
} }
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R { pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R {
let InferCtxtBuilder { let InferCtxtBuilder { tcx, defining_use_anchor, ref fresh_typeck_results } = *self;
tcx,
defining_use_anchor,
reveal_defining_opaque_types,
ref fresh_typeck_results,
} = *self;
let in_progress_typeck_results = fresh_typeck_results.as_ref(); let in_progress_typeck_results = fresh_typeck_results.as_ref();
f(InferCtxt { f(InferCtxt {
tcx, tcx,
defining_use_anchor, defining_use_anchor,
reveal_defining_opaque_types,
in_progress_typeck_results, in_progress_typeck_results,
inner: RefCell::new(InferCtxtInner::new()), inner: RefCell::new(InferCtxtInner::new()),
lexical_region_resolutions: RefCell::new(None), lexical_region_resolutions: RefCell::new(None),

View file

@ -95,13 +95,6 @@ impl<'tcx> InheritedBuilder<'tcx> {
let def_id = self.def_id; let def_id = self.def_id;
self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id))) self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id)))
} }
/// WF-checking doesn't need to recompute opaque types and can instead use
/// the type_of query to get them from typeck.
pub fn reveal_defining_opaque_types(mut self) -> Self {
self.infcx = self.infcx.reveal_defining_opaque_types();
self
}
} }
impl<'a, 'tcx> Inherited<'a, 'tcx> { impl<'a, 'tcx> Inherited<'a, 'tcx> {

View file

@ -968,7 +968,7 @@ fn for_item<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>) -> CheckWfFcxBuilder<
fn for_id(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> CheckWfFcxBuilder<'_> { fn for_id(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> CheckWfFcxBuilder<'_> {
CheckWfFcxBuilder { CheckWfFcxBuilder {
inherited: Inherited::build(tcx, def_id).reveal_defining_opaque_types(), inherited: Inherited::build(tcx, def_id),
id: hir::HirId::make_owner(def_id), id: hir::HirId::make_owner(def_id),
span, span,
param_env: tcx.param_env(def_id), param_env: tcx.param_env(def_id),