@@ -1874,16 +1874,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
1874
1874
}
1875
1875
}
1876
1876
1877
- pub fn get_features ( span_handler : & Handler , krate_attrs : & [ ast:: Attribute ] ,
1877
+ pub fn get_features ( span_handler : & Handler , krate_attrs : & [ ast:: Attribute ] , z_features : & [ String ] ,
1878
1878
crate_edition : Edition ) -> Features {
1879
- fn feature_removed ( span_handler : & Handler , span : Span , reason : Option < & str > ) {
1880
- let mut err = struct_span_err ! ( span_handler, span, E0557 , "feature has been removed" ) ;
1881
- if let Some ( reason) = reason {
1882
- err. span_note ( span, reason) ;
1883
- }
1884
- err. emit ( ) ;
1885
- }
1886
-
1887
1879
let mut features = Features :: new ( ) ;
1888
1880
1889
1881
let mut feature_checker = FeatureChecker :: default ( ) ;
@@ -1919,49 +1911,76 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
1919
1911
continue
1920
1912
} ;
1921
1913
1922
- if let Some ( ( .., set) ) = ACTIVE_FEATURES . iter ( ) . find ( |f| name == f. 0 ) {
1923
- set ( & mut features, mi. span ) ;
1924
- feature_checker. collect ( & features, mi. span ) ;
1925
- continue
1926
- }
1927
-
1928
- let removed = REMOVED_FEATURES . iter ( ) . find ( |f| name == f. 0 ) ;
1929
- let stable_removed = STABLE_REMOVED_FEATURES . iter ( ) . find ( |f| name == f. 0 ) ;
1930
- if let Some ( ( .., reason) ) = removed. or ( stable_removed) {
1931
- feature_removed ( span_handler, mi. span , * reason) ;
1932
- continue
1933
- }
1914
+ set_feature (
1915
+ name,
1916
+ mi. span ,
1917
+ span_handler,
1918
+ & mut features,
1919
+ & mut feature_checker,
1920
+ crate_edition,
1921
+ ) ;
1922
+ }
1923
+ }
1934
1924
1935
- if ACCEPTED_FEATURES . iter ( ) . any ( |f| name == f. 0 ) {
1936
- features. declared_stable_lang_features . push ( ( name, mi. span ) ) ;
1937
- continue
1938
- }
1925
+ for z_feature in z_features {
1926
+ set_feature (
1927
+ Symbol :: intern ( & z_feature) ,
1928
+ DUMMY_SP ,
1929
+ span_handler,
1930
+ & mut features,
1931
+ & mut feature_checker,
1932
+ crate_edition,
1933
+ ) ;
1934
+ }
1939
1935
1940
- if let Some ( edition) = ALL_EDITIONS . iter ( ) . find ( |e| name == e. feature_name ( ) ) {
1941
- if * edition <= crate_edition {
1942
- continue
1943
- }
1936
+ feature_checker. check ( span_handler) ;
1944
1937
1945
- for & ( .., f_edition, set) in ACTIVE_FEATURES . iter ( ) {
1946
- if let Some ( f_edition) = f_edition {
1947
- if * edition >= f_edition {
1948
- // FIXME(Manishearth) there is currently no way to set
1949
- // lib features by edition
1950
- set ( & mut features, DUMMY_SP ) ;
1951
- }
1952
- }
1953
- }
1938
+ features
1939
+ }
1954
1940
1955
- continue
1956
- }
1941
+ fn set_feature ( name : Symbol , span : Span , span_handler : & Handler , features : & mut Features ,
1942
+ feature_checker : & mut FeatureChecker , crate_edition : Edition ) {
1943
+ if let Some ( ( .., set) ) = ACTIVE_FEATURES . iter ( ) . find ( |f| name == f. 0 ) {
1944
+ set ( features, span) ;
1945
+ feature_checker. collect ( & features, span) ;
1946
+ return ;
1947
+ }
1957
1948
1958
- features. declared_lib_features . push ( ( name, mi. span ) ) ;
1949
+ let removed = REMOVED_FEATURES . iter ( ) . find ( |f| name == f. 0 ) ;
1950
+ let stable_removed = STABLE_REMOVED_FEATURES . iter ( ) . find ( |f| name == f. 0 ) ;
1951
+ if let Some ( ( .., reason) ) = removed. or ( stable_removed) {
1952
+ let mut err = struct_span_err ! ( span_handler, span, E0557 , "feature has been removed" ) ;
1953
+ if let Some ( reason) = reason {
1954
+ err. span_note ( span, reason) ;
1959
1955
}
1956
+ err. emit ( ) ;
1957
+ return ;
1960
1958
}
1961
1959
1962
- feature_checker. check ( span_handler) ;
1960
+ if ACCEPTED_FEATURES . iter ( ) . any ( |f| name == f. 0 ) {
1961
+ features. declared_stable_lang_features . push ( ( name, span) ) ;
1962
+ return ;
1963
+ }
1963
1964
1964
- features
1965
+ if let Some ( edition) = ALL_EDITIONS . iter ( ) . find ( |e| name == e. feature_name ( ) ) {
1966
+ if * edition <= crate_edition {
1967
+ return ;
1968
+ }
1969
+
1970
+ for & ( .., f_edition, set) in ACTIVE_FEATURES . iter ( ) {
1971
+ if let Some ( f_edition) = f_edition {
1972
+ if * edition >= f_edition {
1973
+ // FIXME(Manishearth) there is currently no way to set
1974
+ // lib features by edition
1975
+ set ( features, DUMMY_SP ) ;
1976
+ }
1977
+ }
1978
+ }
1979
+
1980
+ return ;
1981
+ }
1982
+
1983
+ features. declared_lib_features . push ( ( name, span) ) ;
1965
1984
}
1966
1985
1967
1986
/// A collector for mutually exclusive and interdependent features and their flag spans.
0 commit comments