blob: bdf5f98bf61e323e30a7e7edf896c634e206efa3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#![allow(clippy::single_char_pattern)]
struct Issue12068;
impl AsRef<str> for Issue12068 {
fn as_ref(&self) -> &str {
""
}
}
#[allow(clippy::to_string_trait_impl)]
impl ToString for Issue12068 {
fn to_string(&self) -> String {
String::new()
}
}
fn main() {
let _ = "a".to_string().split('a').next().unwrap();
//~^ unnecessary_to_owned
let _ = "a".to_string().split("a").next().unwrap();
//~^ unnecessary_to_owned
let _ = "a".to_owned().split('a').next().unwrap();
//~^ unnecessary_to_owned
let _ = "a".to_owned().split("a").next().unwrap();
//~^ unnecessary_to_owned
let _ = Issue12068.to_string().split('a').next().unwrap();
//~^ unnecessary_to_owned
let _ = [1].to_vec().split(|x| *x == 2).next().unwrap();
//~^ unnecessary_to_owned
let _ = [1].to_vec().split(|x| *x == 2).next().unwrap();
//~^ unnecessary_to_owned
let _ = [1].to_owned().split(|x| *x == 2).next().unwrap();
//~^ unnecessary_to_owned
let _ = [1].to_owned().split(|x| *x == 2).next().unwrap();
//~^ unnecessary_to_owned
}
|