@@ -149,8 +149,10 @@ pub struct Config {
149
149
offline : bool ,
150
150
/// A global static IPC control mechanism (used for managing parallel builds)
151
151
jobserver : Option < jobserver:: Client > ,
152
- /// Cli flags of the form "-Z something"
152
+ /// Cli flags of the form "-Z something" merged with config file values
153
153
unstable_flags : CliUnstable ,
154
+ /// Cli flags of the form "-Z something"
155
+ unstable_flags_cli : Option < Vec < String > > ,
154
156
/// A handle on curl easy mode for http calls
155
157
easy : LazyCell < RefCell < Easy > > ,
156
158
/// Cache of the `SourceId` for crates.io
@@ -231,6 +233,7 @@ impl Config {
231
233
}
232
234
} ,
233
235
unstable_flags : CliUnstable :: default ( ) ,
236
+ unstable_flags_cli : None ,
234
237
easy : LazyCell :: new ( ) ,
235
238
crates_io_source_id : LazyCell :: new ( ) ,
236
239
cache_rustc_info,
@@ -427,6 +430,7 @@ impl Config {
427
430
let values = self . load_values_from ( path. as_ref ( ) ) ?;
428
431
self . values . replace ( values) ;
429
432
self . merge_cli_args ( ) ?;
433
+ self . load_unstable_flags_from_config ( ) ?;
430
434
Ok ( ( ) )
431
435
}
432
436
@@ -703,6 +707,11 @@ impl Config {
703
707
cli_config : & [ String ] ,
704
708
) -> CargoResult < ( ) > {
705
709
self . unstable_flags . parse ( unstable_flags) ?;
710
+ if !unstable_flags. is_empty ( ) {
711
+ // store a copy of the cli flags separately for `load_unstable_flags_from_config`
712
+ // (we might also need it again for `reload_rooted_at`)
713
+ self . unstable_flags_cli = Some ( unstable_flags. to_vec ( ) ) ;
714
+ }
706
715
if !cli_config. is_empty ( ) {
707
716
self . unstable_flags . fail_if_stable_opt ( "--config" , 6699 ) ?;
708
717
self . cli_config = Some ( cli_config. iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ) ;
@@ -756,17 +765,25 @@ impl Config {
756
765
. unwrap_or ( false ) ;
757
766
self . target_dir = cli_target_dir;
758
767
768
+ self . load_unstable_flags_from_config ( ) ?;
769
+
770
+ Ok ( ( ) )
771
+ }
772
+
773
+ fn load_unstable_flags_from_config ( & mut self ) -> CargoResult < ( ) > {
759
774
// If nightly features are enabled, allow setting Z-flags from config
760
775
// using the `unstable` table. Ignore that block otherwise.
761
776
if nightly_features_allowed ( ) {
762
- if let Some ( unstable_flags) = self . get :: < Option < CliUnstable > > ( "unstable" ) ? {
763
- self . unstable_flags = unstable_flags;
777
+ self . unstable_flags = self
778
+ . get :: < Option < CliUnstable > > ( "unstable" ) ?
779
+ . unwrap_or_default ( ) ;
780
+ if let Some ( unstable_flags_cli) = & self . unstable_flags_cli {
781
+ // NB. It's not ideal to parse these twice, but doing it again here
782
+ // allows the CLI to override config files for both enabling
783
+ // and disabling, and doing it up top allows CLI Zflags to
784
+ // control config parsing behavior.
785
+ self . unstable_flags . parse ( unstable_flags_cli) ?;
764
786
}
765
- // NB. It's not ideal to parse these twice, but doing it again here
766
- // allows the CLI to override config files for both enabling
767
- // and disabling, and doing it up top allows CLI Zflags to
768
- // control config parsing behavior.
769
- self . unstable_flags . parse ( unstable_flags) ?;
770
787
}
771
788
772
789
Ok ( ( ) )
0 commit comments