1 #![warn(clippy::len_without_is_empty)]
2 #![allow(dead_code, unused)]
7 pub fn len(self: &Self) -> isize {
13 // A second impl for this struct -- the error span shouldn't mention this.
14 pub fn irrelevant(self: &Self) -> bool {
19 // Identical to `PubOne`, but with an `allow` attribute on the impl complaining `len`.
20 pub struct PubAllowed;
22 #[allow(clippy::len_without_is_empty)]
24 pub fn len(self: &Self) -> isize {
29 // No `allow` attribute on this impl block, but that doesn't matter -- we only require one on the
30 // impl containing `len`.
32 pub fn irrelevant(self: &Self) -> bool {
37 pub trait PubTraitsToo {
38 fn len(self: &Self) -> isize;
41 impl PubTraitsToo for One {
42 fn len(self: &Self) -> isize {
47 pub struct HasIsEmpty;
50 pub fn len(self: &Self) -> isize {
54 fn is_empty(self: &Self) -> bool {
59 pub struct HasWrongIsEmpty;
61 impl HasWrongIsEmpty {
62 pub fn len(self: &Self) -> isize {
66 pub fn is_empty(self: &Self, x: u32) -> bool {
74 pub fn len(self: &Self) -> isize {
75 // No error; `len` is pub but `NotPubOne` is not exported anyway.
83 fn len(self: &Self) -> isize {
84 // No error; `len` is private; see issue #1085.
90 fn len(self: &Self) -> isize;
91 // No error; `len` is private; see issue #1085.
94 impl TraitsToo for One {
95 fn len(self: &Self) -> isize {
100 struct HasPrivateIsEmpty;
102 impl HasPrivateIsEmpty {
103 pub fn len(self: &Self) -> isize {
107 fn is_empty(self: &Self) -> bool {
114 pub trait WithIsEmpty {
115 fn len(self: &Self) -> isize;
116 fn is_empty(self: &Self) -> bool;
119 impl WithIsEmpty for Wither {
120 fn len(self: &Self) -> isize {
124 fn is_empty(self: &Self) -> bool {
130 fn is_empty(&self) -> bool;
133 pub trait InheritingEmpty: Empty {
134 // Must not trigger `LEN_WITHOUT_IS_EMPTY`.
135 fn len(&self) -> isize;
139 pub trait Foo: Sized {}
141 pub trait DependsOnFoo: Foo {
142 fn len(&mut self) -> usize;