@@ -38,9 +38,6 @@ impl<'a> ParserAttr for Parser<'a> {
38
38
attrs. push ( self . parse_attribute ( false ) ) ;
39
39
}
40
40
token:: POUND => {
41
- if self . look_ahead ( 1 , |t| * t != token:: LBRACKET ) {
42
- break ;
43
- }
44
41
attrs. push ( self . parse_attribute ( false ) ) ;
45
42
}
46
43
token:: DOC_COMMENT ( s) => {
@@ -61,40 +58,55 @@ impl<'a> ParserAttr for Parser<'a> {
61
58
return attrs;
62
59
}
63
60
64
- // matches attribute = # [ meta_item ]
61
+ // matches attribute = # ! [ meta_item ]
65
62
//
66
- // if permit_inner is true, then a trailing `; ` indicates an inner
63
+ // if permit_inner is true, then a leading `! ` indicates an inner
67
64
// attribute
68
65
fn parse_attribute ( & mut self , permit_inner : bool ) -> ast:: Attribute {
69
66
debug ! ( "parse_attributes: permit_inner={:?} self.token={:?}" ,
70
67
permit_inner, self . token) ;
71
- let ( span, value) = match self . token {
68
+ let ( span, value, mut style ) = match self . token {
72
69
INTERPOLATED ( token:: NtAttr ( attr) ) => {
73
70
assert ! ( attr. node. style == ast:: AttrOuter ) ;
74
71
self . bump ( ) ;
75
- ( attr. span , attr. node . value )
72
+ ( attr. span , attr. node . value , ast :: AttrOuter )
76
73
}
77
74
token:: POUND => {
78
75
let lo = self . span . lo ;
79
76
self . bump ( ) ;
77
+
78
+ let style = if self . eat ( & token:: NOT ) {
79
+ if !permit_inner {
80
+ self . span_err ( self . span ,
81
+ "an inner attribute is not permitted in \
82
+ this context") ;
83
+ }
84
+ ast:: AttrInner
85
+ } else {
86
+ ast:: AttrOuter
87
+ } ;
88
+
80
89
self . expect ( & token:: LBRACKET ) ;
81
90
let meta_item = self . parse_meta_item ( ) ;
82
91
self . expect ( & token:: RBRACKET ) ;
92
+
83
93
let hi = self . span . hi ;
84
- ( mk_sp ( lo, hi) , meta_item)
94
+ ( mk_sp ( lo, hi) , meta_item, style )
85
95
}
86
96
_ => {
87
97
let token_str = self . this_token_to_str ( ) ;
88
98
self . fatal ( format ! ( "expected `\\ #` but found `{}`" ,
89
99
token_str) ) ;
90
100
}
91
101
} ;
92
- let style = if permit_inner && self . token == token:: SEMI {
93
- self . bump ( ) ;
94
- ast:: AttrInner
95
- } else {
96
- ast:: AttrOuter
97
- } ;
102
+
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
+ }
109
+
98
110
return Spanned {
99
111
span : span,
100
112
node : ast:: Attribute_ {
@@ -125,10 +137,6 @@ impl<'a> ParserAttr for Parser<'a> {
125
137
self . parse_attribute ( true )
126
138
}
127
139
token:: POUND => {
128
- if self . look_ahead ( 1 , |t| * t != token:: LBRACKET ) {
129
- // This is an extension
130
- break ;
131
- }
132
140
self . parse_attribute ( true )
133
141
}
134
142
token:: DOC_COMMENT ( s) => {
0 commit comments