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

Do not trigger unused_{braces,parens} lints with yield #75031

Merged
merged 2 commits into from
Aug 2, 2020

Conversation

JohnTitor
Copy link
Member

Fixes #74883
r? @lcnr

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2020
src/librustc_lint/unused.rs Outdated Show resolved Hide resolved
src/librustc_lint/unused.rs Outdated Show resolved Hide resolved
@lcnr
Copy link
Contributor

lcnr commented Aug 2, 2020

The duplicate errors on while are actually part of a bigger problem, the following should not warn:

fn main() {
    let mut a = Some(3);
    while let Some(ref mut v) = {a} {
        a.as_mut().map(|a| std::mem::swap(a, v));
    }
}

The way to fix this would be to pretty much copy what we are already doing for If in check_expr here.

If you want to fix that as part of this PR, feel free, otherwise r=me

@bors delegate+

@bors
Copy link
Contributor

bors commented Aug 2, 2020

✌️ @JohnTitor can now approve this pull request

1 similar comment
@bors
Copy link
Contributor

bors commented Aug 2, 2020

✌️ @JohnTitor can now approve this pull request

@JohnTitor
Copy link
Member Author

The duplicate errors on while are actually part of a bigger problem

Ah, interesting! I didn't realize this case, yeah, we should fix then.

If you want to fix that as part of this PR, feel free, otherwise r=me

I'm going to r=you as-is since I think the fix is out of context of yield but I'll follow-up it!
Btw, I already bors perms so you don't have to delegate me. :)

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Aug 2, 2020

📌 Commit 2e7ba78 has been approved by lcnr

@bors bors 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 Aug 2, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 2, 2020
…arth

Rollup of 5 pull requests

Successful merges:

 - rust-lang#74980 (pprust: adjust mixed comment printing and add regression test for rust-lang#74745)
 - rust-lang#75009 (Document the discrepancy in the mask type for _mm_shuffle_ps)
 - rust-lang#75031 (Do not trigger `unused_{braces,parens}` lints with `yield`)
 - rust-lang#75059 (fix typos)
 - rust-lang#75064 (compiletest: Support ignoring tests requiring missing LLVM components)

Failed merges:

r? @ghost
@bors bors merged commit db3e10f into rust-lang:master Aug 2, 2020
@JohnTitor JohnTitor deleted the unused-parens-braces-yield branch August 3, 2020 00:01
Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 3, 2020
…r=lcnr

Do not trigger `unused_braces` for `while let`

Follow-up for rust-lang#75031
r? @lcnr
Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 3, 2020
…r=lcnr

Do not trigger `unused_braces` for `while let`

Follow-up for rust-lang#75031
r? @lcnr
Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 3, 2020
…r=lcnr

Do not trigger `unused_braces` for `while let`

Follow-up for rust-lang#75031
r? @lcnr
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 3, 2020
…r=lcnr

Do not trigger `unused_braces` for `while let`

Follow-up for rust-lang#75031
r? @lcnr
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 4, 2020
…r=lcnr

Do not trigger `unused_braces` for `while let`

Follow-up for rust-lang#75031
r? @lcnr
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
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.

unnecessary parentheses warning triggers for necessary parentheses around yield expression
6 participants