-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fb7405
commit 24b3a63
Showing
2 changed files
with
15 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#![warn(clippy::str_to_string)] | ||
|
||
fn main() { | ||
let _ = "hello world".to_string(); | ||
let hello = "hello world".to_string(); | ||
let msg = &hello[..]; | ||
msg.to_string(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
error: `to_string()` does a multitude of things to just clone a `&str` | ||
--> $DIR/str_to_string.rs:4:13 | ||
--> $DIR/str_to_string.rs:4:17 | ||
| | ||
LL | let _ = "hello world".to_string(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | let hello = "hello world".to_string(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::str-to-string` implied by `-D warnings` | ||
= help: consider using `.to_owned()` | ||
|
||
error: aborting due to previous error | ||
error: `to_string()` does a multitude of things to just clone a `&str` | ||
--> $DIR/str_to_string.rs:6:5 | ||
| | ||
LL | msg.to_string(); | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using `.to_owned()` | ||
|
||
error: aborting due to 2 previous errors | ||
|