@@ -388,12 +388,6 @@ impl<'a> Parser<'a> {
388
388
/// Converts a flattened iterator of tokens (including open and close delimiter tokens)
389
389
/// into a `TokenStream`, creating a `TokenTree::Delimited` for each matching pair
390
390
/// of open and close delims.
391
- // FIXME(#67062): Currently, we don't parse `Invisible`-delimited groups correctly,
392
- // which can cause us to end up with mismatched `Invisible` delimiters in our
393
- // captured tokens. This function contains several hacks to work around this -
394
- // essentially, we throw away mismatched `Invisible` delimiters when we encounter them.
395
- // Once we properly parse `Invisible` delimiters, they can be captured just like any
396
- // other tokens, and these hacks can be removed.
397
391
fn make_token_stream (
398
392
mut iter : impl Iterator < Item = ( FlatToken , Spacing ) > ,
399
393
break_last_token : bool ,
@@ -412,35 +406,10 @@ fn make_token_stream(
412
406
stack. push ( FrameData { open_delim_sp : Some ( ( delim, span) ) , inner : vec ! [ ] } ) ;
413
407
}
414
408
FlatToken :: Token ( Token { kind : TokenKind :: CloseDelim ( delim) , span } ) => {
415
- // HACK: If we encounter a mismatched `Invisible` delimiter at the top
416
- // level, just ignore it.
417
- if matches ! ( delim, Delimiter :: Invisible )
418
- && ( stack. len ( ) == 1
419
- || !matches ! (
420
- stack. last_mut( ) . unwrap( ) . open_delim_sp. unwrap( ) . 0 ,
421
- Delimiter :: Invisible
422
- ) )
423
- {
424
- token_and_spacing = iter. next ( ) ;
425
- continue ;
426
- }
427
409
let frame_data = stack
428
410
. pop ( )
429
411
. unwrap_or_else ( || panic ! ( "Token stack was empty for token: {:?}" , token) ) ;
430
412
431
- // HACK: If our current frame has a mismatched opening `Invisible` delimiter,
432
- // merge our current frame with the one above it. That is, transform
433
- // `[ { < first second } third ]` into `[ { first second } third ]`
434
- if !matches ! ( delim, Delimiter :: Invisible )
435
- && matches ! ( frame_data. open_delim_sp. unwrap( ) . 0 , Delimiter :: Invisible )
436
- {
437
- stack. last_mut ( ) . unwrap ( ) . inner . extend ( frame_data. inner ) ;
438
- // Process our closing delimiter again, this time at the previous
439
- // frame in the stack
440
- token_and_spacing = Some ( ( token, spacing) ) ;
441
- continue ;
442
- }
443
-
444
413
let ( open_delim, open_sp) = frame_data. open_delim_sp . unwrap ( ) ;
445
414
assert_eq ! (
446
415
open_delim, delim,
@@ -472,13 +441,6 @@ fn make_token_stream(
472
441
}
473
442
token_and_spacing = iter. next ( ) ;
474
443
}
475
- // HACK: If we don't have a closing `Invisible` delimiter for our last
476
- // frame, merge the frame with the top-level frame. That is,
477
- // turn `< first second` into `first second`
478
- if stack. len ( ) == 2 && stack[ 1 ] . open_delim_sp . unwrap ( ) . 0 == Delimiter :: Invisible {
479
- let temp_buf = stack. pop ( ) . unwrap ( ) ;
480
- stack. last_mut ( ) . unwrap ( ) . inner . extend ( temp_buf. inner ) ;
481
- }
482
444
let mut final_buf = stack. pop ( ) . expect ( "Missing final buf!" ) ;
483
445
if break_last_token {
484
446
let ( last_token, spacing) = final_buf. inner . pop ( ) . unwrap ( ) ;
0 commit comments