1 #![warn(clippy::len_without_is_empty)]
2 #![allow(dead_code, unused)]
7 pub fn len(&self) -> isize {
13 // A second impl for this struct -- the error span shouldn't mention this.
14 pub fn irrelevant(&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) -> 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) -> bool {
37 pub struct PubAllowedFn;
40 #[allow(clippy::len_without_is_empty)]
41 pub fn len(&self) -> isize {
46 #[allow(clippy::len_without_is_empty)]
47 pub struct PubAllowedStruct;
49 impl PubAllowedStruct {
50 pub fn len(&self) -> isize {
55 pub trait PubTraitsToo {
56 fn len(&self) -> isize;
59 impl PubTraitsToo for One {
60 fn len(&self) -> isize {
65 pub struct HasIsEmpty;
68 pub fn len(&self) -> isize {
72 fn is_empty(&self) -> bool {
77 pub struct HasWrongIsEmpty;
79 impl HasWrongIsEmpty {
80 pub fn len(&self) -> isize {
84 pub fn is_empty(&self, x: u32) -> bool {
89 pub struct MismatchedSelf;
92 pub fn len(self) -> isize {
96 pub fn is_empty(&self) -> bool {
104 pub fn len(&self) -> isize {
105 // No error; `len` is pub but `NotPubOne` is not exported anyway.
113 fn len(&self) -> isize {
114 // No error; `len` is private; see issue #1085.
120 fn len(&self) -> isize;
121 // No error; `len` is private; see issue #1085.
124 impl TraitsToo for One {
125 fn len(&self) -> isize {
130 struct HasPrivateIsEmpty;
132 impl HasPrivateIsEmpty {
133 pub fn len(&self) -> isize {
137 fn is_empty(&self) -> bool {
144 pub trait WithIsEmpty {
145 fn len(&self) -> isize;
146 fn is_empty(&self) -> bool;
149 impl WithIsEmpty for Wither {
150 fn len(&self) -> isize {
154 fn is_empty(&self) -> bool {
160 fn is_empty(&self) -> bool;
163 pub trait InheritingEmpty: Empty {
164 // Must not trigger `LEN_WITHOUT_IS_EMPTY`.
165 fn len(&self) -> isize;
169 pub trait Foo: Sized {}
171 pub trait DependsOnFoo: Foo {
172 fn len(&mut self) -> usize;
175 pub struct MultipleImpls;
179 pub fn len(&self) -> usize {
185 pub fn is_empty(&self) -> bool {