Skip to content

Fix unused_parens false positive when using binary operations - #71910

Merged
bors merged 3 commits into
rust-lang:masterfrom
mibac138:necessary-paren
May 14, 2020
Merged

Fix unused_parens false positive when using binary operations#71910
bors merged 3 commits into
rust-lang:masterfrom
mibac138:necessary-paren

Conversation

@mibac138

Copy link
Copy Markdown
Contributor

Fixes#71290

r? @cuviper who provided instructions

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2020
Comment threadsrc/test/ui/lint/issue-71290-unused-paren-binop.rs
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
lcnr
lcnr approved these changes May 5, 2020
@cuviper

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

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

cuviper commented May 11, 2020

Copy link
Copy Markdown
Member

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

bors commented May 11, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 4b7a928 has been approved by cuviper

@borsbors 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
Fixesrust-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
Fixesrust-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
Fixesrust-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
Fixesrust-lang#71290
r? @cuviper who provided instructions
@RalfJungRalfJung mentioned this pull request May 14, 2020
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:masterMay 14, 2020
@mibac138
mibac138 deleted the necessary-paren branch August 10, 2020 14:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: 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

@mibac138@cuviper@bors@lcnr@rust-highfive