Skip to content

Commit cb35a7b

Browse files
committed
add BorrowckInferCtxt
1 parent 7aa413d commit cb35a7b

File tree

1 file changed

+29
-1
lines changed
  • compiler/rustc_borrowck/src

1 file changed

+29
-1
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_hir as hir;
2525
use rustc_hir::def_id::LocalDefId;
2626
use rustc_index::bit_set::ChunkedBitSet;
2727
use rustc_index::vec::IndexVec;
28-
use rustc_infer::infer::{DefiningAnchor, InferCtxt, TyCtxtInferExt};
28+
use rustc_infer::infer::{DefiningAnchor, InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt};
2929
use rustc_middle::mir::{
3030
traversal, Body, ClearCrossCrate, Local, Location, Mutability, NonDivergingIntrinsic, Operand,
3131
Place, PlaceElem, PlaceRef, VarDebugInfoContents,
@@ -43,6 +43,7 @@ use smallvec::SmallVec;
4343
use std::cell::OnceCell;
4444
use std::cell::RefCell;
4545
use std::collections::BTreeMap;
46+
use std::ops::Deref;
4647
use std::rc::Rc;
4748

4849
use rustc_mir_dataflow::impls::{
@@ -481,6 +482,33 @@ pub struct BodyWithBorrowckFacts<'tcx> {
481482
pub location_table: LocationTable,
482483
}
483484

485+
struct BorrowckInferCtxt<'cx, 'tcx> {
486+
pub(crate) infcx: &'cx InferCtxt<'tcx>,
487+
488+
#[cfg(debug_assertions)]
489+
pub(crate) _reg_var_to_origin: RefCell<FxHashMap<ty::Region<'tcx>, NllRegionVariableOrigin>>,
490+
}
491+
492+
impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
493+
#[cfg(not(debug_assertions))]
494+
pub(crate) fn _new(infcx: &'cx InferCtxt<'tcx>) -> Self {
495+
BorrowckInferCtxt { infcx }
496+
}
497+
498+
#[cfg(debug_assertions)]
499+
pub(crate) fn _new(infcx: &'cx InferCtxt<'tcx>) -> Self {
500+
BorrowckInferCtxt { infcx, _reg_var_to_origin: RefCell::new(Default::default()) }
501+
}
502+
}
503+
504+
impl<'cx, 'tcx> Deref for BorrowckInferCtxt<'cx, 'tcx> {
505+
type Target = InferCtxt<'tcx>;
506+
507+
fn deref(&self) -> &'cx Self::Target {
508+
self.infcx
509+
}
510+
}
511+
484512
struct MirBorrowckCtxt<'cx, 'tcx> {
485513
infcx: &'cx InferCtxt<'tcx>,
486514
param_env: ParamEnv<'tcx>,

0 commit comments

Comments
 (0)