Skip to content

unused_parens false positive on cfg_attr(..., derive(..., ...)) #48871

Closed
@behnam

Description

@behnam

UNIC builds started failing today on nightly with these errors:

error: unnecessary parentheses around function argument
  --> unic/bidi/src/level.rs:34:49
   |
34 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
   |                                                 ^^^^^^^^^^^
   |
note: lint level defined here
  --> unic/bidi/src/lib.rs:14:20
   |
14 | #![deny(bad_style, unused)]
   |                    ^^^^^^
   = note: #[deny(unused_parens)] implied by #[deny(unused)]
help: remove these parentheses
   |
34 | #[cfg_attr(feature = "serde", derive(Serialize, match <u8 as _serde::Deserialize>::deserialize(__e) {
35 |      ::result::Result::Ok(val) => val,
36 |      ::result::Result::Err(err) => {
37 |          return ::result::Result::Err(::convert::From::from(err))
38 |      }
39 |  }))]
   |
error: unnecessary parentheses around function argument
  --> unic/bidi/src/level.rs:34:49
   |
34 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
   |                                                 ^^^^^^^^^^^ help: remove these parentheses
error: aborting due to 2 previous errors

(from https://travis-ci.org/behnam/rust-unic/jobs/351099208)

Problems:

  • the cfg_attr lines do not have any unused parentheses, so it's a false positive;
  • the location the error message is pointing to is misleading, as there's no parentheses in the span it's pointing to; and
  • there are two different error reports here, both pointing to the same symptom, but with different looks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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