Skip to content

Commit 4d978af

Browse files
committed
Remove GlobalCtxt::enter_local
1 parent 3b4a3d6 commit 4d978af

File tree

2 files changed

+22
-46
lines changed

2 files changed

+22
-46
lines changed

src/librustc_infer/infer/mod.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
570570
/// Necessary because we can't write the following bound:
571571
/// `F: for<'b, 'tcx> where 'tcx FnOnce(InferCtxt<'b, 'tcx>)`.
572572
pub struct InferCtxtBuilder<'tcx> {
573-
global_tcx: TyCtxt<'tcx>,
573+
tcx: TyCtxt<'tcx>,
574574
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
575575
}
576576

@@ -580,7 +580,7 @@ pub trait TyCtxtInferExt<'tcx> {
580580

581581
impl TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
582582
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
583-
InferCtxtBuilder { global_tcx: self, fresh_tables: None }
583+
InferCtxtBuilder { tcx: self, fresh_tables: None }
584584
}
585585
}
586586

@@ -616,24 +616,22 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
616616
}
617617

618618
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R {
619-
let InferCtxtBuilder { global_tcx, ref fresh_tables } = *self;
619+
let InferCtxtBuilder { tcx, ref fresh_tables } = *self;
620620
let in_progress_tables = fresh_tables.as_ref();
621-
global_tcx.enter_local(|tcx| {
622-
f(InferCtxt {
623-
tcx,
624-
in_progress_tables,
625-
inner: RefCell::new(InferCtxtInner::new()),
626-
lexical_region_resolutions: RefCell::new(None),
627-
selection_cache: Default::default(),
628-
evaluation_cache: Default::default(),
629-
reported_trait_errors: Default::default(),
630-
reported_closure_mismatch: Default::default(),
631-
tainted_by_errors_flag: Cell::new(false),
632-
err_count_on_creation: tcx.sess.err_count(),
633-
in_snapshot: Cell::new(false),
634-
skip_leak_check: Cell::new(false),
635-
universe: Cell::new(ty::UniverseIndex::ROOT),
636-
})
621+
f(InferCtxt {
622+
tcx,
623+
in_progress_tables,
624+
inner: RefCell::new(InferCtxtInner::new()),
625+
lexical_region_resolutions: RefCell::new(None),
626+
selection_cache: Default::default(),
627+
evaluation_cache: Default::default(),
628+
reported_trait_errors: Default::default(),
629+
reported_closure_mismatch: Default::default(),
630+
tainted_by_errors_flag: Cell::new(false),
631+
err_count_on_creation: tcx.sess.err_count(),
632+
in_snapshot: Cell::new(false),
633+
skip_leak_check: Cell::new(false),
634+
universe: Cell::new(ty::UniverseIndex::ROOT),
637635
})
638636
}
639637
}

src/librustc_middle/ty/context.rs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,28 +1553,6 @@ impl<'tcx> TyCtxt<'tcx> {
15531553
}
15541554
}
15551555

1556-
impl<'tcx> GlobalCtxt<'tcx> {
1557-
/// Calls the closure with a local `TyCtxt` using the given arena.
1558-
/// `interners` is a slot passed so we can create a CtxtInterners
1559-
/// with the same lifetime as `arena`.
1560-
pub fn enter_local<F, R>(&'tcx self, f: F) -> R
1561-
where
1562-
F: FnOnce(TyCtxt<'tcx>) -> R,
1563-
{
1564-
let tcx = TyCtxt { gcx: self };
1565-
ty::tls::with_related_context(tcx, |icx| {
1566-
let new_icx = ty::tls::ImplicitCtxt {
1567-
tcx,
1568-
query: icx.query,
1569-
diagnostics: icx.diagnostics,
1570-
layout_depth: icx.layout_depth,
1571-
task_deps: icx.task_deps,
1572-
};
1573-
ty::tls::enter_context(&new_icx, |_| f(tcx))
1574-
})
1575-
}
1576-
}
1577-
15781556
/// A trait implemented for all `X<'a>` types that can be safely and
15791557
/// efficiently converted to `X<'tcx>` as long as they are part of the
15801558
/// provided `TyCtxt<'tcx>`.
@@ -1811,11 +1789,11 @@ pub mod tls {
18111789
with_context_opt(|opt_context| f(opt_context.expect("no ImplicitCtxt stored in tls")))
18121790
}
18131791

1814-
/// Allows access to the current `ImplicitCtxt` whose tcx field has the same global
1815-
/// interner as the tcx argument passed in. This means the closure is given an `ImplicitCtxt`
1816-
/// with the same `'tcx` lifetime as the `TyCtxt` passed in.
1817-
/// This will panic if you pass it a `TyCtxt` which has a different global interner from
1818-
/// the current `ImplicitCtxt`'s `tcx` field.
1792+
/// Allows access to the current `ImplicitCtxt` whose tcx field is the same as the tcx argument
1793+
/// passed in. This means the closure is given an `ImplicitCtxt` with the same `'tcx` lifetime
1794+
/// as the `TyCtxt` passed in.
1795+
/// This will panic if you pass it a `TyCtxt` which is different from the current
1796+
/// `ImplicitCtxt`'s `tcx` field.
18191797
#[inline]
18201798
pub fn with_related_context<'tcx, F, R>(tcx: TyCtxt<'tcx>, f: F) -> R
18211799
where

0 commit comments

Comments
 (0)