Skip to content

Commit 89713fc

Browse files
committed
Mention Range when Step trait bound is unmet
1 parent cafe917 commit 89713fc

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

library/core/src/iter/range.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ unsafe_impl_trusted_step![AsciiChar char i8 i16 i32 i64 i128 isize u8 u16 u32 u6
2121
/// The *successor* operation moves towards values that compare greater.
2222
/// The *predecessor* operation moves towards values that compare lesser.
2323
#[rustc_diagnostic_item = "range_step"]
24+
#[rustc_on_unimplemented(
25+
note = "`Range` only implements `Iterator` for select types in the standard library, \
26+
particularly integers; to see the full list of types, see the documentation for the \
27+
unstable `Step` trait"
28+
)]
2429
#[unstable(feature = "step_trait", issue = "42168")]
2530
pub trait Step: Clone + PartialOrd + Sized {
2631
/// Returns the bounds on the number of *successor* steps required to get from `start` to `end`

tests/ui/range/range-1.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ error[E0277]: the trait bound `bool: Step` is not satisfied
1010
LL | for i in false..true {}
1111
| ^^^^^^^^^^^ the nightly-only, unstable trait `Step` is not implemented for `bool`
1212
|
13+
= note: `Range` only implements `Iterator` for select types in the standard library, particularly integers; to see the full list of types, see the documentation for the unstable `Step` trait
1314
= note: required for `std::ops::Range<bool>` to implement `Iterator`
1415
= note: required for `std::ops::Range<bool>` to implement `IntoIterator`
1516

tests/ui/trait-bounds/unstable-trait-suggestion.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error[E0277]: the trait bound `T: Step` is not satisfied
2222
LL | for _ in t {}
2323
| ^ the nightly-only, unstable trait `Step` is not implemented for `T`
2424
|
25+
= note: `Range` only implements `Iterator` for select types in the standard library, particularly integers; to see the full list of types, see the documentation for the unstable `Step` trait
2526
= note: required for `std::ops::Range<T>` to implement `Iterator`
2627
= note: required for `std::ops::Range<T>` to implement `IntoIterator`
2728
help: consider restricting type parameter `T` with unstable trait `Step`

0 commit comments

Comments
 (0)