about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/len_without_is_empty_expect.rs
blob: 9d1245e2d02ad77ad69b1fa10c7bc35cb82e7a84 (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
//@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() {}