File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ deny( while_let_on_iterator) ]
2
+
3
+ use std:: iter:: Iterator ;
4
+
5
+ struct Foo ;
6
+
7
+ impl Foo {
8
+ fn foo1 < I : Iterator < Item = usize > > ( mut it : I ) {
9
+ while let Some ( _) = it. next ( ) {
10
+ println ! ( "{:?}" , it. size_hint( ) ) ;
11
+ }
12
+ }
13
+
14
+ fn foo2 < I : Iterator < Item = usize > > ( mut it : I ) {
15
+ while let Some ( e) = it. next ( ) {
16
+ println ! ( "{:?}" , e) ;
17
+ }
18
+ }
19
+ }
20
+
21
+ fn main ( ) {
22
+ Foo :: foo1 ( vec ! [ ] . into_iter ( ) ) ;
23
+ Foo :: foo2 ( vec ! [ ] . into_iter ( ) ) ;
24
+ }
Original file line number Diff line number Diff line change
1
+ error: this loop could be written as a `for` loop
2
+ --> $DIR/issue_2356.rs:15:29
3
+ |
4
+ 15 | while let Some(e) = it.next() {
5
+ | ^^^^^^^^^ help: try: `for e in it { .. }`
6
+ |
7
+ note: lint level defined here
8
+ --> $DIR/issue_2356.rs:1:9
9
+ |
10
+ 1 | #![deny(while_let_on_iterator)]
11
+ | ^^^^^^^^^^^^^^^^^^^^^
12
+
13
+ error: aborting due to previous error
14
+
You can’t perform that action at this time.
0 commit comments