Skip to content

Wrong "unnecessary parentheses around function argument"-warning #47775

Closed
@SWW13

Description

@SWW13

Recent nightly versions give warnings when using the macro do_parse!() of nom:

I tried this code:

named!(pub parse_string <String>, do_parse!(
    value: map_res!(take_until!("\x00"), |value: &[u8]| String::from_utf8(value.to_vec())) >>
    tag!(b"\x00") >>
    (value)
));

I expected to see this happen:
No warning.

Instead, this happened:

warning: unnecessary parentheses around function argument
   |
13 | / named!(pub parse_string <String>, do_parse!(
14 | |     value: map_res!(take_until!("\x00"), |value: &[u8]| String::from_utf8(value.to_vec())) >>
15 | |     tag!(b"\x00") >>
16 | |     (value)
17 | | ));
   | |___^ help: remove these parentheses
   |
   = note: #[warn(unused_parens)] on by default
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

After investigating this further I found the source of the warning (see SWW13/nom@f1a04eb#diff-06e70f2a187023418eedf26d22d3aa5d).
But these parentheses are needed for the additional tuple, removing them breaks the nom tests.

CI logs show last working version rustc 1.25.0-nightly (da569fa9d 2018-01-16) and first broken version rustc 1.25.0-nightly (97520ccb1 2018-01-21).

Meta

Related Issue: rust-bakery/nom#668

rustc --version --verbose:

rustc 1.25.0-nightly (9fd7da904 2018-01-25)
binary: rustc
commit-hash: 9fd7da904b46ff7aa78c2e2cc1986c4975aeccc6
commit-date: 2018-01-25
host: x86_64-unknown-linux-gnu
release: 1.25.0-nightly
LLVM version: 4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions