6 #[deny(len_without_is_empty)]
8 fn len(self: &Self) -> isize { //~ERROR Item 'One' has a '.len(_: &Self)'
13 #[deny(len_without_is_empty)]
15 fn len(self: &Self) -> isize; //~ERROR Trait 'TraitsToo' has a '.len(_:
18 impl TraitsToo for One {
19 fn len(self: &Self) -> isize {
26 #[deny(len_without_is_empty)]
28 fn len(self: &Self) -> isize {
32 fn is_empty(self: &Self) -> bool {
39 #[deny(len_without_is_empty)]
41 fn len(self: &Self) -> isize;
42 fn is_empty(self: &Self) -> bool;
45 impl WithIsEmpty for Wither {
46 fn len(self: &Self) -> isize {
50 fn is_empty(self: &Self) -> bool {
55 struct HasWrongIsEmpty;
57 #[deny(len_without_is_empty)]
58 impl HasWrongIsEmpty {
59 fn len(self: &Self) -> isize { //~ERROR Item 'HasWrongIsEmpty' has a '.len(_: &Self)'
63 #[allow(dead_code, unused)]
64 fn is_empty(self: &Self, x : u32) -> bool {
72 if x.len() == 0 { //~ERROR Consider replacing the len comparison
73 println!("This should not happen!");
77 if y.len() == 0 { //no error because One does not have .is_empty()
78 println!("This should not happen either!");
81 let z : &TraitsToo = &y;
82 if z.len() > 0 { //no error, because TraitsToo has no .is_empty() method
83 println!("Nor should this!");
87 if hie.len() == 0 { //~ERROR Consider replacing the len comparison
90 assert!(!hie.is_empty());
92 let wie : &WithIsEmpty = &Wither;
93 if wie.len() == 0 { //~ERROR Consider replacing the len comparison
96 assert!(!wie.is_empty());
98 let hwie = HasWrongIsEmpty;
99 if hwie.len() == 0 { //no error as HasWrongIsEmpty does not have .is_empty()
100 println!("Or this!");