clippy --fix generates unbuildable code for a useless_vec fix #14531
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
Summary
Seen with Rust 1.85.1 when running
clippy --fix
on Packetry. at commit greatscottgadgets/packetry@e7c9dcc .The problem involves a useless use of
Vec
, a reference to which is passed into a function that takes&[T]
.When an array is used instead as suggested, the suggestion omits the necessary & operator.
Reproducer
Here's a minimised reproducer:
Running
clippy-driver
on this code results in:If the suggestion is applied, then compilation fails:
The correct suggestion would be
&[1, 2, 3, 4]
which compiles successfully.Version
Additional Labels
@rustbot label I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: