rust/tests/ui/len_without_is_empty_expect.rs
2025-04-22 18:24:43 +02:00

28 lines
596 B
Rust

//@no-rustfix
#![allow(clippy::len_without_is_empty)]
// Check that the lint expectation is fulfilled even if the lint is allowed at the type level.
pub struct Empty;
impl Empty {
#[expect(clippy::len_without_is_empty)]
pub fn len(&self) -> usize {
0
}
}
// Check that the lint expectation is not triggered if it should not
pub struct Empty2;
impl Empty2 {
#[expect(clippy::len_without_is_empty)] //~ ERROR: this lint expectation is unfulfilled
pub fn len(&self) -> usize {
0
}
pub fn is_empty(&self) -> bool {
false
}
}
fn main() {}