Rollup merge of #100250 - cjgillot:recover-token-stream, r=Aaron1011
Manually cleanup token stream when macro expansion aborts. In case of syntax error in macro expansion, the expansion code can decide to stop processing anything. In that case, the token stream is malformed. This makes downstream users, like derive macros, ICE. In this case, this PR manually cleans up the token stream by closing all currently open delimiters. Fixes https://github.com/rust-lang/rust/issues/96818. Fixes https://github.com/rust-lang/rust/issues/80447. Fixes https://github.com/rust-lang/rust/issues/81920. Fixes https://github.com/rust-lang/rust/issues/91023.
This commit is contained in:
commit
14b27cfd11
4 changed files with 84 additions and 29 deletions
|
@ -459,6 +459,5 @@ fn make_token_stream(
|
|||
panic!("Unexpected last token {:?}", last_token)
|
||||
}
|
||||
}
|
||||
assert!(stack.is_empty(), "Stack should be empty: final_buf={:?} stack={:?}", final_buf, stack);
|
||||
AttrTokenStream::new(final_buf.inner)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue