@@ -647,33 +647,15 @@ impl CliUnstable {
647
647
) ;
648
648
}
649
649
let mut warnings = Vec :: new ( ) ;
650
+ // We read flags twice, first to get allowed-features (if specified),
651
+ // and then to read the remaining unstable flags.
650
652
for flag in flags {
651
653
if flag. starts_with ( "allow-features=" ) {
652
654
self . add ( flag, & mut warnings) ?;
653
655
}
654
656
}
655
- if let Some ( allowed) = self . allow_features . take ( ) {
656
- for flag in flags {
657
- let k = flag
658
- . splitn ( 2 , '=' )
659
- . next ( )
660
- . expect ( "split always yields >=1 item" ) ;
661
- if k == "allow-features" {
662
- } else if allowed. contains ( k) {
663
- self . add ( flag, & mut warnings) ?;
664
- } else {
665
- bail ! (
666
- "the feature `{}` is not in the list of allowed features: {:?}" ,
667
- k,
668
- allowed
669
- ) ;
670
- }
671
- }
672
- self . allow_features = Some ( allowed) ;
673
- } else {
674
- for flag in flags {
675
- self . add ( flag, & mut warnings) ?;
676
- }
657
+ for flag in flags {
658
+ self . add ( flag, & mut warnings) ?;
677
659
}
678
660
Ok ( warnings)
679
661
}
@@ -744,6 +726,16 @@ impl CliUnstable {
744
726
) )
745
727
} ;
746
728
729
+ if let Some ( allowed) = & self . allow_features {
730
+ if k != "allow-features" && !allowed. contains ( k) {
731
+ bail ! (
732
+ "the feature `{}` is not in the list of allowed features: {:?}" ,
733
+ k,
734
+ allowed
735
+ ) ;
736
+ }
737
+ }
738
+
747
739
match k {
748
740
"print-im-a-teapot" => self . print_im_a_teapot = parse_bool ( k, v) ?,
749
741
"allow-features" => self . allow_features = Some ( parse_features ( v) . into_iter ( ) . collect ( ) ) ,
0 commit comments