You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #54946 - estebank:iterator, r=varkor
Add filtering option to `rustc_on_unimplemented` and reword `Iterator` E0277 errors
- Add more targetting filters for arrays to `rustc_on_unimplemented` (Fix#53766)
- Detect one element array of `Range` type, which is potentially a typo:
`for _ in [0..10] {}` where iterating between `0` and `10` was intended.
(Fix#23141)
- Suggest `.bytes()` and `.chars()` for `String`.
- Suggest borrowing or `.iter()` on arrays (Fix#36391)
- Suggest using range literal when iterating on integers (Fix#34353)
- Do not suggest `.iter()` by default (Fix#50773, fix#46806)
- Add regression test (Fix#22872)
| |_^ `i32` is not an iterator; maybe try calling `.iter()` or a similar method
84
+
| |_^ `i32` is not an iterator
85
85
|
86
86
= help: the trait `std::iter::Iterator` is not implemented for `i32`
87
+
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
87
88
= help: see issue #48214
88
89
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
Copy file name to clipboardexpand all lines: src/test/ui/issues/issue-50480.stderr
+3-2
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,14 @@ error[E0412]: cannot find type `NotDefined` in this scope
4
4
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
5
5
| ^^^^^^^^^^ not found in this scope
6
6
7
-
error[E0277]: the trait bound `i32: std::iter::Iterator` is not satisfied
7
+
error[E0277]: `i32` is not an iterator
8
8
--> $DIR/issue-50480.rs:13:24
9
9
|
10
10
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
11
-
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator; maybe try calling `.iter()` or a similar method
11
+
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator
12
12
|
13
13
= help: the trait `std::iter::Iterator` is not implemented for `i32`
14
+
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
14
15
15
16
error[E0204]: the trait `Copy` may not be implemented for this type
0 commit comments