-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Compiling a Rocket application on the 2015 edition doesn't emit errors #89699
Comments
This leads to @rustbot label +I-ICE |
The fatal error is raised here: rust/compiler/rustc_parse/src/parser/mod.rs Line 527 in 15491d7
|
Here's an overview of what is happening. The proc-macro creates something along the lines of:
In 2015, when it goes to parse the arguments, it sees Normally this sequence of events won't happen because the I think the use of Here is a minimal repro: // src/lib.rs
#[pm::foo]
fn foo() {} And a proc-macro named extern crate proc_macro;
use proc_macro::*;
#[proc_macro_attribute]
pub fn foo(_attr: TokenStream, item: TokenStream) -> TokenStream {
let tt = item.into_iter().next().unwrap();
let sp = tt.span();
let mut arg = TokenStream::new();
let mut g = Group::new(Delimiter::Brace, TokenStream::new());
g.set_span(sp);
arg.extend([
TokenTree::Ident(Ident::new("async", sp)),
TokenTree::Ident(Ident::new("move", sp)),
TokenTree::Group(g),
]);
let mut body = TokenStream::new();
body.extend([
TokenTree::Ident(Ident::new("async_main", sp)),
TokenTree::Group(Group::new(Delimiter::Parenthesis, arg)),
]);
let mut ret = TokenStream::new();
ret.extend([
TokenTree::Ident(Ident::new("fn", sp)),
TokenTree::Ident(Ident::new("main", sp)),
TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
TokenTree::Group(Group::new(Delimiter::Brace, body)),
]);
eprintln!("{:?}", ret);
ret
} |
That check was added in #58903, but unfortunately there isn't much of a description explaining why it was added. |
IIRC I believe that it was to deduplicate some redundant errors that occurred otherwise. This whole ordeal reminds me that we should be trying to parse |
Triage: Can someone please give a concrete example of a minimal "Rocket application" that reproduces this? |
@Enselic Is there any particular reason you'd like a Rocket application specifically? There is a minimal reproduction without Rocket listed above at #89699 (comment). I believe this is mostly addressed via #114237. The reproduction now prints the error:
However, I would suggest someone adding that reproduction to the UI testsuite, since it is a relatively subtle construction of tokens, and the test in #114237 doesn't test anything like what that is doing. I'd also defer to @estebank if they think there is anything more fundamental that should be done, particularly around the use of |
My bad, sorry about that. I'm trying to keep a high pace when triaging ICE-issues since there are so many of them. In this case the pace was too high, so I missed that comment of yours. |
We discuss this in the wg-macros triage meeting and @CohenArthur will work on it 🛩️ If you want to join the discussion, please join our zulip stream |
@rustbot claim |
Add a test to ensure issue rust-lang#89699 does not show up again. This test emits an `async move` closure in a proc macro, which is used in a test program compiled with edition 2015. We make sure the error message is nice and shows up properly.
Rollup merge of rust-lang#117973 - CohenArthur:fix-89699, r=lqd test: Add test for async-move in 2015 Rust proc macro Fixes rust-lang#89699 Ran cargo bisect-rustc to find when this was fixed exactly, which is in 474709a
When trying to compile any Rocket application in the 2015 edition the compiler says an error occured without showing any actual error:
Switching to the 2018 edition fixes the problem, by either showing errors or properly compiling the application. Minimal reproduction:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: