@@ -25,10 +25,10 @@ use std::num::NonZeroUsize;
25
25
use std:: path:: { Path , PathBuf } ;
26
26
use std:: sync:: Arc ;
27
27
28
- fn mk_session ( handler : & mut EarlyErrorHandler , matches : getopts:: Matches ) -> ( Session , Cfg ) {
28
+ fn mk_session ( matches : getopts:: Matches ) -> ( Session , Cfg ) {
29
+ let mut early_handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
29
30
let registry = registry:: Registry :: new ( & [ ] ) ;
30
- let sessopts = build_session_options ( handler, & matches) ;
31
- let cfg = parse_cfg ( handler, matches. opt_strs ( "cfg" ) ) ;
31
+ let sessopts = build_session_options ( & mut early_handler, & matches) ;
32
32
let temps_dir = sessopts. unstable_opts . temps_dir . as_deref ( ) . map ( PathBuf :: from) ;
33
33
let io = CompilerIO {
34
34
input : Input :: Str { name : FileName :: Custom ( String :: new ( ) ) , input : String :: new ( ) } ,
@@ -37,7 +37,7 @@ fn mk_session(handler: &mut EarlyErrorHandler, matches: getopts::Matches) -> (Se
37
37
temps_dir,
38
38
} ;
39
39
let sess = build_session (
40
- handler ,
40
+ early_handler ,
41
41
sessopts,
42
42
io,
43
43
None ,
@@ -51,6 +51,7 @@ fn mk_session(handler: &mut EarlyErrorHandler, matches: getopts::Matches) -> (Se
51
51
Arc :: default ( ) ,
52
52
Default :: default ( ) ,
53
53
) ;
54
+ let cfg = parse_cfg ( & sess. diagnostic ( ) , matches. opt_strs ( "cfg" ) ) ;
54
55
( sess, cfg)
55
56
}
56
57
@@ -117,8 +118,7 @@ fn assert_non_crate_hash_different(x: &Options, y: &Options) {
117
118
fn test_switch_implies_cfg_test ( ) {
118
119
rustc_span:: create_default_session_globals_then ( || {
119
120
let matches = optgroups ( ) . parse ( & [ "--test" . to_string ( ) ] ) . unwrap ( ) ;
120
- let mut handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
121
- let ( sess, cfg) = mk_session ( & mut handler, matches) ;
121
+ let ( sess, cfg) = mk_session ( matches) ;
122
122
let cfg = build_configuration ( & sess, cfg) ;
123
123
assert ! ( cfg. contains( & ( sym:: test, None ) ) ) ;
124
124
} ) ;
@@ -129,8 +129,7 @@ fn test_switch_implies_cfg_test() {
129
129
fn test_switch_implies_cfg_test_unless_cfg_test ( ) {
130
130
rustc_span:: create_default_session_globals_then ( || {
131
131
let matches = optgroups ( ) . parse ( & [ "--test" . to_string ( ) , "--cfg=test" . to_string ( ) ] ) . unwrap ( ) ;
132
- let mut handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
133
- let ( sess, cfg) = mk_session ( & mut handler, matches) ;
132
+ let ( sess, cfg) = mk_session ( matches) ;
134
133
let cfg = build_configuration ( & sess, cfg) ;
135
134
let mut test_items = cfg. iter ( ) . filter ( |& & ( name, _) | name == sym:: test) ;
136
135
assert ! ( test_items. next( ) . is_some( ) ) ;
@@ -142,23 +141,20 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
142
141
fn test_can_print_warnings ( ) {
143
142
rustc_span:: create_default_session_globals_then ( || {
144
143
let matches = optgroups ( ) . parse ( & [ "-Awarnings" . to_string ( ) ] ) . unwrap ( ) ;
145
- let mut handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
146
- let ( sess, _) = mk_session ( & mut handler, matches) ;
144
+ let ( sess, _) = mk_session ( matches) ;
147
145
assert ! ( !sess. diagnostic( ) . can_emit_warnings( ) ) ;
148
146
} ) ;
149
147
150
148
rustc_span:: create_default_session_globals_then ( || {
151
149
let matches =
152
150
optgroups ( ) . parse ( & [ "-Awarnings" . to_string ( ) , "-Dwarnings" . to_string ( ) ] ) . unwrap ( ) ;
153
- let mut handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
154
- let ( sess, _) = mk_session ( & mut handler, matches) ;
151
+ let ( sess, _) = mk_session ( matches) ;
155
152
assert ! ( sess. diagnostic( ) . can_emit_warnings( ) ) ;
156
153
} ) ;
157
154
158
155
rustc_span:: create_default_session_globals_then ( || {
159
156
let matches = optgroups ( ) . parse ( & [ "-Adead_code" . to_string ( ) ] ) . unwrap ( ) ;
160
- let mut handler = EarlyErrorHandler :: new ( ErrorOutputType :: default ( ) ) ;
161
- let ( sess, _) = mk_session ( & mut handler, matches) ;
157
+ let ( sess, _) = mk_session ( matches) ;
162
158
assert ! ( sess. diagnostic( ) . can_emit_warnings( ) ) ;
163
159
} ) ;
164
160
}
0 commit comments