@@ -1923,6 +1923,14 @@ 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 & edition in ALL_EDITIONS {
1927
+ if edition <= crate_edition {
1928
+ // The `crate_edition` implies its respective umbrella feature-gate
1929
+ // (i.e. `#![feature(rust_20XX_preview)]` isn't needed on edition 20XX).
1930
+ edition_enabled_features. insert ( Symbol :: intern ( edition. feature_name ( ) ) , edition) ;
1931
+ }
1932
+ }
1933
+
1926
1934
for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
1927
1935
if let Some ( f_edition) = f_edition {
1928
1936
if f_edition <= crate_edition {
@@ -1993,25 +2001,26 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
1993
2001
continue
1994
2002
} ;
1995
2003
2004
+ if let Some ( edition) = edition_enabled_features. get ( & name) {
2005
+ struct_span_warn ! (
2006
+ span_handler,
2007
+ mi. span,
2008
+ E0705 ,
2009
+ "the feature `{}` is included in the Rust {} edition" ,
2010
+ name,
2011
+ edition,
2012
+ ) . emit ( ) ;
2013
+ continue ;
2014
+ }
2015
+
1996
2016
if ALL_EDITIONS . iter ( ) . any ( |e| name == e. feature_name ( ) ) {
1997
2017
// Handled in the separate loop above.
1998
2018
continue ;
1999
2019
}
2000
2020
2001
2021
if let Some ( ( .., set) ) = ACTIVE_FEATURES . iter ( ) . find ( |f| name == f. 0 ) {
2002
- if let Some ( edition) = edition_enabled_features. get ( & name) {
2003
- struct_span_warn ! (
2004
- span_handler,
2005
- mi. span,
2006
- E0705 ,
2007
- "the feature `{}` is included in the Rust {} edition" ,
2008
- name,
2009
- edition,
2010
- ) . emit ( ) ;
2011
- } else {
2012
- set ( & mut features, mi. span ) ;
2013
- features. declared_lang_features . push ( ( name, mi. span , None ) ) ;
2014
- }
2022
+ set ( & mut features, mi. span ) ;
2023
+ features. declared_lang_features . push ( ( name, mi. span , None ) ) ;
2015
2024
continue
2016
2025
}
2017
2026
0 commit comments