rust/tests/ui/needless_borrows_for_generic_args.stderr
Michael Baikov 79a14dea86 less aggressive needless_borrows_for_generic_args
Current implementation looks for significant drops, that can change the
behavior, but that's not enough - value might not have a Drop itself but
one of its children might have it.

A good example is passing a reference to `PathBuf` to `std::fs::File::open`.
There's no benefits to pass `PathBuf` by value, but since clippy can't
see `Drop` on `Vec` several layers down it complains forcing pass by
value and making it impossible to use the same name later.

New implementation only looks at copy values or values created inplace
so existing variable will never be moved but things that take a string
reference created and value is created inplace `&"".to_owned()` will
make it to suggest to use `"".to_owned()` still.

Fixes https://github.com/rust-lang/rust-clippy/issues/12454
2024-05-05 12:08:38 -04:00

72 lines
2.9 KiB
Plaintext

error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:16:37
|
LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap();
| ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
|
= note: `-D clippy::needless-borrows-for-generic-args` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_borrows_for_generic_args)]`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:17:33
|
LL | let _ = Path::new(".").join(&&".");
| ^^^^^ help: change this to: `"."`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:21:33
|
LL | let _ = std::fs::write("x", &"".to_string());
| ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:36:27
|
LL | deref_target_is_x(&X);
| ^^ help: change this to: `X`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:49:30
|
LL | multiple_constraints(&[[""]]);
| ^^^^^^^ help: change this to: `[[""]]`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:69:49
|
LL | multiple_constraints_normalizes_to_same(&X, X);
| ^^ help: change this to: `X`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:127:24
|
LL | takes_iter(&mut x)
| ^^^^^^ help: change this to: `x`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:136:41
|
LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap();
| ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:247:13
|
LL | foo(&a);
| ^^ help: change this to: `a`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:331:11
|
LL | f(&String::new()); // Lint, makes no difference
| ^^^^^^^^^^^^^^ help: change this to: `String::new()`
error: the borrowed expression implements the required traits
--> tests/ui/needless_borrows_for_generic_args.rs:334:11
|
LL | f(&"".to_owned()); // Lint
| ^^^^^^^^^^^^^^ help: change this to: `"".to_owned()`
error: aborting due to 11 previous errors