@@ -7716,8 +7716,9 @@ impl<'a> Parser<'a> {
7716
7716
let ret = f ( self ) ;
7717
7717
let last_token = if self . token_cursor . stack . len ( ) == prev {
7718
7718
& mut self . token_cursor . frame . last_token
7719
- } else if self . token_cursor . stack . is_empty ( ) { //&& !self.unclosed_delims.is_empty() {
7720
- // This can happen with mismatched delimiters (#62881)
7719
+ } else if self . token_cursor . stack . get ( prev) . is_none ( ) {
7720
+ // This can happen due to a bad interaction of two unrelated recovery mechanisms with
7721
+ // mismatched delimiters *and* recovery lookahead on `pub ident(` likely typo (#62881)
7721
7722
return Ok ( ( ret?, TokenStream :: new ( vec ! [ ] ) ) ) ;
7722
7723
} else {
7723
7724
& mut self . token_cursor . stack [ prev] . last_token
@@ -7726,7 +7727,15 @@ impl<'a> Parser<'a> {
7726
7727
// Pull out the tokens that we've collected from the call to `f` above.
7727
7728
let mut collected_tokens = match * last_token {
7728
7729
LastToken :: Collecting ( ref mut v) => mem:: replace ( v, Vec :: new ( ) ) ,
7729
- LastToken :: Was ( _) => panic ! ( "our vector went away?" ) ,
7730
+ LastToken :: Was ( ref was) => {
7731
+ let msg = format ! ( "our vector went away? - found Was({:?})" , was) ;
7732
+ debug ! ( "collect_tokens: {}" , msg) ;
7733
+ self . sess . span_diagnostic . delay_span_bug ( self . token . span , & msg) ;
7734
+ // This can happen due to a bad interaction of two unrelated recovery mechanisms
7735
+ // with mismatched delimiters *and* recovery lookahead on `pub ident(` likely typo
7736
+ // (#62895, different but similar to the case above)
7737
+ return Ok ( ( ret?, TokenStream :: new ( vec ! [ ] ) ) ) ;
7738
+ }
7730
7739
} ;
7731
7740
7732
7741
// If we're not at EOF our current token wasn't actually consumed by
0 commit comments