diff options
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/interface.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 15 |
3 files changed, 14 insertions, 13 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index a1090ee316d..086c49c7397 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -76,7 +76,7 @@ impl Compiler { /// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`. pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String>)> { - rustc_span::with_default_session_globals(move || { + rustc_span::create_default_session_if_not_set_then(move |_| { let cfg = cfgspecs .into_iter() .map(|s| { diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index b252409a92a..a053253ec16 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -107,7 +107,7 @@ fn assert_non_crate_hash_different(x: &Options, y: &Options) { // When the user supplies --test we should implicitly supply --cfg test #[test] fn test_switch_implies_cfg_test() { - rustc_span::with_default_session_globals(|| { + rustc_span::create_default_session_globals_then(|| { let matches = optgroups().parse(&["--test".to_string()]).unwrap(); let (sess, cfg) = mk_session(matches); let cfg = build_configuration(&sess, to_crate_config(cfg)); @@ -118,7 +118,7 @@ fn test_switch_implies_cfg_test() { // When the user supplies --test and --cfg test, don't implicitly add another --cfg test #[test] fn test_switch_implies_cfg_test_unless_cfg_test() { - rustc_span::with_default_session_globals(|| { + rustc_span::create_default_session_globals_then(|| { let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap(); let (sess, cfg) = mk_session(matches); let cfg = build_configuration(&sess, to_crate_config(cfg)); @@ -130,20 +130,20 @@ fn test_switch_implies_cfg_test_unless_cfg_test() { #[test] fn test_can_print_warnings() { - rustc_span::with_default_session_globals(|| { + rustc_span::create_default_session_globals_then(|| { let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap(); let (sess, _) = mk_session(matches); assert!(!sess.diagnostic().can_emit_warnings()); }); - rustc_span::with_default_session_globals(|| { + rustc_span::create_default_session_globals_then(|| { let matches = optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap(); let (sess, _) = mk_session(matches); assert!(sess.diagnostic().can_emit_warnings()); }); - rustc_span::with_default_session_globals(|| { + rustc_span::create_default_session_globals_then(|| { let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap(); let (sess, _) = mk_session(matches); assert!(sess.diagnostic().can_emit_warnings()); diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index d1d0eee365d..4f51ce62042 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -150,7 +150,7 @@ pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Se crate::callbacks::setup_callbacks(); let main_handler = move || { - rustc_span::with_session_globals(edition, || { + rustc_span::create_session_globals_then(edition, || { io::set_output_capture(stderr.clone()); f() }) @@ -171,12 +171,13 @@ unsafe fn handle_deadlock() { rustc_data_structures::sync::assert_sync::<tls::ImplicitCtxt<'_, '_>>(); let icx: &tls::ImplicitCtxt<'_, '_> = &*(context as *const tls::ImplicitCtxt<'_, '_>); - let session_globals = rustc_span::SESSION_GLOBALS.with(|sg| sg as *const _); + let session_globals = rustc_span::with_session_globals(|sg| sg as *const _); let session_globals = &*session_globals; thread::spawn(move || { tls::enter_context(icx, |_| { - rustc_span::SESSION_GLOBALS - .set(session_globals, || tls::with(|tcx| tcx.queries.deadlock(tcx, ®istry))) + rustc_span::set_session_globals_then(session_globals, || { + tls::with(|tcx| tcx.queries.deadlock(tcx, ®istry)) + }) }); }); } @@ -203,13 +204,13 @@ pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Se let with_pool = move |pool: &rayon::ThreadPool| pool.install(f); - rustc_span::with_session_globals(edition, || { - rustc_span::SESSION_GLOBALS.with(|session_globals| { + rustc_span::create_session_globals_then(edition, || { + rustc_span::with_session_globals(|session_globals| { // The main handler runs for each Rayon worker thread and sets up // the thread local rustc uses. `session_globals` is captured and set // on the new threads. let main_handler = move |thread: rayon::ThreadBuilder| { - rustc_span::SESSION_GLOBALS.set(session_globals, || { + rustc_span::set_session_globals_then(session_globals, || { io::set_output_capture(stderr.clone()); thread.run() }) |
