trim paths in suspicious_to_owned
This commit is contained in:
parent
41b2a3d9fe
commit
bd76d9133b
@ -5,7 +5,7 @@
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::{self, print::with_forced_trimmed_paths};
|
||||
use rustc_span::sym;
|
||||
|
||||
use super::SUSPICIOUS_TO_OWNED;
|
||||
@ -24,7 +24,9 @@ pub fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) -
|
||||
cx,
|
||||
SUSPICIOUS_TO_OWNED,
|
||||
expr.span,
|
||||
&format!("this `to_owned` call clones the {input_type} itself and does not cause the {input_type} contents to become owned"),
|
||||
&with_forced_trimmed_paths!(format!(
|
||||
"this `to_owned` call clones the {input_type} itself and does not cause the {input_type} contents to become owned"
|
||||
)),
|
||||
"consider using, depending on intent",
|
||||
format!("{recv_snip}.clone()` or `{recv_snip}.into_owned()"),
|
||||
app,
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: this `to_owned` call clones the std::borrow::Cow<'_, str> itself and does not cause the std::borrow::Cow<'_, str> contents to become owned
|
||||
error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned
|
||||
--> $DIR/suspicious_to_owned.rs:16:13
|
||||
|
|
||||
LL | let _ = cow.to_owned();
|
||||
@ -6,19 +6,19 @@ LL | let _ = cow.to_owned();
|
||||
|
|
||||
= note: `-D clippy::suspicious-to-owned` implied by `-D warnings`
|
||||
|
||||
error: this `to_owned` call clones the std::borrow::Cow<'_, [char; 3]> itself and does not cause the std::borrow::Cow<'_, [char; 3]> contents to become owned
|
||||
error: this `to_owned` call clones the Cow<'_, [char; 3]> itself and does not cause the Cow<'_, [char; 3]> contents to become owned
|
||||
--> $DIR/suspicious_to_owned.rs:26:13
|
||||
|
|
||||
LL | let _ = cow.to_owned();
|
||||
| ^^^^^^^^^^^^^^ help: consider using, depending on intent: `cow.clone()` or `cow.into_owned()`
|
||||
|
||||
error: this `to_owned` call clones the std::borrow::Cow<'_, std::vec::Vec<char>> itself and does not cause the std::borrow::Cow<'_, std::vec::Vec<char>> contents to become owned
|
||||
error: this `to_owned` call clones the Cow<'_, Vec<char>> itself and does not cause the Cow<'_, Vec<char>> contents to become owned
|
||||
--> $DIR/suspicious_to_owned.rs:36:13
|
||||
|
|
||||
LL | let _ = cow.to_owned();
|
||||
| ^^^^^^^^^^^^^^ help: consider using, depending on intent: `cow.clone()` or `cow.into_owned()`
|
||||
|
||||
error: this `to_owned` call clones the std::borrow::Cow<'_, str> itself and does not cause the std::borrow::Cow<'_, str> contents to become owned
|
||||
error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned
|
||||
--> $DIR/suspicious_to_owned.rs:46:13
|
||||
|
|
||||
LL | let _ = cow.to_owned();
|
||||
|
Loading…
Reference in New Issue
Block a user