Rework SESSION_GLOBALS API to prevent overwriting it

This commit is contained in:
Guillaume Gomez
2021-05-05 21:31:25 +02:00
committed by Guillaume Gomez
parent 0cd0709f19
commit a2654fb64c
27 changed files with 146 additions and 100 deletions

View File

@@ -5,7 +5,6 @@
// See https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28
use crate::hygiene::SyntaxContext;
use crate::SESSION_GLOBALS;
use crate::{BytePos, SpanData};
use rustc_data_structures::fx::FxIndexSet;
@@ -122,5 +121,5 @@ impl SpanInterner {
// If an interner exists, return it. Otherwise, prepare a fresh one.
#[inline]
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.span_interner.lock()))
crate::with_session_globals(|session_globals| f(&mut *session_globals.span_interner.lock()))
}