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

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

Closed
behnam opened this issue Mar 9, 2018 · 6 comments
Closed

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

behnam opened this issue Mar 9, 2018 · 6 comments
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@behnam
Copy link
Contributor

behnam commented Mar 9, 2018

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.
@zackmdavis
Copy link
Member

Possibly-relevant context: the unnecessary-parens lint was extended to arguments in #46980, and neutered for arguments in nested macros in #47896. But if this started failing today, something relevant must have changed elsewhere to reveal this bug.

@ExpHP
Copy link
Contributor

ExpHP commented Mar 13, 2018

Or it could be a change in serde_derive. This recent commit looks interesting, but it actually removes parentheses instead of adding them. What happens if you try serde on git master?

BTW, I tried building unic locally, and was unable to reproduce this with unic@9466e05e, rustc nightly-2018-03-07, and any of serde_derive versions 1.0.28–1.0.30 (the latest).

@pietroalbini pietroalbini added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Mar 13, 2018
@nikomatsakis
Copy link
Contributor

Hello from the @rust-lang/compiler triage meeting.

@benham can you verify if you are able to reproduce? If so, maybe give a specific commit and the output from rustc -vV? It'd be great if we can isolate down what has changed.

@nikomatsakis
Copy link
Contributor

triage: P-high

(But no assignment until we can reproduce.)

@rust-highfive rust-highfive added the P-high High priority label Mar 15, 2018
@behnam
Copy link
Contributor Author

behnam commented Mar 18, 2018

Thanks, @nikomatsakis, for the follow up!

Looks at the UNIC build history, apparently it was only failing for one day, on nightly, and got fixed. The version for that nightly build was rustc 1.26.0-nightly (2789b067d 2018-03-06).

I reported the issue right away to help with triage. Since it hasn't been repro'ed for the past 9 days, please feel free to close it.

@nikomatsakis
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants