diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2022-09-09 13:01:06 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2022-10-07 07:06:19 -0500 |
| commit | 349415d1c67df81e18519a7d2c6375901ec31b3d (patch) | |
| tree | 473e5978a9b4a1fbc33f1306962728e55ea5cf0f /compiler/rustc_hir_analysis/src/check/inherited.rs | |
| parent | 4a68373217e610e2e6768bae27c6b15e0377faad (diff) | |
| download | rust-349415d1c67df81e18519a7d2c6375901ec31b3d.tar.gz rust-349415d1c67df81e18519a7d2c6375901ec31b3d.zip | |
Remove TypeckResults from InferCtxt
Diffstat (limited to 'compiler/rustc_hir_analysis/src/check/inherited.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/inherited.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/inherited.rs b/compiler/rustc_hir_analysis/src/check/inherited.rs index 6c337e3eaba..e273571edbd 100644 --- a/compiler/rustc_hir_analysis/src/check/inherited.rs +++ b/compiler/rustc_hir_analysis/src/check/inherited.rs @@ -6,7 +6,7 @@ use rustc_hir as hir; use rustc_hir::def_id::LocalDefId; use rustc_hir::HirIdMap; use rustc_infer::infer; -use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt}; +use rustc_infer::infer::{DefiningAnchor, InferCtxt, InferOk, TyCtxtInferExt}; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::visit::TypeVisitable; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -30,7 +30,7 @@ use std::ops::Deref; /// `bar()` will each have their own `FnCtxt`, but they will /// share the inherited fields. pub struct Inherited<'a, 'tcx> { - pub(super) infcx: InferCtxt<'a, 'tcx>, + pub(super) infcx: InferCtxt<'tcx>, pub(super) typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>, @@ -71,7 +71,7 @@ pub struct Inherited<'a, 'tcx> { } impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> { - type Target = InferCtxt<'a, 'tcx>; + type Target = InferCtxt<'tcx>; fn deref(&self) -> &Self::Target { &self.infcx } @@ -83,6 +83,7 @@ impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> { pub struct InheritedBuilder<'tcx> { infcx: infer::InferCtxtBuilder<'tcx>, def_id: LocalDefId, + typeck_results: RefCell<ty::TypeckResults<'tcx>>, } impl<'tcx> Inherited<'_, 'tcx> { @@ -93,7 +94,7 @@ impl<'tcx> Inherited<'_, 'tcx> { infcx: tcx .infer_ctxt() .ignoring_regions() - .with_fresh_in_progress_typeck_results(hir_owner) + .with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)) .with_normalize_fn_sig_for_diagnostic(Lrc::new(move |infcx, fn_sig| { if fn_sig.has_escaping_bound_vars() { return fn_sig; @@ -117,6 +118,7 @@ impl<'tcx> Inherited<'_, 'tcx> { }) })), def_id, + typeck_results: RefCell::new(ty::TypeckResults::new(hir_owner)), } } } @@ -127,16 +129,18 @@ impl<'tcx> InheritedBuilder<'tcx> { F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R, { 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, &self.typeck_results))) } } impl<'a, 'tcx> Inherited<'a, 'tcx> { - fn new(infcx: InferCtxt<'a, 'tcx>, def_id: LocalDefId) -> Self { + fn new( + infcx: InferCtxt<'tcx>, + def_id: LocalDefId, + typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>, + ) -> Self { let tcx = infcx.tcx; let body_id = tcx.hir().maybe_body_owned_by(def_id); - let typeck_results = - infcx.in_progress_typeck_results.expect("building `FnCtxt` without typeck results"); Inherited { typeck_results, |
