@@ -213,6 +213,7 @@ impl<'a> Parser<'a> {
213
213
214
214
let start_token = ( self . token . clone ( ) , self . token_spacing ) ;
215
215
let cursor_snapshot = self . token_cursor . clone ( ) ;
216
+ let start_pos = self . num_bump_calls ;
216
217
217
218
let has_outer_attrs = !attrs. attrs . is_empty ( ) ;
218
219
let prev_capturing = std:: mem:: replace ( & mut self . capture_state . capturing , Capturing :: Yes ) ;
@@ -273,8 +274,7 @@ impl<'a> Parser<'a> {
273
274
274
275
let replace_ranges_end = self . capture_state . replace_ranges . len ( ) ;
275
276
276
- let cursor_snapshot_next_calls = cursor_snapshot. num_next_calls ;
277
- let mut end_pos = self . token_cursor . num_next_calls ;
277
+ let mut end_pos = self . num_bump_calls ;
278
278
279
279
let mut captured_trailing = false ;
280
280
@@ -301,12 +301,12 @@ impl<'a> Parser<'a> {
301
301
// then extend the range of captured tokens to include it, since the parser
302
302
// was not actually bumped past it. When the `LazyAttrTokenStream` gets converted
303
303
// into an `AttrTokenStream`, we will create the proper token.
304
- if self . token_cursor . break_last_token {
304
+ if self . break_last_token {
305
305
assert ! ( !captured_trailing, "Cannot set break_last_token and have trailing token" ) ;
306
306
end_pos += 1 ;
307
307
}
308
308
309
- let num_calls = end_pos - cursor_snapshot_next_calls ;
309
+ let num_calls = end_pos - start_pos ;
310
310
311
311
// If we have no attributes, then we will never need to
312
312
// use any replace ranges.
@@ -316,7 +316,7 @@ impl<'a> Parser<'a> {
316
316
// Grab any replace ranges that occur *inside* the current AST node.
317
317
// We will perform the actual replacement when we convert the `LazyAttrTokenStream`
318
318
// to an `AttrTokenStream`.
319
- let start_calls: u32 = cursor_snapshot_next_calls . try_into ( ) . unwrap ( ) ;
319
+ let start_calls: u32 = start_pos . try_into ( ) . unwrap ( ) ;
320
320
self . capture_state . replace_ranges [ replace_ranges_start..replace_ranges_end]
321
321
. iter ( )
322
322
. cloned ( )
@@ -331,7 +331,7 @@ impl<'a> Parser<'a> {
331
331
start_token,
332
332
num_calls,
333
333
cursor_snapshot,
334
- break_last_token : self . token_cursor . break_last_token ,
334
+ break_last_token : self . break_last_token ,
335
335
replace_ranges,
336
336
} ) ;
337
337
@@ -359,14 +359,10 @@ impl<'a> Parser<'a> {
359
359
// with a `FlatToken::AttrTarget`. If this AST node is inside an item
360
360
// that has `#[derive]`, then this will allow us to cfg-expand this
361
361
// AST node.
362
- let start_pos =
363
- if has_outer_attrs { attrs. start_pos } else { cursor_snapshot_next_calls } ;
362
+ let start_pos = if has_outer_attrs { attrs. start_pos } else { start_pos } ;
364
363
let new_tokens = vec ! [ ( FlatToken :: AttrTarget ( attr_data) , Spacing :: Alone ) ] ;
365
364
366
- assert ! (
367
- !self . token_cursor. break_last_token,
368
- "Should not have unglued last token with cfg attr"
369
- ) ;
365
+ assert ! ( !self . break_last_token, "Should not have unglued last token with cfg attr" ) ;
370
366
let range: Range < u32 > = ( start_pos. try_into ( ) . unwrap ( ) ) ..( end_pos. try_into ( ) . unwrap ( ) ) ;
371
367
self . capture_state . replace_ranges . push ( ( range, new_tokens) ) ;
372
368
self . capture_state . replace_ranges . extend ( inner_attr_replace_ranges) ;
@@ -464,6 +460,6 @@ mod size_asserts {
464
460
use rustc_data_structures:: static_assert_size;
465
461
// tidy-alphabetical-start
466
462
static_assert_size ! ( AttrWrapper , 16 ) ;
467
- static_assert_size ! ( LazyAttrTokenStreamImpl , 120 ) ;
463
+ static_assert_size ! ( LazyAttrTokenStreamImpl , 104 ) ;
468
464
// tidy-alphabetical-end
469
465
}
0 commit comments