@@ -29,15 +29,15 @@ pub struct AttrWrapper {
29
29
// The start of the outer attributes in the token cursor.
30
30
// This allows us to create a `ReplaceRange` for the entire attribute
31
31
// target, including outer attributes.
32
- start_pos : usize ,
32
+ start_pos : u32 ,
33
33
}
34
34
35
35
impl AttrWrapper {
36
- pub ( super ) fn new ( attrs : AttrVec , start_pos : usize ) -> AttrWrapper {
36
+ pub ( super ) fn new ( attrs : AttrVec , start_pos : u32 ) -> AttrWrapper {
37
37
AttrWrapper { attrs, start_pos }
38
38
}
39
39
pub fn empty ( ) -> AttrWrapper {
40
- AttrWrapper { attrs : AttrVec :: new ( ) , start_pos : usize :: MAX }
40
+ AttrWrapper { attrs : AttrVec :: new ( ) , start_pos : u32 :: MAX }
41
41
}
42
42
43
43
pub ( crate ) fn take_for_recovery ( self , psess : & ParseSess ) -> AttrVec {
@@ -91,7 +91,7 @@ fn has_cfg_or_cfg_attr(attrs: &[Attribute]) -> bool {
91
91
struct LazyAttrTokenStreamImpl {
92
92
start_token : ( Token , Spacing ) ,
93
93
cursor_snapshot : TokenCursor ,
94
- num_calls : usize ,
94
+ num_calls : u32 ,
95
95
break_last_token : bool ,
96
96
replace_ranges : Box < [ ReplaceRange ] > ,
97
97
}
@@ -110,7 +110,7 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
110
110
let token = cursor_snapshot. next ( ) ;
111
111
( FlatToken :: Token ( token. 0 ) , token. 1 )
112
112
} ) )
113
- . take ( self . num_calls ) ;
113
+ . take ( self . num_calls as usize ) ;
114
114
115
115
if self . replace_ranges . is_empty ( ) {
116
116
make_token_stream ( tokens, self . break_last_token )
@@ -296,12 +296,12 @@ impl<'a> Parser<'a> {
296
296
) ;
297
297
298
298
let end_pos = self . num_bump_calls
299
- + captured_trailing as usize
299
+ + captured_trailing as u32
300
300
// If we 'broke' the last token (e.g. breaking a '>>' token to two '>' tokens), then
301
301
// extend the range of captured tokens to include it, since the parser was not actually
302
302
// bumped past it. When the `LazyAttrTokenStream` gets converted into an
303
303
// `AttrTokenStream`, we will create the proper token.
304
- + self . break_last_token as usize ;
304
+ + self . break_last_token as u32 ;
305
305
306
306
let num_calls = end_pos - start_pos;
307
307
@@ -313,14 +313,11 @@ impl<'a> Parser<'a> {
313
313
// Grab any replace ranges that occur *inside* the current AST node.
314
314
// We will perform the actual replacement when we convert the `LazyAttrTokenStream`
315
315
// to an `AttrTokenStream`.
316
- let start_calls: u32 = start_pos. try_into ( ) . unwrap ( ) ;
317
316
self . capture_state . replace_ranges [ replace_ranges_start..replace_ranges_end]
318
317
. iter ( )
319
318
. cloned ( )
320
319
. chain ( inner_attr_replace_ranges. iter ( ) . cloned ( ) )
321
- . map ( |( range, tokens) | {
322
- ( ( range. start - start_calls) ..( range. end - start_calls) , tokens)
323
- } )
320
+ . map ( |( range, tokens) | ( ( range. start - start_pos) ..( range. end - start_pos) , tokens) )
324
321
. collect ( )
325
322
} ;
326
323
@@ -459,6 +456,6 @@ mod size_asserts {
459
456
use rustc_data_structures:: static_assert_size;
460
457
// tidy-alphabetical-start
461
458
static_assert_size ! ( AttrWrapper , 16 ) ;
462
- static_assert_size ! ( LazyAttrTokenStreamImpl , 104 ) ;
459
+ static_assert_size ! ( LazyAttrTokenStreamImpl , 96 ) ;
463
460
// tidy-alphabetical-end
464
461
}
0 commit comments