Skip to content

Commit

Permalink
Add ui tests for UNNECESSARY_TO_OWNED on split
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 25, 2023
1 parent 6d5856c commit b5a2864
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/ui/unnecessary_to_owned_on_split.fixed
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`
}
6 changes: 6 additions & 0 deletions tests/ui/unnecessary_to_owned_on_split.rs
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`
}
17 changes: 17 additions & 0 deletions tests/ui/unnecessary_to_owned_on_split.stderr
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

0 comments on commit b5a2864

Please sign in to comment.