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

Fix unused_parens false positive when using binary operations #71910

Merged
merged 3 commits into from
May 14, 2020

Conversation

mibac138
Copy link
Contributor

@mibac138 mibac138 commented May 5, 2020

Fixes #71290

r? @cuviper who provided instructions

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2020
@mibac138 mibac138 force-pushed the necessary-paren branch from a76eeaf to 3471bc8 Compare May 5, 2020 00:22
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
@cuviper
Copy link
Member

cuviper commented May 5, 2020

I think this is going to need some level of recursion -- for example, this still fails:

fn z() -> u8 {
    ({ 0 } + 1 + 2)
}

In the AST, that will associate like ( ({ 0 } + 1) + 2 ), so the LHS of the outer binop is another binop, which doesn't pass the expr_requires_semi_to_be_stmt test.

@mibac138
Copy link
Contributor Author

mibac138 commented May 6, 2020

I have now added recursion support and a relevant test case. I assume Expr can't create a cycle so this should be fine. Should I add an upper iteration bound anyway?

@cuviper
Copy link
Member

cuviper commented May 11, 2020

I assume Expr can't create a cycle so this should be fine. Should I add an upper iteration bound anyway?

I think it's fine -- for example, contains_exterior_struct_lit uses plain recursion on binary lhs/rhs.

@bors r+

@bors
Copy link
Contributor

bors commented May 11, 2020

📌 Commit 4b7a928 has been approved by cuviper

@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 May 11, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 12, 2020
Fix unused_parens false positive when using binary operations

Fixes rust-lang#71290

r? @cuviper who provided instructions
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 12, 2020
Fix unused_parens false positive when using binary operations

Fixes rust-lang#71290

r? @cuviper who provided instructions
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 13, 2020
Fix unused_parens false positive when using binary operations

Fixes rust-lang#71290

r? @cuviper who provided instructions
RalfJung added a commit to RalfJung/rust that referenced this pull request May 14, 2020
Fix unused_parens false positive when using binary operations

Fixes rust-lang#71290

r? @cuviper who provided instructions
bors added a commit to rust-lang-ci/rust that referenced this pull request May 14, 2020
Rollup of 8 pull requests

Successful merges:

 - rust-lang#71910 (Fix unused_parens false positive when using binary operations)
 - rust-lang#72087 (Fix hang in lexical_region_resolve)
 - rust-lang#72126 (Change `WorkProduct::saved_files` to an `Option`.)
 - rust-lang#72127 (add long error explanation for E0228)
 - rust-lang#72141 (Warn against thread::sleep in async fn)
 - rust-lang#72170 (use `require_lang_item` over `unwrap`.)
 - rust-lang#72191 (Clean up E0589 explanation)
 - rust-lang#72194 (Don't ICE on missing `Unsize` impl)

Failed merges:

r? @ghost
@bors bors merged commit b20b200 into rust-lang:master May 14, 2020
@mibac138 mibac138 deleted the necessary-paren branch August 10, 2020 14:31
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.

unused_parens false positive on addition of blocks?
5 participants