@@ -1923,7 +1923,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19231923 let mut features = Features :: new ( ) ;
19241924 let mut edition_enabled_features = FxHashMap ( ) ;
19251925
1926- for & ( name, .., f_edition, set) in ACTIVE_FEATURES . iter ( ) {
1926+ for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
19271927 if let Some ( f_edition) = f_edition {
19281928 if f_edition <= crate_edition {
19291929 set ( & mut features, DUMMY_SP ) ;
@@ -1932,35 +1932,31 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19321932 }
19331933 }
19341934
1935+ // Process the edition umbrella feature-gates first, to ensure
1936+ // `edition_enabled_features` is completed before it's queried.
19351937 for attr in krate_attrs {
19361938 if !attr. check_name ( "feature" ) {
19371939 continue
19381940 }
19391941
19401942 let list = match attr. meta_item_list ( ) {
19411943 Some ( list) => list,
1942- None => {
1943- span_err ! ( span_handler, attr. span, E0555 ,
1944- "malformed feature attribute, expected #![feature(...)]" ) ;
1945- continue
1946- }
1944+ None => continue ,
19471945 } ;
19481946
19491947 for mi in list {
19501948 let name = if let Some ( word) = mi. word ( ) {
19511949 word. name ( )
19521950 } else {
1953- span_err ! ( span_handler, mi. span, E0556 ,
1954- "malformed feature, expected just one word" ) ;
19551951 continue
19561952 } ;
19571953
19581954 if let Some ( edition) = ALL_EDITIONS . iter ( ) . find ( |e| name == e. feature_name ( ) ) {
19591955 if * edition <= crate_edition {
1960- continue
1956+ continue ;
19611957 }
19621958
1963- for & ( name, .., f_edition, set) in ACTIVE_FEATURES . iter ( ) {
1959+ for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
19641960 if let Some ( f_edition) = f_edition {
19651961 if f_edition <= * edition {
19661962 // FIXME(Manishearth) there is currently no way to set
@@ -1970,8 +1966,36 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19701966 }
19711967 }
19721968 }
1969+ }
1970+ }
1971+ }
1972+
1973+ for attr in krate_attrs {
1974+ if !attr. check_name ( "feature" ) {
1975+ continue
1976+ }
1977+
1978+ let list = match attr. meta_item_list ( ) {
1979+ Some ( list) => list,
1980+ None => {
1981+ span_err ! ( span_handler, attr. span, E0555 ,
1982+ "malformed feature attribute, expected #![feature(...)]" ) ;
1983+ continue
1984+ }
1985+ } ;
19731986
1987+ for mi in list {
1988+ let name = if let Some ( word) = mi. word ( ) {
1989+ word. name ( )
1990+ } else {
1991+ span_err ! ( span_handler, mi. span, E0556 ,
1992+ "malformed feature, expected just one word" ) ;
19741993 continue
1994+ } ;
1995+
1996+ if ALL_EDITIONS . iter ( ) . any ( |e| name == e. feature_name ( ) ) {
1997+ // Handled in the separate loop above.
1998+ continue ;
19751999 }
19762000
19772001 if let Some ( ( .., set) ) = ACTIVE_FEATURES . iter ( ) . find ( |f| name == f. 0 ) {
0 commit comments