@@ -38,9 +38,6 @@ impl<'a> ParserAttr for Parser<'a> {
3838 attrs. push ( self . parse_attribute ( false ) ) ;
3939 }
4040 token:: POUND => {
41- if self . look_ahead ( 1 , |t| * t != token:: LBRACKET ) {
42- break ;
43- }
4441 attrs. push ( self . parse_attribute ( false ) ) ;
4542 }
4643 token:: DOC_COMMENT ( s) => {
@@ -68,6 +65,7 @@ impl<'a> ParserAttr for Parser<'a> {
6865 fn parse_attribute ( & mut self , permit_inner : bool ) -> ast:: Attribute {
6966 debug ! ( "parse_attributes: permit_inner={:?} self.token={:?}" ,
7067 permit_inner, self . token) ;
68+ let mut warned = false ;
7169 let ( span, value) = match self . token {
7270 INTERPOLATED ( token:: NtAttr ( attr) ) => {
7371 assert ! ( attr. node. style == ast:: AttrOuter ) ;
@@ -77,9 +75,22 @@ impl<'a> ParserAttr for Parser<'a> {
7775 token:: POUND => {
7876 let lo = self . span . lo ;
7977 self . bump ( ) ;
78+
79+ if self . eat ( & token:: NOT ) {
80+ if !permit_inner {
81+ self . fatal ( "an inner attribute was not permitted in this context." ) ;
82+ }
83+ } 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+ }
89+
8090 self . expect ( & token:: LBRACKET ) ;
8191 let meta_item = self . parse_meta_item ( ) ;
8292 self . expect ( & token:: RBRACKET ) ;
93+
8394 let hi = self . span . hi ;
8495 ( mk_sp ( lo, hi) , meta_item)
8596 }
@@ -89,12 +100,23 @@ impl<'a> ParserAttr for Parser<'a> {
89100 token_str) ) ;
90101 }
91102 } ;
92- let style = if permit_inner && self . token == token:: SEMI {
93- self . bump ( ) ;
103+
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+
94115 ast:: AttrInner
95116 } else {
96117 ast:: AttrOuter
97118 } ;
119+
98120 return Spanned {
99121 span : span,
100122 node : ast:: Attribute_ {
@@ -125,10 +147,6 @@ impl<'a> ParserAttr for Parser<'a> {
125147 self . parse_attribute ( true )
126148 }
127149 token:: POUND => {
128- if self . look_ahead ( 1 , |t| * t != token:: LBRACKET ) {
129- // This is an extension
130- break ;
131- }
132150 self . parse_attribute ( true )
133151 }
134152 token:: DOC_COMMENT ( s) => {
0 commit comments