You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implemented suspicious_to_owned lint to check if to_owned is called on a Cow.
This is done because `to_owned` is very similarly named to `into_owned`, but the
effect of calling those two methods is completely different. This creates
confusion (stemming from the ambiguity of the 'owned' term in the context of
`Cow`s) and might not be what the writer intended.
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
2
+
--> $DIR/suspicious_to_owned.rs:16:13
3
+
|
4
+
LL | let _ = cow.to_owned();
5
+
| ^^^^^^^^^^^^^^ help: consider using, depending on intent: `cow.clone()` or `cow.into_owned()`
6
+
|
7
+
= note: `-D clippy::suspicious-to-owned` implied by `-D warnings`
8
+
9
+
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
10
+
--> $DIR/suspicious_to_owned.rs:26:13
11
+
|
12
+
LL | let _ = cow.to_owned();
13
+
| ^^^^^^^^^^^^^^ help: consider using, depending on intent: `cow.clone()` or `cow.into_owned()`
14
+
15
+
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
16
+
--> $DIR/suspicious_to_owned.rs:36:13
17
+
|
18
+
LL | let _ = cow.to_owned();
19
+
| ^^^^^^^^^^^^^^ help: consider using, depending on intent: `cow.clone()` or `cow.into_owned()`
20
+
21
+
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
22
+
--> $DIR/suspicious_to_owned.rs:46:13
23
+
|
24
+
LL | let _ = cow.to_owned();
25
+
| ^^^^^^^^^^^^^^ help: consider using, depending on intent: `cow.clone()` or `cow.into_owned()`
26
+
27
+
error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type
0 commit comments