10
10
11
11
use attr;
12
12
use ast;
13
- use syntax_pos:: { mk_sp, Span } ;
14
- use codemap:: spanned;
13
+ use codemap:: respan;
15
14
use parse:: common:: SeqSep ;
16
15
use parse:: PResult ;
17
16
use parse:: token:: { self , Nonterminal } ;
@@ -49,8 +48,7 @@ impl<'a> Parser<'a> {
49
48
just_parsed_doc_comment = false ;
50
49
}
51
50
token:: DocComment ( s) => {
52
- let Span { lo, hi, .. } = self . span ;
53
- let attr = attr:: mk_sugared_doc_attr ( attr:: mk_attr_id ( ) , s, lo, hi) ;
51
+ let attr = attr:: mk_sugared_doc_attr ( attr:: mk_attr_id ( ) , s, self . span ) ;
54
52
if attr. style != ast:: AttrStyle :: Outer {
55
53
let mut err = self . fatal ( "expected outer doc comment" ) ;
56
54
err. note ( "inner doc comments like this (starting with \
@@ -94,7 +92,7 @@ impl<'a> Parser<'a> {
94
92
self . token) ;
95
93
let ( span, path, tokens, mut style) = match self . token {
96
94
token:: Pound => {
97
- let lo = self . span . lo ;
95
+ let lo = self . span ;
98
96
self . bump ( ) ;
99
97
100
98
if inner_parse_policy == InnerAttributeParsePolicy :: Permitted {
@@ -122,9 +120,9 @@ impl<'a> Parser<'a> {
122
120
self . expect ( & token:: OpenDelim ( token:: Bracket ) ) ?;
123
121
let ( path, tokens) = self . parse_path_and_tokens ( ) ?;
124
122
self . expect ( & token:: CloseDelim ( token:: Bracket ) ) ?;
125
- let hi = self . prev_span . hi ;
123
+ let hi = self . prev_span ;
126
124
127
- ( mk_sp ( lo , hi) , path, tokens, style)
125
+ ( lo . to ( hi) , path, tokens, style)
128
126
}
129
127
_ => {
130
128
let token_str = self . this_token_to_string ( ) ;
@@ -189,8 +187,7 @@ impl<'a> Parser<'a> {
189
187
}
190
188
token:: DocComment ( s) => {
191
189
// we need to get the position of this token before we bump.
192
- let Span { lo, hi, .. } = self . span ;
193
- let attr = attr:: mk_sugared_doc_attr ( attr:: mk_attr_id ( ) , s, lo, hi) ;
190
+ let attr = attr:: mk_sugared_doc_attr ( attr:: mk_attr_id ( ) , s, self . span ) ;
194
191
if attr. style == ast:: AttrStyle :: Inner {
195
192
attrs. push ( attr) ;
196
193
self . bump ( ) ;
@@ -238,11 +235,10 @@ impl<'a> Parser<'a> {
238
235
return Ok ( meta) ;
239
236
}
240
237
241
- let lo = self . span . lo ;
238
+ let lo = self . span ;
242
239
let ident = self . parse_ident ( ) ?;
243
240
let node = self . parse_meta_item_kind ( ) ?;
244
- let hi = self . prev_span . hi ;
245
- Ok ( ast:: MetaItem { name : ident. name , node : node, span : mk_sp ( lo, hi) } )
241
+ Ok ( ast:: MetaItem { name : ident. name , node : node, span : lo. to ( self . prev_span ) } )
246
242
}
247
243
248
244
pub fn parse_meta_item_kind ( & mut self ) -> PResult < ' a , ast:: MetaItemKind > {
@@ -258,26 +254,25 @@ impl<'a> Parser<'a> {
258
254
259
255
/// matches meta_item_inner : (meta_item | UNSUFFIXED_LIT) ;
260
256
fn parse_meta_item_inner ( & mut self ) -> PResult < ' a , ast:: NestedMetaItem > {
261
- let sp = self . span ;
262
- let lo = self . span . lo ;
257
+ let lo = self . span ;
263
258
264
259
match self . parse_unsuffixed_lit ( ) {
265
260
Ok ( lit) => {
266
- return Ok ( spanned ( lo, self . prev_span . hi , ast:: NestedMetaItemKind :: Literal ( lit) ) )
261
+ return Ok ( respan ( lo. to ( self . prev_span ) , ast:: NestedMetaItemKind :: Literal ( lit) ) )
267
262
}
268
263
Err ( ref mut err) => self . diagnostic ( ) . cancel ( err)
269
264
}
270
265
271
266
match self . parse_meta_item ( ) {
272
267
Ok ( mi) => {
273
- return Ok ( spanned ( lo, self . prev_span . hi , ast:: NestedMetaItemKind :: MetaItem ( mi) ) )
268
+ return Ok ( respan ( lo. to ( self . prev_span ) , ast:: NestedMetaItemKind :: MetaItem ( mi) ) )
274
269
}
275
270
Err ( ref mut err) => self . diagnostic ( ) . cancel ( err)
276
271
}
277
272
278
273
let found = self . this_token_to_string ( ) ;
279
274
let msg = format ! ( "expected unsuffixed literal or identifier, found {}" , found) ;
280
- Err ( self . diagnostic ( ) . struct_span_err ( sp , & msg) )
275
+ Err ( self . diagnostic ( ) . struct_span_err ( lo , & msg) )
281
276
}
282
277
283
278
/// matches meta_seq = ( COMMASEP(meta_item_inner) )
0 commit comments