@@ -7716,8 +7716,9 @@ impl<'a> Parser<'a> {
77167716 let ret = f ( self ) ;
77177717 let last_token = if self . token_cursor . stack . len ( ) == prev {
77187718 & 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)
77217722 return Ok ( ( ret?, TokenStream :: new ( vec ! [ ] ) ) ) ;
77227723 } else {
77237724 & mut self . token_cursor . stack [ prev] . last_token
@@ -7726,7 +7727,15 @@ impl<'a> Parser<'a> {
77267727 // Pull out the tokens that we've collected from the call to `f` above.
77277728 let mut collected_tokens = match * last_token {
77287729 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+ }
77307739 } ;
77317740
77327741 // If we're not at EOF our current token wasn't actually consumed by
0 commit comments