Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Removes redundant parentheses #7721

Merged
merged 1 commit into from
Jan 31, 2018
Merged

Removes redundant parentheses #7721

merged 1 commit into from
Jan 31, 2018

Conversation

0x7CFE
Copy link
Contributor

@0x7CFE 0x7CFE commented Jan 29, 2018

Recent nightly contains lint for redundant parentheses in expressions, that typically looks like this:

warning: unnecessary parentheses around function argument
   --> util/rlp/src/untrusted_rlp.rs:279:43
    |
279 |             result = UntrustedRlp::consume(result, (i.header_len + i.value_len))?;
    |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
    |
    = note: #[warn(unused_parens)] on by default

Entries in normal sources were modified accordingly. However, there are a lot of generated files, where n-tuple is returned as Ok part of a function's Result. In case of 1-tuple it looks like Ok((x)) which makes rustc nervous.

In order to calm the compiler down, I've added #![allow(unused_parens)] in generated modules and simplified the expressions in normal code (where applicable).

Also, updater/src/operations.rs seems to be autogenerated, but since it was in the repo, I decided to fix it by hand as well.

@0x7CFE 0x7CFE requested a review from debris January 29, 2018 15:10
@0x7CFE 0x7CFE changed the title Removes redundant parentheses, whitelists them in generated code Removes redundant parentheses Jan 29, 2018
@0x7CFE 0x7CFE self-assigned this Jan 30, 2018
@5chdn 5chdn added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jan 30, 2018
@5chdn 5chdn added this to the 1.10 milestone Jan 30, 2018
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

Long-term maybe we should fix the generators so that we don't have to allow unused_parens.

Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

I think @debris is getting rid of generated code in general, so it shouldn't be an issue with any new code.

@tomusdrw tomusdrw added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 30, 2018
@5chdn 5chdn merged commit a412f7c into master Jan 31, 2018
@5chdn 5chdn deleted the unused_parens branch January 31, 2018 08:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants