@@ -30,7 +30,7 @@ use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax};
3030use attr;
3131use epoch:: Epoch ;
3232use codemap:: Spanned ;
33- use syntax_pos:: Span ;
33+ use syntax_pos:: { Span , DUMMY_SP } ;
3434use errors:: { DiagnosticBuilder , Handler , FatalError } ;
3535use visit:: { self , FnKind , Visitor } ;
3636use parse:: ParseSess ;
@@ -59,7 +59,8 @@ macro_rules! declare_features {
5959 /// Represents active features that are currently being implemented or
6060 /// currently being considered for addition/removal.
6161 const ACTIVE_FEATURES :
62- & ' static [ ( & ' static str , & ' static str , Option <u32 >, Option <Epoch >, fn ( & mut Features , Span ) ) ] =
62+ & ' static [ ( & ' static str , & ' static str , Option <u32 >,
63+ Option <Epoch >, fn ( & mut Features , Span ) ) ] =
6364 & [ $( ( stringify!( $feature) , $ver, $issue, $epoch, set!( $feature) ) ) ,+] ;
6465
6566 /// A set of features to be used by later passes.
@@ -408,7 +409,7 @@ declare_features! (
408409 ( active, match_default_bindings, "1.22.0" , Some ( 42640 ) , None ) ,
409410
410411 // Trait object syntax with `dyn` prefix
411- ( active, dyn_trait, "1.22.0" , Some ( 44662 ) , None ) ,
412+ ( active, dyn_trait, "1.22.0" , Some ( 44662 ) , Some ( Epoch :: Epoch2018 ) ) ,
412413
413414 // `crate` as visibility modifier, synonymous to `pub(crate)`
414415 ( active, crate_visibility_modifier, "1.23.0" , Some ( 45388 ) , None ) ,
@@ -1794,11 +1795,22 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
17941795 }
17951796}
17961797
1797- pub fn get_features ( span_handler : & Handler , krate_attrs : & [ ast:: Attribute ] ) -> Features {
1798+ pub fn get_features ( span_handler : & Handler , krate_attrs : & [ ast:: Attribute ] ,
1799+ epoch : Epoch ) -> Features {
17981800 let mut features = Features :: new ( ) ;
17991801
18001802 let mut feature_checker = FeatureChecker :: default ( ) ;
18011803
1804+ for & ( .., f_epoch, set) in ACTIVE_FEATURES . iter ( ) {
1805+ if let Some ( f_epoch) = f_epoch {
1806+ if epoch >= f_epoch {
1807+ // FIXME(Manishearth) there is currently no way to set
1808+ // lang features by epoch
1809+ set ( & mut features, DUMMY_SP ) ;
1810+ }
1811+ }
1812+ }
1813+
18021814 for attr in krate_attrs {
18031815 if !attr. check_name ( "feature" ) {
18041816 continue
0 commit comments