Skip to content

explicit_auto_deref suggests code that does not compile #9841

@rossmacarthur

Description

@rossmacarthur

Summary

Reproducer attached. Clippy suggests to remove the dereference operator but without it the code doesn't compile.

Lint Name

explicit_auto_deref

Reproducer

I tried this code:

fn takes_array_ref<T, const N: usize>(array: &&[T; N]) {
    takes_slice(*array) // clippy suggests to remove dereference
}

fn takes_slice<T>(slice: &[T]) {
    todo!()
}

I saw this happen:

 --> src/lib.rs:2:17
  |
2 |     takes_slice(*array)
  |                 ^^^^^^ help: try this: `array`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
  = note: `#[warn(clippy::explicit_auto_deref)]` on by default

I expected to see this happen:
No lint, or a suggestion that builds

Version

rustc 1.67.0-nightly (6284998a2 2022-11-12)
binary: rustc
commit-hash: 6284998a2677d7e3e8420db783f3aa4fd80d7423
commit-date: 2022-11-12
host: aarch64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

Additional Labels

@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

No one assigned

    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