Skip to content

Commit 660ab62

Browse files
committed
Be more lax in .into_iter() suggestion when encountering Iterator methods on non-Iterator
``` error[E0599]: no method named `map` found for struct `Vec<bool>` in the current scope --> $DIR/vec-on-unimplemented.rs:3:23 | LL | vec![true, false].map(|v| !v).collect::<Vec<_>>(); | ^^^ `Vec<bool>` is not an iterator | help: call `.into_iter()` first | LL | vec![true, false].into_iter().map(|v| !v).collect::<Vec<_>>(); | ++++++++++++ ``` We used to provide some help through `rustc_on_unimplemented` on non-`impl Trait` and non-type-params, but this lets us get rid of some otherwise unnecessary conditions in the annotation on `Iterator`.
1 parent e2361fb commit 660ab62

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

core/src/iter/traits/iterator.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
3434
_Self = "core::ops::range::RangeToInclusive<Idx>",
3535
note = "you might have meant to use a bounded `RangeInclusive`"
3636
),
37-
on(
38-
_Self = "[]",
39-
label = "`{Self}` is not an iterator; try calling `.into_iter()` or `.iter()`"
40-
),
41-
on(_Self = "&[]", label = "`{Self}` is not an iterator; try calling `.iter()`"),
42-
on(
43-
_Self = "alloc::vec::Vec<T, A>",
44-
label = "`{Self}` is not an iterator; try calling `.into_iter()` or `.iter()`"
45-
),
4637
label = "`{Self}` is not an iterator",
4738
message = "`{Self}` is not an iterator"
4839
)]

0 commit comments

Comments
 (0)