2024-01-11 16:27:03 +00:00
|
|
|
#![allow(clippy::single_char_pattern)]
|
|
|
|
|
|
|
|
struct Issue12068;
|
|
|
|
|
|
|
|
impl AsRef<str> for Issue12068 {
|
|
|
|
fn as_ref(&self) -> &str {
|
|
|
|
""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-08 19:24:42 +00:00
|
|
|
#[allow(clippy::to_string_trait_impl)]
|
2024-01-11 16:27:03 +00:00
|
|
|
impl ToString for Issue12068 {
|
|
|
|
fn to_string(&self) -> String {
|
|
|
|
String::new()
|
|
|
|
}
|
|
|
|
}
|
2023-12-28 18:33:07 +00:00
|
|
|
|
|
|
|
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_string`
|
|
|
|
let _ = "a".split('a').next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_owned`
|
|
|
|
let _ = "a".split("a").next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_owned`
|
2024-01-11 16:27:03 +00:00
|
|
|
let _ = Issue12068.as_ref().split('a').next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_string`
|
2023-12-28 18:33:07 +00:00
|
|
|
|
|
|
|
let _ = [1].split(|x| *x == 2).next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_vec`
|
|
|
|
let _ = [1].split(|x| *x == 2).next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_vec`
|
|
|
|
let _ = [1].split(|x| *x == 2).next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_owned`
|
|
|
|
let _ = [1].split(|x| *x == 2).next().unwrap();
|
|
|
|
//~^ ERROR: unnecessary use of `to_owned`
|
|
|
|
}
|