-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Assignment to immutable argument: diagnostic tweak #47261
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
4a01467
to
1890818
Compare
14 | _x = 4; | ||
| ^^^^^^ cannot assign twice to immutable variable | ||
|
||
error[E0384]: cannot assign twice to immutable variable `_x` (Mir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this message say "argument" instead of "variable" as well?
efd08e0
to
e1ee593
Compare
e1ee593
to
90bc98c
Compare
@bors r+ |
📌 Commit 90bc98c has been approved by |
} | ||
} else { | ||
false | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
much
vertical
space.
Now every time I see stuff like this I'm rewording it with is
expressions in my head.
let is_arg = place is Place::Local(local) && self.mir.local_kind(*local) is LocalKind::Arg;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petrochenkov To be fair this is just:
let is_arg = match place {
Place::Local(local) => self.mir.local_kind(*local) == LocalKind::Arg,
_ => false
};
I think if let
is overused and match is better in many cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I usually revert to using match in cases like this. Somehow it escaped me here ^_^
Assignment to immutable argument: diagnostic tweak Re #46659.
☀️ Test successful - status-appveyor, status-travis |
Re #46659.