2024-05-17 16:05:46 +00:00
|
|
|
#![warn(clippy::needless_character_iteration)]
|
|
|
|
#![allow(clippy::map_identity, clippy::unnecessary_operation)]
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
struct S {
|
|
|
|
field: &'static str,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
fn field(&self) -> &str {
|
|
|
|
self.field
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn magic(_: char) {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
"foo".is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
!"foo".is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
"foo".is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
!"foo".is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
|
|
|
|
let s = String::new();
|
|
|
|
s.is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
!"foo".to_string().is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
|
|
|
|
"foo".is_ascii();
|
|
|
|
!"foo".is_ascii();
|
|
|
|
|
|
|
|
S::default().field().is_ascii();
|
|
|
|
//~^ ERROR: checking if a string is ascii using iterators
|
|
|
|
|
|
|
|
// Should not lint!
|
|
|
|
"foo".chars().all(|c| {
|
|
|
|
let x = c;
|
|
|
|
magic(x);
|
|
|
|
x.is_ascii()
|
|
|
|
});
|
|
|
|
|
|
|
|
// Should not lint!
|
|
|
|
"foo".chars().all(|c| c.is_ascii() && c.is_alphabetic());
|
|
|
|
|
|
|
|
// Should not lint!
|
|
|
|
"foo".chars().map(|c| c).all(|c| !char::is_ascii(&c));
|
2024-06-03 19:57:47 +00:00
|
|
|
|
|
|
|
// Should not lint!
|
|
|
|
"foo".chars().all(|c| !c.is_ascii());
|
|
|
|
|
|
|
|
// Should not lint!
|
|
|
|
"foo".chars().any(|c| c.is_ascii());
|
2024-05-17 16:05:46 +00:00
|
|
|
}
|