-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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, ..)C-bugCategory: This is a bug.Category: This is a bug.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.
Description
This kind of macro pattern seems to mess up the span:
macro_rules! bad {
($s:ident whatever) => {
{
let $s = 0;
*&mut $s = 0;
}
}
}
fn main() {
bad!(foo whatever);
}
Compiling it results in a messed up error message:
<anon>:11:14: 11:22 error: cannot borrow immutable local variable `foo` as mutable
<anon>:11 bad!(foo whatever);
^~~~~~~~
<anon>:11:5: 11:24 note: in this expansion of bad! (defined in <anon>)
<anon>:11:14: 11:22 help: to make the local variable mutable, use `mut` as shown:
<anon>: bad!(foo mut whatever);
<anon>:11:5: 11:24 note: in this expansion of bad! (defined in <anon>)
error: aborting due to previous error
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, ..)C-bugCategory: This is a bug.Category: This is a bug.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.