1 #![allow(dead_code, unused_variables, clippy::return_self_not_must_use)] 2 3 /// Utility macro to test linting behavior in `option_methods()` 4 /// The lints included in `option_methods()` should not lint if the call to map is partially 5 /// within a macro 6 #[macro_export] 7 macro_rules! opt_map { 8 ($opt:expr, $map:expr) => { 9 ($opt).map($map) 10 }; 11 } 12 13 /// Struct to generate false positive for Iterator-based lints 14 #[derive(Copy, Clone)] 15 pub struct IteratorFalsePositives { 16 pub foo: u32, 17 } 18 19 impl IteratorFalsePositives { filter(self) -> IteratorFalsePositives20 pub fn filter(self) -> IteratorFalsePositives { 21 self 22 } 23 next(self) -> IteratorFalsePositives24 pub fn next(self) -> IteratorFalsePositives { 25 self 26 } 27 find(self) -> Option<u32>28 pub fn find(self) -> Option<u32> { 29 Some(self.foo) 30 } 31 position(self) -> Option<u32>32 pub fn position(self) -> Option<u32> { 33 Some(self.foo) 34 } 35 rposition(self) -> Option<u32>36 pub fn rposition(self) -> Option<u32> { 37 Some(self.foo) 38 } 39 nth(self, n: usize) -> Option<u32>40 pub fn nth(self, n: usize) -> Option<u32> { 41 Some(self.foo) 42 } 43 skip(self, _: usize) -> IteratorFalsePositives44 pub fn skip(self, _: usize) -> IteratorFalsePositives { 45 self 46 } 47 skip_while(self) -> IteratorFalsePositives48 pub fn skip_while(self) -> IteratorFalsePositives { 49 self 50 } 51 count(self) -> usize52 pub fn count(self) -> usize { 53 self.foo as usize 54 } 55 } 56 57 #[derive(Copy, Clone)] 58 pub struct IteratorMethodFalsePositives; 59 60 impl IteratorMethodFalsePositives { filter(&self, _s: i32) -> std::vec::IntoIter<i32>61 pub fn filter(&self, _s: i32) -> std::vec::IntoIter<i32> { 62 unimplemented!(); 63 } 64 } 65