Rework SESSION_GLOBALS API to prevent overwriting it
This commit is contained in:
committed by
Guillaume Gomez
parent
0cd0709f19
commit
a2654fb64c
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user