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

must_use_unit fails to apply if it's one of many attrs #12320

Open
matthiaskrgr opened this issue Feb 20, 2024 · 0 comments
Open

must_use_unit fails to apply if it's one of many attrs #12320

matthiaskrgr opened this issue Feb 20, 2024 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

Summary

.

Reproducer

I tried this code:

#[cfg_attr(all(), must_use, deprecated)]
fn main() { }
warning: this unit-returning function has a `#[must_use]` attribute
 --> src/main.rs:2:1
  |
1 | #[cfg_attr(all(), must_use, deprecated)]
  |                   -------- help: remove the attribute
2 | fn main() { }
  | ^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_unit
  = note: `#[warn(clippy::must_use_unit)]` on by default

in this case we need to remove the "," as well otherwise we end up with a syntax error lol

error: expected identifier, found `,`
 --> src/main.rs:1:19
  |
1 | #[cfg_attr(all(), , deprecated)]
  |                   ^
  |                   |
  |                   expected identifier
  |                   help: remove this comma

Version

rustc 1.78.0-nightly (3246e7951 2024-02-19)
binary: rustc
commit-hash: 3246e79513cb89ddbfc0f21cb5a877e5b321dcc5
commit-date: 2024-02-19
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Additional Labels

No response

@matthiaskrgr matthiaskrgr added the C-bug Category: Clippy is not doing the correct thing label Feb 20, 2024
@y21 y21 added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Feb 20, 2024
@matthiaskrgr matthiaskrgr changed the title must_use_unit fails to apply if its one of many attrs must_use_unit fails to apply if it's one of many attrs Feb 20, 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-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

No branches or pull requests

2 participants