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

allow_attributes triggers on variable name #13380

Closed
Byter09 opened this issue Sep 11, 2024 · 3 comments · Fixed by #13389
Closed

allow_attributes triggers on variable name #13380

Byter09 opened this issue Sep 11, 2024 · 3 comments · Fixed by #13389
Assignees
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

@Byter09
Copy link

Byter09 commented Sep 11, 2024

Summary

When upgrading to 1.81.0 the lint triggered on a variable in our code. I managed to produce a minimal example, unsure if it can be even smaller.

Lint Name

allow_attributes

Reproducer

I tried this code:

#![deny(clippy::allow_attributes)]


pub fn minimal_example() -> Option<u8> {
    let allowed_opt: Option<u8> = None;

    let allowed_raw = allowed_opt?;

    Some(allowed_raw)
}

I saw this happen:

    Checking playground v0.0.1 (/playground)
error: #[allow] attribute found
 --> src/lib.rs:7:23
  |
7 |     let allowed_raw = allowed_opt?;
  |                       ^^^^^^^^^^^^ help: replace it with: `expect`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![deny(clippy::allow_attributes)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `playground` (lib) due to 1 previous error

I expected to see this happen:

    Checking playground v0.0.1 (/playground)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.47s

Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

@Byter09 Byter09 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 Sep 11, 2024
@samueltardieu
Copy link
Contributor

@rustbot claim

workingjubilee pushed a commit to workingjubilee/rustc that referenced this issue Sep 11, 2024
This is needed for Clippy to know that the `#[allow(unused)]` attributes
added by the expansion of `?` are part of the desugaring, and that they
do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 11, 2024
…-fix, r=jieyouxu

Use the same span for attributes and Try expansion of ?

This is needed for Clippy to know that the `#[allow(unused)]` attributes added by the expansion of `?` are part of the desugaring, and that they do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem and will be fixed by this change.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 12, 2024
Rollup merge of rust-lang#130244 - samueltardieu:qmark-expansion-span-fix, r=jieyouxu

Use the same span for attributes and Try expansion of ?

This is needed for Clippy to know that the `#[allow(unused)]` attributes added by the expansion of `?` are part of the desugaring, and that they do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem and will be fixed by this change.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 12, 2024
…ieyouxu

Use the same span for attributes and Try expansion of ?

This is needed for Clippy to know that the `#[allow(unused)]` attributes added by the expansion of `?` are part of the desugaring, and that they do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem and will be fixed by this change.
@samueltardieu
Copy link
Contributor

Thanks for the report @Byter09. This should be fixed in Rust/Clippy 1.83, as it was due to a bug in the rust compiler and has been fixed for 1.83.

@Byter09
Copy link
Author

Byter09 commented Sep 12, 2024

Neat. Thanks for the quick fix. :D

@bors bors closed this as completed in b39323b Sep 23, 2024
shrirambalaji pushed a commit to shrirambalaji/rust that referenced this issue Oct 6, 2024
This is needed for Clippy to know that the `#[allow(unused)]` attributes
added by the expansion of `?` are part of the desugaring, and that they
do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem.
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.

2 participants