@@ -1923,7 +1923,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
1923
1923
let mut features = Features :: new ( ) ;
1924
1924
let mut edition_enabled_features = FxHashMap ( ) ;
1925
1925
1926
- for & ( name, .., f_edition, set) in ACTIVE_FEATURES . iter ( ) {
1926
+ for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
1927
1927
if let Some ( f_edition) = f_edition {
1928
1928
if f_edition <= crate_edition {
1929
1929
set ( & mut features, DUMMY_SP ) ;
@@ -1932,35 +1932,31 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
1932
1932
}
1933
1933
}
1934
1934
1935
+ // Process the edition umbrella feature-gates first, to ensure
1936
+ // `edition_enabled_features` is completed before it's queried.
1935
1937
for attr in krate_attrs {
1936
1938
if !attr. check_name ( "feature" ) {
1937
1939
continue
1938
1940
}
1939
1941
1940
1942
let list = match attr. meta_item_list ( ) {
1941
1943
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 ,
1947
1945
} ;
1948
1946
1949
1947
for mi in list {
1950
1948
let name = if let Some ( word) = mi. word ( ) {
1951
1949
word. name ( )
1952
1950
} else {
1953
- span_err ! ( span_handler, mi. span, E0556 ,
1954
- "malformed feature, expected just one word" ) ;
1955
1951
continue
1956
1952
} ;
1957
1953
1958
1954
if let Some ( edition) = ALL_EDITIONS . iter ( ) . find ( |e| name == e. feature_name ( ) ) {
1959
1955
if * edition <= crate_edition {
1960
- continue
1956
+ continue ;
1961
1957
}
1962
1958
1963
- for & ( name, .., f_edition, set) in ACTIVE_FEATURES . iter ( ) {
1959
+ for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
1964
1960
if let Some ( f_edition) = f_edition {
1965
1961
if f_edition <= * edition {
1966
1962
// FIXME(Manishearth) there is currently no way to set
@@ -1970,8 +1966,36 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
1970
1966
}
1971
1967
}
1972
1968
}
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
+ } ;
1973
1986
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" ) ;
1974
1993
continue
1994
+ } ;
1995
+
1996
+ if ALL_EDITIONS . iter ( ) . any ( |e| name == e. feature_name ( ) ) {
1997
+ // Handled in the separate loop above.
1998
+ continue ;
1975
1999
}
1976
2000
1977
2001
if let Some ( ( .., set) ) = ACTIVE_FEATURES . iter ( ) . find ( |f| name == f. 0 ) {
0 commit comments