@@ -30,7 +30,7 @@ use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax};
30
30
use attr;
31
31
use epoch:: Epoch ;
32
32
use codemap:: Spanned ;
33
- use syntax_pos:: Span ;
33
+ use syntax_pos:: { Span , DUMMY_SP } ;
34
34
use errors:: { DiagnosticBuilder , Handler , FatalError } ;
35
35
use visit:: { self , FnKind , Visitor } ;
36
36
use parse:: ParseSess ;
@@ -59,7 +59,8 @@ macro_rules! declare_features {
59
59
/// Represents active features that are currently being implemented or
60
60
/// currently being considered for addition/removal.
61
61
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 ) ) ] =
63
64
& [ $( ( stringify!( $feature) , $ver, $issue, $epoch, set!( $feature) ) ) ,+] ;
64
65
65
66
/// A set of features to be used by later passes.
@@ -408,7 +409,7 @@ declare_features! (
408
409
( active, match_default_bindings, "1.22.0" , Some ( 42640 ) , None ) ,
409
410
410
411
// 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 ) ) ,
412
413
413
414
// `crate` as visibility modifier, synonymous to `pub(crate)`
414
415
( active, crate_visibility_modifier, "1.23.0" , Some ( 45388 ) , None ) ,
@@ -1794,11 +1795,22 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
1794
1795
}
1795
1796
}
1796
1797
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 {
1798
1800
let mut features = Features :: new ( ) ;
1799
1801
1800
1802
let mut feature_checker = FeatureChecker :: default ( ) ;
1801
1803
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
+
1802
1814
for attr in krate_attrs {
1803
1815
if !attr. check_name ( "feature" ) {
1804
1816
continue
0 commit comments