Closed
Description
This is a regression from stable to beta and nightly.
This code is wrong (missing semicolons):
macro_rules! make_item {
($a:ident) => { struct $a; }
}
fn a() { make_item!(A) }
fn b() { make_item!(B) }
Stable prints:
<anon>:2:21: 2:27 error: expected identifier, found keyword `struct`
<anon>:2 ($a:ident) => { struct $a; }
^~~~~~
<anon>:5:21: 5:22 error: macro expansion ignores token `A` and any following
<anon>:5 fn a() { make_item!(A) }
^
<anon>:5:10: 5:23 note: caused by the macro expansion here; the usage of `make_item!` is likely invalid in expression context
<anon>:5 fn a() { make_item!(A) }
^~~~~~~~~~~~~
<anon>:2:21: 2:27 error: expected identifier, found keyword `struct`
<anon>:2 ($a:ident) => { struct $a; }
^~~~~~
<anon>:6:21: 6:22 error: macro expansion ignores token `B` and any following
<anon>:6 fn b() { make_item!(B) }
^
<anon>:6:10: 6:23 note: caused by the macro expansion here; the usage of `make_item!` is likely invalid in expression context
<anon>:6 fn b() { make_item!(B) }
^~~~~~~~~~~~~
error: aborting due to 4 previous errors
Beta and nightly both print:
error: expected expression, found keyword `struct`
--> <anon>:2:21
|>
2 |> ($a:ident) => { struct $a; }
|> ^^^^^^
Notice that not only is all the useful information gone, but the compiler aborts after the first error instead of finding the rest. It does not matter whether RUST_NEW_ERROR_FORMAT
is on or off.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: This is a bug.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.
Activity
jseyfried commentedon Jun 23, 2016
cc me
Mark-Simulacrum commentedon May 6, 2017
So this fell through the cracks, and was a stable to nightly/beta regression. It still is a regression, in a way, but only of diagnostics. @jseyfried Could you take a look?
nikomatsakis commentedon May 8, 2017
Nominating for prioritization.
nikomatsakis commentedon May 11, 2017
So this part of the (previous) stable message:
feels like a bug to me anyhow.
This part:
is sort of good. It'd be nice to preserve a backtrace, at least. And ideally we'd suggest adding a
;
.nikomatsakis commentedon May 11, 2017
Given how much time has past, we're going to call this P-medium for now. However, @jseyfried will try to write up some mentoring instructions (or maybe fix it). He has a plan. =)
triage: P-medium
jseyfried commentedon May 15, 2017
I think the best path forward here is to try parsing an expression macro expansion as a statement before emitting an error. If the macro expansion parses as a statement successfully, we can emit a more helpful error suggesting that the user add a semicolon to the macro invocation.
14 remaining items