@@ -22,26 +22,25 @@ impl<'a> Parser<'a> {
22
22
pub fn parse_outer_attributes ( & mut self ) -> PResult < ' a , Vec < ast:: Attribute > > {
23
23
let mut attrs: Vec < ast:: Attribute > = Vec :: new ( ) ;
24
24
loop {
25
- debug ! ( "parse_outer_attributes: self.token={:?}" ,
26
- self . token) ;
25
+ debug ! ( "parse_outer_attributes: self.token={:?}" , self . token) ;
27
26
match self . token {
28
- token:: Pound => {
29
- attrs. push ( try!( self . parse_attribute ( false ) ) ) ;
30
- }
31
- token:: DocComment ( s) => {
32
- let attr = :: attr:: mk_sugared_doc_attr (
27
+ token:: Pound => {
28
+ attrs. push ( try!( self . parse_attribute ( false ) ) ) ;
29
+ }
30
+ token:: DocComment ( s) => {
31
+ let attr = :: attr:: mk_sugared_doc_attr (
33
32
attr:: mk_attr_id ( ) ,
34
33
self . id_to_interned_str ( ast:: Ident :: with_empty_ctxt ( s) ) ,
35
34
self . span . lo ,
36
35
self . span . hi
37
36
) ;
38
- if attr. node . style != ast:: AttrStyle :: Outer {
39
- return Err ( self . fatal ( "expected outer comment" ) ) ;
37
+ if attr. node . style != ast:: AttrStyle :: Outer {
38
+ return Err ( self . fatal ( "expected outer comment" ) ) ;
39
+ }
40
+ attrs. push ( attr) ;
41
+ self . bump ( ) ;
40
42
}
41
- attrs. push ( attr) ;
42
- self . bump ( ) ;
43
- }
44
- _ => break
43
+ _ => break ,
45
44
}
46
45
}
47
46
return Ok ( attrs) ;
@@ -53,24 +52,27 @@ impl<'a> Parser<'a> {
53
52
/// attribute
54
53
pub fn parse_attribute ( & mut self , permit_inner : bool ) -> PResult < ' a , ast:: Attribute > {
55
54
debug ! ( "parse_attributes: permit_inner={:?} self.token={:?}" ,
56
- permit_inner, self . token) ;
55
+ permit_inner,
56
+ self . token) ;
57
57
let ( span, value, mut style) = match self . token {
58
58
token:: Pound => {
59
59
let lo = self . span . lo ;
60
60
self . bump ( ) ;
61
61
62
- if permit_inner { self . expected_tokens . push ( TokenType :: Token ( token:: Not ) ) ; }
62
+ if permit_inner {
63
+ self . expected_tokens . push ( TokenType :: Token ( token:: Not ) ) ;
64
+ }
63
65
let style = if self . token == token:: Not {
64
66
self . bump ( ) ;
65
67
if !permit_inner {
66
68
let span = self . span ;
67
- self . diagnostic ( ) . struct_span_err ( span ,
68
- "an inner attribute is not permitted in \
69
- this context")
70
- . fileline_help ( span,
71
- "place inner attribute at the top of \
72
- the module or block")
73
- . emit ( )
69
+ self . diagnostic ( )
70
+ . struct_span_err ( span ,
71
+ "an inner attribute is not permitted in this context")
72
+ . fileline_help ( span,
73
+ "place inner attribute at the top of the module or \
74
+ block")
75
+ . emit ( )
74
76
}
75
77
ast:: AttrStyle :: Inner
76
78
} else {
@@ -92,8 +94,9 @@ impl<'a> Parser<'a> {
92
94
93
95
if permit_inner && self . token == token:: Semi {
94
96
self . bump ( ) ;
95
- self . span_warn ( span, "this inner attribute syntax is deprecated. \
96
- The new syntax is `#![foo]`, with a bang and no semicolon") ;
97
+ self . span_warn ( span,
98
+ "this inner attribute syntax is deprecated. The new syntax is \
99
+ `#![foo]`, with a bang and no semicolon") ;
97
100
style = ast:: AttrStyle :: Inner ;
98
101
}
99
102
@@ -103,8 +106,8 @@ impl<'a> Parser<'a> {
103
106
id : attr:: mk_attr_id ( ) ,
104
107
style : style,
105
108
value : value,
106
- is_sugared_doc : false
107
- }
109
+ is_sugared_doc : false ,
110
+ } ,
108
111
} )
109
112
}
110
113
@@ -139,7 +142,7 @@ impl<'a> Parser<'a> {
139
142
break ;
140
143
}
141
144
}
142
- _ => break
145
+ _ => break ,
143
146
}
144
147
}
145
148
Ok ( attrs)
@@ -150,10 +153,8 @@ impl<'a> Parser<'a> {
150
153
/// | IDENT meta_seq
151
154
pub fn parse_meta_item ( & mut self ) -> PResult < ' a , P < ast:: MetaItem > > {
152
155
let nt_meta = match self . token {
153
- token:: Interpolated ( token:: NtMeta ( ref e) ) => {
154
- Some ( e. clone ( ) )
155
- }
156
- _ => None
156
+ token:: Interpolated ( token:: NtMeta ( ref e) ) => Some ( e. clone ( ) ) ,
157
+ _ => None ,
157
158
} ;
158
159
159
160
match nt_meta {
@@ -176,9 +177,8 @@ impl<'a> Parser<'a> {
176
177
match lit. node {
177
178
ast:: LitStr ( ..) => { }
178
179
_ => {
179
- self . span_err (
180
- lit. span ,
181
- "non-string literals are not allowed in meta-items" ) ;
180
+ self . span_err ( lit. span ,
181
+ "non-string literals are not allowed in meta-items" ) ;
182
182
}
183
183
}
184
184
let hi = self . span . hi ;
0 commit comments