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

match_single_binding: Fix invalid suggestion when match scrutinee has side effects #7095

Merged
merged 1 commit into from
May 13, 2021

Conversation

Y-Nak
Copy link
Contributor

@Y-Nak Y-Nak commented Apr 16, 2021

fixes #7094

changelog: match_single_binding: Fix invalid suggestion when match scrutinee has side effects


Expr::can_have_side_effects is used to determine the scrutinee has side effects, while this method is a little bit conservative for our use case. But I'd like to use it to avoid reimplementation of the method and too much heuristics. If you think this is problematic, then I'll implement a custom visitor to address it.

@rust-highfive
Copy link

r? @phansch

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 16, 2021
@Y-Nak Y-Nak force-pushed the match_single_binding branch 3 times, most recently from f45381a to c8e3da4 Compare April 16, 2021 10:46
@giraffate
Copy link
Contributor

ping from triage @phansch. Can you have time to review this?

Copy link
Contributor

@giraffate giraffate left a comment

Choose a reason for hiding this comment

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

@Y-Nak Sorry for the late review.

Expr::can_have_side_effects is used to determine the scrutinee has side effects, while this method is a little bit conservative for our use case.

Yes I think so, but I also think it's not bad. At least, this lint is improved. I made some comment on this, but overall looks good.

Anyway, thanks for your patience!

clippy_lints/src/matches.rs Outdated Show resolved Hide resolved
clippy_lints/src/matches.rs Outdated Show resolved Hide resolved
@Y-Nak Y-Nak force-pushed the match_single_binding branch from c8e3da4 to 8214bf0 Compare May 13, 2021 01:38
@Y-Nak
Copy link
Contributor Author

Y-Nak commented May 13, 2021

Thanks for your review @giraffate! Happy to move forward.

@giraffate
Copy link
Contributor

@bors r+

It looks good, thanks!

@bors
Copy link
Contributor

bors commented May 13, 2021

📌 Commit 8214bf0 has been approved by giraffate

@bors
Copy link
Contributor

bors commented May 13, 2021

⌛ Testing commit 8214bf0 with merge 1fd9975...

@bors
Copy link
Contributor

bors commented May 13, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 1fd9975 to master...

@bors bors merged commit 1fd9975 into rust-lang:master May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vacuous match body with side-effectful matchee
5 participants