File tree 2 files changed +25
-0
lines changed
compiler/rustc_session/src
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,17 @@ impl LinkSelfContained {
306
306
pub fn is_linker_disabled ( & self ) -> bool {
307
307
self . disabled_components . contains ( LinkSelfContainedComponents :: LINKER )
308
308
}
309
+
310
+ /// Returns CLI inconsistencies to emit errors: individual components were both enabled and
311
+ /// disabled.
312
+ fn check_consistency ( & self ) -> Option < LinkSelfContainedComponents > {
313
+ if self . explicitly_set . is_some ( ) {
314
+ None
315
+ } else {
316
+ let common = self . enabled_components . intersection ( self . disabled_components ) ;
317
+ if common. is_empty ( ) { None } else { Some ( common) }
318
+ }
319
+ }
309
320
}
310
321
311
322
/// Used with `-Z assert-incr-state`.
@@ -2753,6 +2764,19 @@ pub fn build_session_options(
2753
2764
}
2754
2765
}
2755
2766
2767
+ // Check `-C link-self-contained` for consistency: individual components cannot be both enabled
2768
+ // and disabled at the same time.
2769
+ if let Some ( erroneous_components) = cg. link_self_contained . check_consistency ( ) {
2770
+ let names: String = erroneous_components
2771
+ . into_iter ( )
2772
+ . map ( |c| c. as_str ( ) . unwrap ( ) )
2773
+ . intersperse ( ", " )
2774
+ . collect ( ) ;
2775
+ handler. early_error ( format ! (
2776
+ "some `-C link-self-contained` components were both enabled and disabled: {names}"
2777
+ ) ) ;
2778
+ }
2779
+
2756
2780
let prints = collect_print_requests ( handler, & mut cg, & mut unstable_opts, matches) ;
2757
2781
2758
2782
let cg = cg;
Original file line number Diff line number Diff line change 6
6
#![ feature( option_get_or_insert_default) ]
7
7
#![ feature( rustc_attrs) ]
8
8
#![ feature( map_many_mut) ]
9
+ #![ feature( iter_intersperse) ]
9
10
#![ recursion_limit = "256" ]
10
11
#![ allow( rustc:: potential_query_instability) ]
11
12
#![ deny( rustc:: untranslatable_diagnostic) ]
You can’t perform that action at this time.
0 commit comments