Skip to content
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

Merged
merged 2 commits into from
Jan 14, 2018

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jan 8, 2018

Re #46659.

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@estebank estebank added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2018
14 | _x = 4;
| ^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `_x` (Mir)
Copy link
Contributor

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?

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2018
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 10, 2018
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 10, 2018

📌 Commit 90bc98c has been approved by petrochenkov

}
} else {
false
};
Copy link
Contributor

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;

Copy link
Contributor

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.

Copy link
Contributor Author

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 ^_^

@petrochenkov petrochenkov added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2018
@bors
Copy link
Contributor

bors commented Jan 14, 2018

⌛ Testing commit 90bc98c with merge fd0f292...

bors added a commit that referenced this pull request Jan 14, 2018
Assignment to immutable argument: diagnostic tweak

Re #46659.
@bors
Copy link
Contributor

bors commented Jan 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing fd0f292 to master...

@bors bors merged commit 90bc98c into rust-lang:master Jan 14, 2018
@estebank estebank deleted the immutable-arg branch November 9, 2023 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants