1
1
use super :: { active:: { ACTIVE_FEATURES , Features } , Feature , State as FeatureState } ;
2
2
use super :: accepted:: ACCEPTED_FEATURES ;
3
3
use super :: removed:: { REMOVED_FEATURES , STABLE_REMOVED_FEATURES } ;
4
- use super :: builtin_attrs:: { AttributeGate , AttributeType , BuiltinAttribute , BUILTIN_ATTRIBUTE_MAP } ;
4
+ use super :: builtin_attrs:: { AttributeGate , BuiltinAttribute , BUILTIN_ATTRIBUTE_MAP } ;
5
5
6
6
use crate :: ast:: {
7
7
self , AssocTyConstraint , AssocTyConstraintKind , NodeId , GenericParam , GenericParamKind ,
@@ -33,9 +33,8 @@ pub enum Stability {
33
33
}
34
34
35
35
struct Context < ' a > {
36
- features : & ' a Features ,
37
36
parse_sess : & ' a ParseSess ,
38
- plugin_attributes : & ' a [ ( Symbol , AttributeType ) ] ,
37
+ features : & ' a Features ,
39
38
}
40
39
41
40
macro_rules! gate_feature_fn {
@@ -67,7 +66,6 @@ impl<'a> Context<'a> {
67
66
& self ,
68
67
attr : & ast:: Attribute ,
69
68
attr_info : Option < & BuiltinAttribute > ,
70
- is_macro : bool
71
69
) {
72
70
debug ! ( "check_attribute(attr = {:?})" , attr) ;
73
71
if let Some ( & ( name, ty, _template, ref gateage) ) = attr_info {
@@ -87,42 +85,15 @@ impl<'a> Context<'a> {
87
85
}
88
86
}
89
87
debug ! ( "check_attribute: {:?} is builtin, {:?}, {:?}" , attr. path, ty, gateage) ;
90
- return ;
91
- } else {
92
- for segment in & attr. path . segments {
93
- if segment. ident . as_str ( ) . starts_with ( "rustc" ) {
94
- let msg = "attributes starting with `rustc` are \
95
- reserved for use by the `rustc` compiler";
96
- gate_feature ! ( self , rustc_attrs, segment. ident. span, msg) ;
97
- }
98
- }
99
- }
100
- for & ( n, ty) in self . plugin_attributes {
101
- if attr. path == n {
102
- // Plugins can't gate attributes, so we don't check for it
103
- // unlike the code above; we only use this loop to
104
- // short-circuit to avoid the checks below.
105
- debug ! ( "check_attribute: {:?} is registered by a plugin, {:?}" , attr. path, ty) ;
106
- return ;
107
- }
108
- }
109
- if !is_macro && !attr:: is_known ( attr) {
110
- // Only run the custom attribute lint during regular feature gate
111
- // checking. Macro gating runs before the plugin attributes are
112
- // registered, so we skip this in that case.
113
- let msg = format ! ( "the attribute `{}` is currently unknown to the compiler and \
114
- may have meaning added to it in the future", attr. path) ;
115
- gate_feature ! ( self , custom_attribute, attr. span, & msg) ;
116
88
}
117
89
}
118
90
}
119
91
120
92
pub fn check_attribute ( attr : & ast:: Attribute , parse_sess : & ParseSess , features : & Features ) {
121
- let cx = Context { features , parse_sess, plugin_attributes : & [ ] } ;
93
+ let cx = Context { parse_sess, features } ;
122
94
cx. check_attribute (
123
95
attr,
124
96
attr. ident ( ) . and_then ( |ident| BUILTIN_ATTRIBUTE_MAP . get ( & ident. name ) . map ( |a| * a) ) ,
125
- true
126
97
) ;
127
98
}
128
99
@@ -321,7 +292,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
321
292
} ) ;
322
293
323
294
// Check for gated attributes.
324
- self . context . check_attribute ( attr, attr_info, false ) ;
295
+ self . context . check_attribute ( attr, attr_info) ;
325
296
326
297
if attr. check_name ( sym:: doc) {
327
298
if let Some ( content) = attr. meta_item_list ( ) {
@@ -872,21 +843,16 @@ fn active_features_up_to(edition: Edition) -> impl Iterator<Item=&'static Featur
872
843
}
873
844
874
845
pub fn check_crate ( krate : & ast:: Crate ,
875
- sess : & ParseSess ,
846
+ parse_sess : & ParseSess ,
876
847
features : & Features ,
877
- plugin_attributes : & [ ( Symbol , AttributeType ) ] ,
878
848
unstable : UnstableFeatures ) {
879
- maybe_stage_features ( & sess. span_diagnostic , krate, unstable) ;
880
- let ctx = Context {
881
- features,
882
- parse_sess : sess,
883
- plugin_attributes,
884
- } ;
849
+ maybe_stage_features ( & parse_sess. span_diagnostic , krate, unstable) ;
850
+ let ctx = Context { parse_sess, features } ;
885
851
886
852
macro_rules! gate_all {
887
853
( $gate: ident, $msg: literal) => { gate_all!( $gate, $gate, $msg) ; } ;
888
854
( $spans: ident, $gate: ident, $msg: literal) => {
889
- for span in & * sess . gated_spans. $spans. borrow( ) {
855
+ for span in & * parse_sess . gated_spans. $spans. borrow( ) {
890
856
gate_feature!( & ctx, $gate, * span, $msg) ;
891
857
}
892
858
}
0 commit comments