@@ -275,18 +275,18 @@ impl OutputTypes {
275
275
// DO NOT switch BTreeMap or BTreeSet out for an unsorted container type! That
276
276
// would break dependency tracking for commandline arguments.
277
277
#[ derive( Clone , Hash ) ]
278
- pub struct Externs ( BTreeMap < String , BTreeSet < String > > ) ;
278
+ pub struct Externs ( BTreeMap < String , BTreeSet < Option < String > > > ) ;
279
279
280
280
impl Externs {
281
- pub fn new ( data : BTreeMap < String , BTreeSet < String > > ) -> Externs {
281
+ pub fn new ( data : BTreeMap < String , BTreeSet < Option < String > > > ) -> Externs {
282
282
Externs ( data)
283
283
}
284
284
285
- pub fn get ( & self , key : & str ) -> Option < & BTreeSet < String > > {
285
+ pub fn get ( & self , key : & str ) -> Option < & BTreeSet < Option < String > > > {
286
286
self . 0 . get ( key)
287
287
}
288
288
289
- pub fn iter < ' a > ( & ' a self ) -> BTreeMapIter < ' a , String , BTreeSet < String > > {
289
+ pub fn iter < ' a > ( & ' a self ) -> BTreeMapIter < ' a , String , BTreeSet < Option < String > > > {
290
290
self . 0 . iter ( )
291
291
}
292
292
}
@@ -2169,6 +2169,8 @@ pub fn build_session_options_and_crate_config(
2169
2169
let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
2170
2170
let test = matches. opt_present ( "test" ) ;
2171
2171
2172
+ let is_unstable_enabled = nightly_options:: is_unstable_enabled ( matches) ;
2173
+
2172
2174
prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |s| match & * s {
2173
2175
"crate-name" => PrintRequest :: CrateName ,
2174
2176
"file-names" => PrintRequest :: FileNames ,
@@ -2182,15 +2184,13 @@ pub fn build_session_options_and_crate_config(
2182
2184
"tls-models" => PrintRequest :: TlsModels ,
2183
2185
"native-static-libs" => PrintRequest :: NativeStaticLibs ,
2184
2186
"target-spec-json" => {
2185
- if nightly_options :: is_unstable_enabled ( matches ) {
2187
+ if is_unstable_enabled {
2186
2188
PrintRequest :: TargetSpec
2187
2189
} else {
2188
2190
early_error (
2189
2191
error_format,
2190
- & format ! (
2191
- "the `-Z unstable-options` flag must also be passed to \
2192
- enable the target-spec-json print option"
2193
- ) ,
2192
+ "the `-Z unstable-options` flag must also be passed to \
2193
+ enable the target-spec-json print option",
2194
2194
) ;
2195
2195
}
2196
2196
}
@@ -2220,18 +2220,19 @@ pub fn build_session_options_and_crate_config(
2220
2220
Some ( s) => s,
2221
2221
None => early_error ( error_format, "--extern value must not be empty" ) ,
2222
2222
} ;
2223
- let location = match parts. next ( ) {
2224
- Some ( s ) => s ,
2225
- None => early_error (
2223
+ let location = parts. next ( ) . map ( |s| s . to_string ( ) ) ;
2224
+ if location . is_none ( ) && !is_unstable_enabled {
2225
+ early_error (
2226
2226
error_format,
2227
- "--extern value must be of the format `foo=bar`" ,
2228
- ) ,
2227
+ "the `-Z unstable-options` flag must also be passed to \
2228
+ enable `--extern crate_name` without `=path`",
2229
+ ) ;
2229
2230
} ;
2230
2231
2231
2232
externs
2232
2233
. entry ( name. to_string ( ) )
2233
2234
. or_default ( )
2234
- . insert ( location. to_string ( ) ) ;
2235
+ . insert ( location) ;
2235
2236
}
2236
2237
2237
2238
let crate_name = matches. opt_str ( "crate-name" ) ;
@@ -2687,33 +2688,33 @@ mod tests {
2687
2688
v1. externs = Externs :: new ( mk_map ( vec ! [
2688
2689
(
2689
2690
String :: from( "a" ) ,
2690
- mk_set( vec![ String :: from( "b" ) , String :: from( "c" ) ] ) ,
2691
+ mk_set( vec![ Some ( String :: from( "b" ) ) , Some ( String :: from( "c" ) ) ] ) ,
2691
2692
) ,
2692
2693
(
2693
2694
String :: from( "d" ) ,
2694
- mk_set( vec![ String :: from( "e" ) , String :: from( "f" ) ] ) ,
2695
+ mk_set( vec![ Some ( String :: from( "e" ) ) , Some ( String :: from( "f" ) ) ] ) ,
2695
2696
) ,
2696
2697
] ) ) ;
2697
2698
2698
2699
v2. externs = Externs :: new ( mk_map ( vec ! [
2699
2700
(
2700
2701
String :: from( "d" ) ,
2701
- mk_set( vec![ String :: from( "e" ) , String :: from( "f" ) ] ) ,
2702
+ mk_set( vec![ Some ( String :: from( "e" ) ) , Some ( String :: from( "f" ) ) ] ) ,
2702
2703
) ,
2703
2704
(
2704
2705
String :: from( "a" ) ,
2705
- mk_set( vec![ String :: from( "b" ) , String :: from( "c" ) ] ) ,
2706
+ mk_set( vec![ Some ( String :: from( "b" ) ) , Some ( String :: from( "c" ) ) ] ) ,
2706
2707
) ,
2707
2708
] ) ) ;
2708
2709
2709
2710
v3. externs = Externs :: new ( mk_map ( vec ! [
2710
2711
(
2711
2712
String :: from( "a" ) ,
2712
- mk_set( vec![ String :: from( "b" ) , String :: from( "c" ) ] ) ,
2713
+ mk_set( vec![ Some ( String :: from( "b" ) ) , Some ( String :: from( "c" ) ) ] ) ,
2713
2714
) ,
2714
2715
(
2715
2716
String :: from( "d" ) ,
2716
- mk_set( vec![ String :: from( "f" ) , String :: from( "e" ) ] ) ,
2717
+ mk_set( vec![ Some ( String :: from( "f" ) ) , Some ( String :: from( "e" ) ) ] ) ,
2717
2718
) ,
2718
2719
] ) ) ;
2719
2720
0 commit comments