@@ -1923,6 +1923,14 @@ 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 & 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+
19261934 for & ( name, .., f_edition, set) in ACTIVE_FEATURES {
19271935 if let Some ( f_edition) = f_edition {
19281936 if f_edition <= crate_edition {
@@ -1993,25 +2001,26 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
19932001 continue
19942002 } ;
19952003
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+
19962016 if ALL_EDITIONS . iter ( ) . any ( |e| name == e. feature_name ( ) ) {
19972017 // Handled in the separate loop above.
19982018 continue ;
19992019 }
20002020
20012021 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 ) ) ;
20152024 continue
20162025 }
20172026
0 commit comments