@@ -161,28 +161,13 @@ macro_rules! create_config {
161
161
162
162
fn fill_from_parsed_config( mut self , parsed: PartialConfig , dir: & Path ) -> Config {
163
163
$(
164
- if let Some ( val) = parsed. $i {
165
- let nightly = crate :: is_nightly_channel!( ) ;
164
+ if let Some ( option_value) = parsed. $i {
166
165
let option_stable = self . $i. 3 ;
167
- let variant_stable = val. stable_variant( ) ;
168
-
169
- match ( nightly, option_stable, variant_stable) {
170
- // Stable with an unstable option
171
- ( false , false , _) => {
172
- eprintln!( "Warning: can't set `{} = {:?}`, unstable features are only \
173
- available in nightly channel.", stringify!( $i) , val) ;
174
- } ,
175
- // Stable with a stable option, but an unstable variant
176
- ( false , true , false ) => {
177
- eprintln!( "Warning: can't set `{} = {:?}`, unstable variants are only \
178
- available in nightly channel.", stringify!( $i) , val) ;
179
- } ,
180
- // Nightly: everything allowed
181
- // Stable with stable option and variant: allowed
182
- ( true , _, _) | ( false , true , true ) => {
183
- self . $i. 1 = true ;
184
- self . $i. 2 = val;
185
- } ,
166
+ if $crate:: config:: config_type:: is_stable_option_and_value(
167
+ stringify!( $i) , option_stable, & option_value
168
+ ) {
169
+ self . $i. 1 = true ;
170
+ self . $i. 2 = option_value;
186
171
}
187
172
}
188
173
) +
@@ -249,12 +234,18 @@ macro_rules! create_config {
249
234
match key {
250
235
$(
251
236
stringify!( $i) => {
252
- self . $i. 1 = true ;
253
- self . $i. 2 = val. parse:: <$ty>( )
237
+ let option_value = val. parse:: <$ty>( )
254
238
. expect( & format!( "Failed to parse override for {} (\" {}\" ) as a {}" ,
255
239
stringify!( $i) ,
256
240
val,
257
241
stringify!( $ty) ) ) ;
242
+ let option_stable = self . $i. 3 ;
243
+ if $crate:: config:: config_type:: is_stable_option_and_value(
244
+ stringify!( $i) , option_stable, & option_value
245
+ ) {
246
+ self . $i. 1 = true ;
247
+ self . $i. 2 = option_value;
248
+ }
258
249
}
259
250
) +
260
251
_ => panic!( "Unknown config key in override: {}" , key)
@@ -452,3 +443,38 @@ macro_rules! create_config {
452
443
}
453
444
)
454
445
}
446
+
447
+ pub ( crate ) fn is_stable_option_and_value < T > (
448
+ option_name : & str ,
449
+ option_stable : bool ,
450
+ option_value : & T ,
451
+ ) -> bool
452
+ where
453
+ T : PartialEq + std:: fmt:: Debug + ConfigType ,
454
+ {
455
+ let nightly = crate :: is_nightly_channel!( ) ;
456
+ let variant_stable = option_value. stable_variant ( ) ;
457
+ match ( nightly, option_stable, variant_stable) {
458
+ // Stable with an unstable option
459
+ ( false , false , _) => {
460
+ eprintln ! (
461
+ "Warning: can't set `{} = {:?}`, unstable features are only \
462
+ available in nightly channel.",
463
+ option_name, option_value
464
+ ) ;
465
+ false
466
+ }
467
+ // Stable with a stable option, but an unstable variant
468
+ ( false , true , false ) => {
469
+ eprintln ! (
470
+ "Warning: can't set `{} = {:?}`, unstable variants are only \
471
+ available in nightly channel.",
472
+ option_name, option_value
473
+ ) ;
474
+ false
475
+ }
476
+ // Nightly: everything allowed
477
+ // Stable with stable option and variant: allowed
478
+ ( true , _, _) | ( false , true , true ) => true ,
479
+ }
480
+ }
0 commit comments