Skip to content

Commit ff7b19b

Browse files
committed
Add DefiningAnchor to FnCtxt in preparation for removing it from InferCtxt
1 parent 0d4017c commit ff7b19b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc_hir_typeck/src/inherited.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ use std::ops::Deref;
2828
pub struct Inherited<'tcx> {
2929
pub(super) infcx: InferCtxt<'tcx>,
3030

31+
/// The `DefId` of the item in whose context we are performing inference or typeck.
32+
/// It is used to check whether an opaque type use is a defining use.
33+
///
34+
/// Its default value is `DefiningAnchor::Error`, this way it is easier to catch errors that
35+
/// might come up during inference or typeck.
36+
pub(super) defining_use_anchor: DefiningAnchor,
37+
3138
pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
3239

3340
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
@@ -118,7 +125,9 @@ impl<'tcx> Inherited<'tcx> {
118125
let tcx = infcx.tcx;
119126
let body_id = tcx.hir().maybe_body_owned_by(def_id);
120127

128+
let defining_use_anchor = DefiningAnchor::Bind(typeck_results.borrow().hir_owner.def_id);
121129
Inherited {
130+
defining_use_anchor,
122131
typeck_results,
123132
infcx,
124133
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),

0 commit comments

Comments
 (0)