-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack overflow? in parser in some code with syntax errors #80447
Comments
Minimized: proc macro extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn mac(_attrs: TokenStream, input: TokenStream) -> TokenStream {
input
} lib.rs pub trait Crash {
#[mac::mac]
fn one(s: () {
}
fn two();
} |
@rustbot modify labels -E-needs-mcve +A-proc-macros |
Issue: rust-lang/rust#80447
Is the solution possibly to just remove the offending assertion? The token stream will be nonsense but some other error reporting should catch the mismatched delimiters, I'd assume? |
I just quickly tried the suggestion above (removing the assertion) and this is the error I got without it:
Note that I tried a slightly simpler version of the small repro above:
This still fails with ICE with the assertion. |
I think I'm seeing the same issue with code containing a similar syntax error: use tracing::instrument;
struct al;
impl al {
#[instrument]
fn ox(&mut self {
}
} The error is the I see this on both release and debug builds: Here is the error and stack from Rust Playground:
|
…aron1011 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 rust-lang#96818. Fixes rust-lang#80447. Fixes rust-lang#81920. Fixes rust-lang#91023.
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 rust-lang/rust#96818. Fixes rust-lang/rust#80447. Fixes rust-lang/rust#81920. Fixes rust-lang/rust#91023.
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 rust-lang/rust#96818. Fixes rust-lang/rust#80447. Fixes rust-lang/rust#81920. Fixes rust-lang/rust#91023.
Steps to reproduce
I'm afraid I haven't minimised this test case.
This doesn't seem to be a very serious problem as the compiler has correctly pointed out syntax errors; fixing those syntax errors makes the ICE go away. But since it suggested filing a bug I repro'd with today's nightly and have done so.
Meta
rustc --version --verbose
:Error output
Backtrace
The panic message in full
The text was updated successfully, but these errors were encountered: