@@ -732,13 +732,9 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
732
732
}
733
733
}
734
734
735
- for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
736
- if let Some ( f_edition) = f_edition {
737
- if f_edition <= crate_edition {
738
- set ( & mut features, DUMMY_SP ) ;
739
- edition_enabled_features. insert ( name, crate_edition) ;
740
- }
741
- }
735
+ for feature in active_features_up_to ( crate_edition) {
736
+ feature. set ( & mut features, DUMMY_SP ) ;
737
+ edition_enabled_features. insert ( feature. name , crate_edition) ;
742
738
}
743
739
744
740
// Process the edition umbrella feature-gates first, to ensure
@@ -760,20 +756,17 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
760
756
761
757
let name = mi. name_or_empty ( ) ;
762
758
763
- if let Some ( edition) = ALL_EDITIONS . iter ( ) . find ( |e| name == e. feature_name ( ) ) {
764
- if * edition <= crate_edition {
759
+ let edition = ALL_EDITIONS . iter ( ) . find ( |e| name == e. feature_name ( ) ) . copied ( ) ;
760
+ if let Some ( edition) = edition {
761
+ if edition <= crate_edition {
765
762
continue ;
766
763
}
767
764
768
- for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
769
- if let Some ( f_edition) = f_edition {
770
- if f_edition <= * edition {
771
- // FIXME(Manishearth) there is currently no way to set
772
- // lib features by edition
773
- set ( & mut features, DUMMY_SP ) ;
774
- edition_enabled_features. insert ( name, * edition) ;
775
- }
776
- }
765
+ for feature in active_features_up_to ( edition) {
766
+ // FIXME(Manishearth) there is currently no way to set
767
+ // lib features by edition
768
+ feature. set ( & mut features, DUMMY_SP ) ;
769
+ edition_enabled_features. insert ( feature. name , edition) ;
777
770
}
778
771
}
779
772
}
@@ -867,6 +860,17 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
867
860
features
868
861
}
869
862
863
+ fn active_features_up_to ( edition : Edition ) -> impl Iterator < Item =& ' static Feature > {
864
+ ACTIVE_FEATURES . iter ( )
865
+ . filter ( move |feature| {
866
+ if let Some ( feature_edition) = feature. edition {
867
+ feature_edition <= edition
868
+ } else {
869
+ false
870
+ }
871
+ } )
872
+ }
873
+
870
874
pub fn check_crate ( krate : & ast:: Crate ,
871
875
sess : & ParseSess ,
872
876
features : & Features ,
0 commit comments