@@ -254,33 +254,38 @@ struct TokenCursor {
254
254
}
255
255
256
256
impl TokenCursor {
257
- fn next ( & mut self , desugar_doc_comments : bool ) -> ( Token , Spacing ) {
258
- self . inlined_next ( desugar_doc_comments )
257
+ fn next ( & mut self ) -> ( Token , Spacing ) {
258
+ self . inlined_next ( )
259
259
}
260
260
261
261
/// This always-inlined version should only be used on hot code paths.
262
262
#[ inline( always) ]
263
- fn inlined_next ( & mut self , desugar_doc_comments : bool ) -> ( Token , Spacing ) {
263
+ fn inlined_next ( & mut self ) -> ( Token , Spacing ) {
264
264
loop {
265
265
// FIXME: we currently don't return `Delimiter` open/close delims. To fix #67062 we will
266
266
// need to, whereupon the `delim != Delimiter::Invisible` conditions below can be
267
267
// removed.
268
268
if let Some ( tree) = self . tree_cursor . next_ref ( ) {
269
269
match tree {
270
- & TokenTree :: Token ( ref token, spacing) => match ( desugar_doc_comments, token) {
271
- ( true , & Token { kind : token:: DocComment ( _, attr_style, data) , span } ) => {
272
- let desugared = self . desugar ( attr_style, data, span) ;
273
- self . tree_cursor . replace_prev_and_rewind ( desugared) ;
274
- // Continue to get the first token of the desugared doc comment.
275
- }
276
- _ => {
277
- debug_assert ! ( !matches!(
278
- token. kind,
279
- token:: OpenDelim ( _) | token:: CloseDelim ( _)
280
- ) ) ;
281
- return ( token. clone ( ) , spacing) ;
270
+ & TokenTree :: Token ( ref token, spacing) => {
271
+ match ( self . desugar_doc_comments , token) {
272
+ (
273
+ true ,
274
+ & Token { kind : token:: DocComment ( _, attr_style, data) , span } ,
275
+ ) => {
276
+ let desugared = self . desugar ( attr_style, data, span) ;
277
+ self . tree_cursor . replace_prev_and_rewind ( desugared) ;
278
+ // Continue to get the first token of the desugared doc comment.
279
+ }
280
+ _ => {
281
+ debug_assert ! ( !matches!(
282
+ token. kind,
283
+ token:: OpenDelim ( _) | token:: CloseDelim ( _)
284
+ ) ) ;
285
+ return ( token. clone ( ) , spacing) ;
286
+ }
282
287
}
283
- } ,
288
+ }
284
289
& TokenTree :: Delimited ( sp, delim, ref tts) => {
285
290
let trees = tts. clone ( ) . into_trees ( ) ;
286
291
self . stack . push ( ( mem:: replace ( & mut self . tree_cursor , trees) , delim, sp) ) ;
@@ -1105,7 +1110,7 @@ impl<'a> Parser<'a> {
1105
1110
pub fn bump ( & mut self ) {
1106
1111
// Note: destructuring here would give nicer code, but it was found in #96210 to be slower
1107
1112
// than `.0`/`.1` access.
1108
- let mut next = self . token_cursor . inlined_next ( self . token_cursor . desugar_doc_comments ) ;
1113
+ let mut next = self . token_cursor . inlined_next ( ) ;
1109
1114
self . token_cursor . num_next_calls += 1 ;
1110
1115
// We've retrieved an token from the underlying
1111
1116
// cursor, so we no longer need to worry about
@@ -1155,7 +1160,7 @@ impl<'a> Parser<'a> {
1155
1160
let mut i = 0 ;
1156
1161
let mut token = Token :: dummy ( ) ;
1157
1162
while i < dist {
1158
- token = cursor. next ( cursor . desugar_doc_comments ) . 0 ;
1163
+ token = cursor. next ( ) . 0 ;
1159
1164
if matches ! (
1160
1165
token. kind,
1161
1166
token:: OpenDelim ( Delimiter :: Invisible ) | token:: CloseDelim ( Delimiter :: Invisible )
0 commit comments