]> git.lizzy.rs Git - rust.git/blob - tests/ui/iter_not_returning_iterator.rs
Auto merge of #8359 - flip1995:rustup, r=flip1995
[rust.git] / tests / ui / iter_not_returning_iterator.rs
1 #![warn(clippy::iter_not_returning_iterator)]
2
3 struct Data {
4     begin: u32,
5 }
6
7 struct Counter {
8     count: u32,
9 }
10
11 impl Data {
12     fn iter(&self) -> Counter {
13         todo!()
14     }
15
16     fn iter_mut(&self) -> Counter {
17         todo!()
18     }
19 }
20
21 struct Data2 {
22     begin: u32,
23 }
24
25 struct Counter2 {
26     count: u32,
27 }
28
29 impl Data2 {
30     fn iter(&self) -> Counter2 {
31         todo!()
32     }
33
34     fn iter_mut(&self) -> Counter2 {
35         todo!()
36     }
37 }
38
39 impl Iterator for Counter {
40     type Item = u32;
41
42     fn next(&mut self) -> Option<Self::Item> {
43         todo!()
44     }
45 }
46
47 // Issue #8225
48 trait Iter {
49     type I;
50     fn iter(&self) -> Self::I;
51 }
52
53 impl Iter for () {
54     type I = core::slice::Iter<'static, ()>;
55     fn iter(&self) -> Self::I {
56         [].iter()
57     }
58 }
59
60 struct S;
61 impl S {
62     fn iter(&self) -> <() as Iter>::I {
63         ().iter()
64     }
65 }
66
67 struct S2([u8]);
68 impl S2 {
69     fn iter(&self) -> core::slice::Iter<u8> {
70         self.0.iter()
71     }
72 }
73
74 fn main() {}