Skip to content

regression: bad fix for clippy::useless_conversion on auto-Deref conversions e.g. &&[T] #11572

@lorepozo

Description

@lorepozo

Summary

Fixes of this lint don't account for auto-Deref.

For example, where an IntoIterator is expected such as in Iterator::zip, if x.into_iter() is supplied then this lint can be triggered. But the fix does not account for cases where x is getting auto-Deref to invoke (*x).into_iter(). So x is the suggested fix, but *x is the correct fix.

Reproducer

I tried this code:

let x = &[1];
let y = &&[2];
let _ = x.iter().zip(y.into_iter());

I expected to see this happen:
valid fix, or no fix at all. (example of valid fix: replace y.into_iter() with *y)

Instead, this happened:
invalid fix, attempting to replace y.into_iter() with y.

Version

rustc 1.72.1 (d5c2e9c34 2023-09-13)
binary: rustc
commit-hash: d5c2e9c342b358556da91d61ed4133f6f50fc0c3
commit-date: 2023-09-13
host: x86_64-apple-darwin
release: 1.72.1
LLVM version: 16.0.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions