Skip to content

explicit_deref_methods triggering from within macros #15168

Open
@JustusFluegel

Description

@JustusFluegel

Summary

Starting from the below mentioned rust version, I get clippy lints that are not actionable from inside a macro expansion from a third-party crate:

rustc 1.89.0-nightly (1677d46cb 2025-06-10) and later. Can very well be that a earlier nightly also triggers this, but this is the first version that this appears in our ci. Also happens on current beta.

If that is welcome, I can try to do a bisect to find the exact commit that triggered this, and I can try to fix this as well if someone can give me a rough guide how one can generally go about fixing such bugs. Thank you :)

Lint Name

clippy::explicit_deref_methods

Reproducer

I tried this code:

#![warn(clippy::explicit_deref_methods)]

#[cfg(test)]
mod test {
    use proptest::prop_assert;
    use test_strategy::proptest;

    #[proptest]
    fn my_test(#[strategy(1..=20usize)] foo: usize) {
        prop_assert!(foo > 0);
    }
}

I saw this happen:

warning: explicit `deref` method call
 --> src/lib.rs:9:27
  |
9 |     fn my_test(#[strategy(1..=20usize)] foo: usize) {
  |                           ^^^^^^^^^^^ help: try: `&**#[proptest]`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_deref_methods
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(clippy::explicit_deref_methods)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The suggestion from within rust-analyzer also suggests writing #[strategy(&**#[proptest])] which obviously doesn't make any sense.

I expected to see this happen:

No lints, since the deref originates from within a macro

Version

rustc 1.89.0-nightly (1677d46cb 2025-06-10)
binary: rustc
commit-hash: 1677d46cb128cc8f285dbd32b0dc4d7a46437050
commit-date: 2025-06-10
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Additional Labels

@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions