@@ -58,41 +58,40 @@ impl<'a> ParserAttr for Parser<'a> {
58
58
return attrs;
59
59
}
60
60
61
- // matches attribute = # [ meta_item ]
61
+ // matches attribute = # ! [ meta_item ]
62
62
//
63
- // if permit_inner is true, then a trailing `; ` indicates an inner
63
+ // if permit_inner is true, then a leading `! ` indicates an inner
64
64
// attribute
65
65
fn parse_attribute ( & mut self , permit_inner : bool ) -> ast:: Attribute {
66
66
debug ! ( "parse_attributes: permit_inner={:?} self.token={:?}" ,
67
67
permit_inner, self . token) ;
68
- let mut warned = false ;
69
- let ( span, value) = match self . token {
68
+ let ( span, value, mut style) = match self . token {
70
69
INTERPOLATED ( token:: NtAttr ( attr) ) => {
71
70
assert ! ( attr. node. style == ast:: AttrOuter ) ;
72
71
self . bump ( ) ;
73
- ( attr. span , attr. node . value )
72
+ ( attr. span , attr. node . value , ast :: AttrOuter )
74
73
}
75
74
token:: POUND => {
76
75
let lo = self . span . lo ;
77
76
self . bump ( ) ;
78
77
79
- if self . eat ( & token:: NOT ) {
78
+ let style = if self . eat ( & token:: NOT ) {
80
79
if !permit_inner {
81
- self . fatal ( "an inner attribute was not permitted in this context." ) ;
80
+ self . span_err ( self . span ,
81
+ "an inner attribute is not permitted in \
82
+ this context") ;
82
83
}
84
+ ast:: AttrInner
83
85
} else {
84
- warned = true ;
85
- // NOTE: uncomment this after a stage0 snap
86
- //self.warn("The syntax for inner attributes have changed.
87
- // Use `#![lang(foo)]` instead.");
88
- }
86
+ ast:: AttrOuter
87
+ } ;
89
88
90
89
self . expect ( & token:: LBRACKET ) ;
91
90
let meta_item = self . parse_meta_item ( ) ;
92
91
self . expect ( & token:: RBRACKET ) ;
93
92
94
93
let hi = self . span . hi ;
95
- ( mk_sp ( lo, hi) , meta_item)
94
+ ( mk_sp ( lo, hi) , meta_item, style )
96
95
}
97
96
_ => {
98
97
let token_str = self . this_token_to_str ( ) ;
@@ -101,21 +100,12 @@ impl<'a> ParserAttr for Parser<'a> {
101
100
}
102
101
} ;
103
102
104
- let style = if permit_inner {
105
-
106
- if self . eat ( & token:: SEMI ) {
107
- // Only warn the user once if the syntax is the old one.
108
- if !warned {
109
- // NOTE: uncomment this after a stage0 snap
110
- //self.warn("This uses the old attribute syntax. Semicolons
111
- // are not longer required.");
112
- }
113
- }
114
-
115
- ast:: AttrInner
116
- } else {
117
- ast:: AttrOuter
118
- } ;
103
+ if permit_inner && self . eat ( & token:: SEMI ) {
104
+ // NOTE: uncomment this after a stage0 snap
105
+ //self.warn("This uses the old attribute syntax. Semicolons
106
+ // are not longer required.");
107
+ style = ast:: AttrInner ;
108
+ }
119
109
120
110
return Spanned {
121
111
span : span,
0 commit comments