-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Error recovery after errors during macro expansion is usually futile #116180
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
Rationale and extra context
This is a concrete example, but the problem is very general. When macro expansion goes wrong, anything might have not happened as a result, for example defining types and other things. In my experience, this frequently causes cascading useless errors, mostly but not exclusively from name resolution. This makes it very hard to work with the output of
cargo checkwhen dealing with macro expansion errors in my experience.We should, when there are errors during macro expansion, abort compilation after macro expansion without any further recovery. It's impossible to know which errors are actually useful and in many cases there are a lot of useless ones.
With errors during macro expansion I mean any errors that stop macros from being expanded, for example matching mismatches or macros not being found.
Note that errors before macro expansion, like parser errors, tend to be fairly recoverable and we should still do recovery on them, this is specifically about the case where the error count increases during macro expansion.
Other cases
No response
Anything else?
cc @rust-lang/wg-diagnostics