Closed
Description
Summary
&mut Vec<T>
in a trait method signature used to correctly not trigger ptr_arg
. As of the most recent nightly, it's started falsely positiving. The same type in a non-trait function does not seem to be affected.
Lint Name
ptr_arg
Reproducer
trait Trait {
fn f(vec: &mut Vec<i32>);
}
impl Trait for i32 {
fn f(vec: &mut Vec<i32>) {
vec.push(2);
}
}
fn main() {
let mut vec = Vec::new();
i32::f(&mut vec);
println!("{:?}", vec);
}
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
--> src/main.rs:2:15
|
2 | fn f(vec: &mut Vec<i32>);
| ^^^^^^^^^^^^^ help: change this to: `&mut [i32]`
|
= note: `#[warn(clippy::ptr_arg)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
Version
rustc 1.60.0-nightly (e0a55f449 2022-01-28)
binary: rustc
commit-hash: e0a55f4491a729bffc63b402ba903d90858c806b
commit-date: 2022-01-28
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
Additional Labels
@rustbot label +I-suggestion-causes-error