1
- use getopts;
2
- use crate :: lint ;
3
- use crate :: middle :: cstore ;
4
- use crate :: session :: config :: {
5
- build_configuration ,
6
- build_session_options ,
7
- to_crate_config,
8
- parse_cfgspecs ,
9
- } ;
10
- use crate :: session:: config:: { LtoCli , LinkerPluginLto , SwitchWithOptPath , ExternEntry } ;
11
- use crate :: session:: build_session;
12
- use crate :: session:: search_paths:: SearchPath ;
1
+ extern crate getopts;
2
+
3
+ use crate :: interface :: parse_cfgspecs ;
4
+
5
+ use rustc :: lint ;
6
+ use rustc :: middle :: cstore ;
7
+ use rustc :: session :: config :: { build_configuration , build_session_options , to_crate_config} ;
8
+ use rustc :: session :: config :: { LtoCli , LinkerPluginLto , SwitchWithOptPath , ExternEntry } ;
9
+ use rustc :: session :: config :: { Externs , OutputType , OutputTypes , SymbolManglingVersion } ;
10
+ use rustc :: session:: config:: { rustc_optgroups , Options , ErrorOutputType , Passes } ;
11
+ use rustc :: session:: build_session;
12
+ use rustc :: session:: search_paths:: SearchPath ;
13
13
use std:: collections:: { BTreeMap , BTreeSet } ;
14
14
use std:: iter:: FromIterator ;
15
15
use std:: path:: PathBuf ;
16
- use super :: { Externs , OutputType , OutputTypes , SymbolManglingVersion } ;
17
16
use rustc_target:: spec:: { MergeFunctions , PanicStrategy , RelroLevel } ;
18
17
use syntax:: symbol:: sym;
19
18
use syntax:: edition:: { Edition , DEFAULT_EDITION } ;
20
19
use syntax;
21
- use super :: Options ;
22
20
use rustc_data_structures:: fx:: FxHashSet ;
21
+ use rustc_errors:: { ColorConfig , emitter:: HumanReadableErrorType , registry} ;
23
22
24
23
pub fn build_session_options_and_crate_config (
25
24
matches : & getopts:: Matches ,
@@ -30,22 +29,23 @@ pub fn build_session_options_and_crate_config(
30
29
)
31
30
}
32
31
33
- impl ExternEntry {
34
- fn new_public < S : Into < String > ,
35
- I : IntoIterator < Item = Option < S > > > ( locations : I ) -> ExternEntry {
36
- let locations: BTreeSet < _ > = locations. into_iter ( ) . map ( |o| o. map ( |s| s. into ( ) ) )
37
- . collect ( ) ;
38
-
39
- ExternEntry {
40
- locations,
41
- is_private_dep : false
42
- }
32
+ fn new_public_extern_entry < S , I > ( locations : I ) -> ExternEntry
33
+ where
34
+ S : Into < String > ,
35
+ I : IntoIterator < Item = Option < S > > ,
36
+ {
37
+ let locations: BTreeSet < _ > = locations. into_iter ( ) . map ( |o| o. map ( |s| s. into ( ) ) )
38
+ . collect ( ) ;
39
+
40
+ ExternEntry {
41
+ locations,
42
+ is_private_dep : false
43
43
}
44
44
}
45
45
46
46
fn optgroups ( ) -> getopts:: Options {
47
47
let mut opts = getopts:: Options :: new ( ) ;
48
- for group in super :: rustc_optgroups ( ) {
48
+ for group in rustc_optgroups ( ) {
49
49
( group. apply ) ( & mut opts) ;
50
50
}
51
51
return opts;
@@ -63,7 +63,7 @@ fn test_switch_implies_cfg_test() {
63
63
Ok ( m) => m,
64
64
Err ( f) => panic ! ( "test_switch_implies_cfg_test: {}" , f) ,
65
65
} ;
66
- let registry = errors :: registry:: Registry :: new ( & [ ] ) ;
66
+ let registry = registry:: Registry :: new ( & [ ] ) ;
67
67
let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
68
68
let sess = build_session ( sessopts, None , registry) ;
69
69
let cfg = build_configuration ( & sess, to_crate_config ( cfg) ) ;
@@ -81,7 +81,7 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
81
81
Ok ( m) => m,
82
82
Err ( f) => panic ! ( "test_switch_implies_cfg_test_unless_cfg_test: {}" , f) ,
83
83
} ;
84
- let registry = errors :: registry:: Registry :: new ( & [ ] ) ;
84
+ let registry = registry:: Registry :: new ( & [ ] ) ;
85
85
let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
86
86
let sess = build_session ( sessopts, None , registry) ;
87
87
let cfg = build_configuration ( & sess, to_crate_config ( cfg) ) ;
@@ -95,7 +95,7 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
95
95
fn test_can_print_warnings ( ) {
96
96
syntax:: with_default_globals ( || {
97
97
let matches = optgroups ( ) . parse ( & [ "-Awarnings" . to_string ( ) ] ) . unwrap ( ) ;
98
- let registry = errors :: registry:: Registry :: new ( & [ ] ) ;
98
+ let registry = registry:: Registry :: new ( & [ ] ) ;
99
99
let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
100
100
let sess = build_session ( sessopts, None , registry) ;
101
101
assert ! ( !sess. diagnostic( ) . can_emit_warnings( ) ) ;
@@ -105,15 +105,15 @@ fn test_can_print_warnings() {
105
105
let matches = optgroups ( )
106
106
. parse ( & [ "-Awarnings" . to_string ( ) , "-Dwarnings" . to_string ( ) ] )
107
107
. unwrap ( ) ;
108
- let registry = errors :: registry:: Registry :: new ( & [ ] ) ;
108
+ let registry = registry:: Registry :: new ( & [ ] ) ;
109
109
let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
110
110
let sess = build_session ( sessopts, None , registry) ;
111
111
assert ! ( sess. diagnostic( ) . can_emit_warnings( ) ) ;
112
112
} ) ;
113
113
114
114
syntax:: with_default_globals ( || {
115
115
let matches = optgroups ( ) . parse ( & [ "-Adead_code" . to_string ( ) ] ) . unwrap ( ) ;
116
- let registry = errors :: registry:: Registry :: new ( & [ ] ) ;
116
+ let registry = registry:: Registry :: new ( & [ ] ) ;
117
117
let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
118
118
let sess = build_session ( sessopts, None , registry) ;
119
119
assert ! ( sess. diagnostic( ) . can_emit_warnings( ) ) ;
@@ -172,33 +172,33 @@ fn test_externs_tracking_hash_different_construction_order() {
172
172
v1. externs = Externs :: new ( mk_map ( vec ! [
173
173
(
174
174
String :: from( "a" ) ,
175
- ExternEntry :: new_public ( vec![ Some ( "b" ) , Some ( "c" ) ] )
175
+ new_public_extern_entry ( vec![ Some ( "b" ) , Some ( "c" ) ] )
176
176
) ,
177
177
(
178
178
String :: from( "d" ) ,
179
- ExternEntry :: new_public ( vec![ Some ( "e" ) , Some ( "f" ) ] )
179
+ new_public_extern_entry ( vec![ Some ( "e" ) , Some ( "f" ) ] )
180
180
) ,
181
181
] ) ) ;
182
182
183
183
v2. externs = Externs :: new ( mk_map ( vec ! [
184
184
(
185
185
String :: from( "d" ) ,
186
- ExternEntry :: new_public ( vec![ Some ( "e" ) , Some ( "f" ) ] )
186
+ new_public_extern_entry ( vec![ Some ( "e" ) , Some ( "f" ) ] )
187
187
) ,
188
188
(
189
189
String :: from( "a" ) ,
190
- ExternEntry :: new_public ( vec![ Some ( "b" ) , Some ( "c" ) ] )
190
+ new_public_extern_entry ( vec![ Some ( "b" ) , Some ( "c" ) ] )
191
191
) ,
192
192
] ) ) ;
193
193
194
194
v3. externs = Externs :: new ( mk_map ( vec ! [
195
195
(
196
196
String :: from( "a" ) ,
197
- ExternEntry :: new_public ( vec![ Some ( "b" ) , Some ( "c" ) ] )
197
+ new_public_extern_entry ( vec![ Some ( "b" ) , Some ( "c" ) ] )
198
198
) ,
199
199
(
200
200
String :: from( "d" ) ,
201
- ExternEntry :: new_public ( vec![ Some ( "f" ) , Some ( "e" ) ] )
201
+ new_public_extern_entry ( vec![ Some ( "f" ) , Some ( "e" ) ] )
202
202
) ,
203
203
] ) ) ;
204
204
@@ -282,9 +282,9 @@ fn test_search_paths_tracking_hash_different_order() {
282
282
let mut v3 = Options :: default ( ) ;
283
283
let mut v4 = Options :: default ( ) ;
284
284
285
- const JSON : super :: ErrorOutputType = super :: ErrorOutputType :: Json {
285
+ const JSON : ErrorOutputType = ErrorOutputType :: Json {
286
286
pretty : false ,
287
- json_rendered : super :: HumanReadableErrorType :: Default ( super :: ColorConfig :: Never ) ,
287
+ json_rendered : HumanReadableErrorType :: Default ( ColorConfig :: Never ) ,
288
288
} ;
289
289
290
290
// Reference
@@ -455,7 +455,7 @@ fn test_codegen_options_tracking_hash() {
455
455
opts. cg . codegen_units = Some ( 42 ) ;
456
456
assert_eq ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
457
457
458
- opts. cg . remark = super :: Passes :: Some ( vec ! [ String :: from( "pass1" ) , String :: from( "pass2" ) ] ) ;
458
+ opts. cg . remark = Passes :: Some ( vec ! [ String :: from( "pass1" ) , String :: from( "pass2" ) ] ) ;
459
459
assert_eq ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
460
460
461
461
opts. cg . save_temps = true ;
0 commit comments