forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ui tests for
UNNECESSARY_TO_OWNED
on split
- Loading branch information
1 parent
6d5856c
commit b5a2864
Showing
3 changed files
with
29 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
let _ = "a".split('a').next().unwrap(); | ||
//~^ ERROR: unnecessary use of `to_string` | ||
let _ = "a".split('a').next().unwrap(); | ||
//~^ ERROR: unnecessary use of `to_owned` | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
let _ = "a".to_string().split('a').next().unwrap(); | ||
//~^ ERROR: unnecessary use of `to_string` | ||
let _ = "a".to_owned().split('a').next().unwrap(); | ||
//~^ ERROR: unnecessary use of `to_owned` | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: unnecessary use of `to_string` | ||
--> $DIR/unnecessary_to_owned_on_split.rs:2:13 | ||
| | ||
LL | let _ = "a".to_string().split('a').next().unwrap(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` | ||
| | ||
= note: `-D clippy::unnecessary-to-owned` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` | ||
|
||
error: unnecessary use of `to_owned` | ||
--> $DIR/unnecessary_to_owned_on_split.rs:4:13 | ||
| | ||
LL | let _ = "a".to_owned().split('a').next().unwrap(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` | ||
|
||
error: aborting due to 2 previous errors | ||
|