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

Incorrect handling of rustc_on_unimplemented for duplicated_attributes #12619

Closed
Nilstrieb opened this issue Apr 2, 2024 · 0 comments · Fixed by #12620
Closed

Incorrect handling of rustc_on_unimplemented for duplicated_attributes #12619

Nilstrieb opened this issue Apr 2, 2024 · 0 comments · Fixed by #12620
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Nilstrieb
Copy link
Member

Summary

I ran clippy on the standard library and it complained about duplicated attributes that were not duplicated.
This does not affect the new diagnostic::on_unimplemented attribute, as it does not support on syntax.

Lint Name

duplicated_attributes

Reproducer

I tried this code:

#![feature(rustc_attrs)]

#[rustc_on_unimplemented(
    on(
        _Self = "&str",
        label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
    ),
    on(
        _Self = "alloc::string::String",
        label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
    ),
)]
trait X {}

fn main() {}

I saw this happen:

warning: duplicated attribute
  --> uwuclip.rs:10:9
   |
10 |         label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: first defined here
  --> uwuclip.rs:6:9
   |
6  |         label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: remove this attribute
  --> uwuclip.rs:10:9
   |
10 |         label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#duplicated_attributes
   = note: `#[warn(clippy::duplicated_attributes)]` on by default

I expected to see this happen:
No lints, this is some excellent code straight from the standard library

Version

rustc 1.79.0-nightly (8df7e723e 2024-03-30)
binary: rustc
commit-hash: 8df7e723ea729a7f917501cc2d91d640b7021373
commit-date: 2024-03-30
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Additional Labels

No response

@Nilstrieb Nilstrieb added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Apr 2, 2024
@bors bors closed this as completed in 412b691 May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant