Skip to content

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

Merged
bors merged 2 commits intorust-lang:masterfrom
sugar700:mark-writes-to-constant-as-sideeffectless
Dec 29, 2018
Merged

Mark writes to constants as side-effect-less#3595
bors merged 2 commits intorust-lang:masterfrom
sugar700:mark-writes-to-constant-as-sideeffectless

Conversation

@sugar700
Copy link
Copy Markdown
Contributor

@sugar700 sugar700 commented Dec 29, 2018

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

@sugar700 sugar700 force-pushed the mark-writes-to-constant-as-sideeffectless branch from 5d66f83 to 7a0e132 Compare December 29, 2018 14:17
@sugar700 sugar700 force-pushed the mark-writes-to-constant-as-sideeffectless branch from 7a0e132 to 847898f Compare December 29, 2018 14:19
Comment thread clippy_lints/src/no_effect.rs Outdated
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
Copy Markdown
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.

@sugar700
Copy link
Copy Markdown
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
Copy Markdown
Contributor

oli-obk commented Dec 29, 2018

@bors r+

Thanks

@bors
Copy link
Copy Markdown
Contributor

bors commented Dec 29, 2018

📌 Commit 9fe8a3e has been approved by oli-obk

@bors
Copy link
Copy Markdown
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
Copy Markdown
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