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

Mark writes to constants as side-effect-less #3595

Merged

Conversation

KamilaBorowska
Copy link
Contributor

@KamilaBorowska KamilaBorowska commented Dec 29, 2018

This is my first real contribution, so I probably did it wrong.

@KamilaBorowska KamilaBorowska force-pushed the mark-writes-to-constant-as-sideeffectless branch from 5d66f83 to 7a0e132 Compare December 29, 2018 14:17
@KamilaBorowska KamilaBorowska force-pushed the mark-writes-to-constant-as-sideeffectless branch from 7a0e132 to 847898f Compare December 29, 2018 14:19
ExprKind::Assign(ref left, ref right) => {
if has_no_effect(cx, left) {
let mut left = left;
while let ExprKind::Field(f, _) = &left.node {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can unwrap a few other expressions, too. Index would be one i can think of. There may be others, too.

@KamilaBorowska
Copy link
Contributor Author

Okay, I added if_while_or_patterns feature, because it makes this code more readable, and I believe the intent is to stabilize this feature anyways in Rust 1.33 (see rust-lang/rust#56212).

@oli-obk
Copy link
Contributor

oli-obk commented Dec 29, 2018

@bors r+

Thanks

@bors
Copy link
Contributor

bors commented Dec 29, 2018

📌 Commit 9fe8a3e has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Dec 29, 2018

⌛ Testing commit 9fe8a3e with merge a7fe5af...

bors added a commit that referenced this pull request Dec 29, 2018
… r=oli-obk

Mark writes to constants as side-effect-less

This is my first real contribution, so I probably did it wrong.
@bors
Copy link
Contributor

bors commented Dec 29, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing a7fe5af to master...

@bors bors merged commit 9fe8a3e into rust-lang:master Dec 29, 2018
bors added a commit that referenced this pull request Jan 4, 2019
Move constant write checks to temporary_assignment lint

They make more sense here

cc #3595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants