@@ -1570,11 +1570,22 @@ impl Config {
1570
1570
let mut is_user_configured_rust_channel = false ;
1571
1571
1572
1572
if let Some ( rust) = toml. rust {
1573
- config. download_rustc_commit =
1574
- config. download_ci_rustc_commit ( rust. download_rustc . clone ( ) ) ;
1575
-
1576
- if config. download_rustc_commit . is_some ( ) {
1577
- check_incompatible_options_for_ci_rustc ( & rust) ;
1573
+ if let Some ( commit) = config. download_ci_rustc_commit ( rust. download_rustc . clone ( ) ) {
1574
+ // Primarily used by CI runners to avoid handling download-rustc incompatible
1575
+ // options one by one on shell scripts.
1576
+ let disable_ci_rustc_if_incompatible =
1577
+ env:: var_os ( "DISABLE_CI_RUSTC_IF_INCOMPATIBLE" )
1578
+ . is_some_and ( |s| s == "1" || s == "true" ) ;
1579
+
1580
+ if let Err ( e) = check_incompatible_options_for_ci_rustc ( & rust) {
1581
+ if disable_ci_rustc_if_incompatible {
1582
+ config. download_rustc_commit = None ;
1583
+ } else {
1584
+ panic ! ( "{}" , e) ;
1585
+ }
1586
+ } else {
1587
+ config. download_rustc_commit = Some ( commit) ;
1588
+ }
1578
1589
}
1579
1590
1580
1591
let Rust {
@@ -2614,14 +2625,15 @@ impl Config {
2614
2625
2615
2626
/// Checks the CI rustc incompatible options by destructuring the `Rust` instance
2616
2627
/// and makes sure that no rust options from config.toml are missed.
2617
- fn check_incompatible_options_for_ci_rustc ( rust : & Rust ) {
2628
+ fn check_incompatible_options_for_ci_rustc ( rust : & Rust ) -> Result < ( ) , String > {
2618
2629
macro_rules! err {
2619
2630
( $name: expr) => {
2620
- assert!(
2621
- $name. is_none( ) ,
2622
- "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`." ,
2623
- stringify!( $name) . replace( "_" , "-" )
2624
- ) ;
2631
+ if $name. is_some( ) {
2632
+ return Err ( format!(
2633
+ "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`." ,
2634
+ stringify!( $name) . replace( "_" , "-" )
2635
+ ) ) ;
2636
+ }
2625
2637
} ;
2626
2638
}
2627
2639
@@ -2717,6 +2729,8 @@ fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
2717
2729
warn ! ( channel) ;
2718
2730
warn ! ( description) ;
2719
2731
warn ! ( incremental) ;
2732
+
2733
+ Ok ( ( ) )
2720
2734
}
2721
2735
2722
2736
fn set < T > ( field : & mut T , val : Option < T > ) {
0 commit comments