Skip to content

Commit c71228e

Browse files
committed
review comments
- reword messages - apply custom comments to all types of ranges - fix indentation
1 parent a0fd68b commit c71228e

File tree

7 files changed

+46
-22
lines changed

7 files changed

+46
-22
lines changed

src/libcore/iter/iterator.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,32 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
3333
on(
3434
_Self="[std::ops::Range<Idx>; 1]",
3535
label="if you meant to iterate between two values, remove the square brackets",
36-
note="`[start..end]` is an array of one `Range`, you might have meant to have a `Range`: \
37-
`start..end`"
36+
note="`[start..end]` is an array of one `Range`; you might have meant to have a `Range` \
37+
without the brackets: `start..end`"
38+
),
39+
on(
40+
_Self="[std::ops::RangeFrom<Idx>; 1]",
41+
label="if you meant to iterate from a value onwards, remove the square brackets",
42+
note="`[start..]` is an array of one `RangeFrom`; you might have meant to have a \
43+
`RangeFrom` without the brackets: `start..`"
44+
),
45+
on(
46+
_Self="[std::ops::RangeTo<Idx>; 1]",
47+
label="if you meant to iterate until a value, remove the square brackets",
48+
note="`[..end]` is an array of one `RangeTo`; you might have meant to have a \
49+
`RangeTo` without the brackets: `..end`"
50+
),
51+
on(
52+
_Self="[std::ops::RangeInclusive<Idx>; 1]",
53+
label="if you meant to iterate between two values, remove the square brackets",
54+
note="`[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a \
55+
`RangeInclusive` without the brackets: `start..=end`"
56+
),
57+
on(
58+
_Self="[std::ops::RangeToInclusive<Idx>; 1]",
59+
label="if you meant to iterate until a value, remove the square brackets",
60+
note="`[..=end]` is an array of one `RangeToInclusive`; you might have meant to have a \
61+
`RangeToInclusive` without the brackets: `..=end`"
3862
),
3963
on(
4064
_Self="&str",
@@ -51,8 +75,8 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
5175
),
5276
on(
5377
_Self="{integral}",
54-
note="if you want to iterate between `0` until a value `end`, use the range syntax: \
55-
`0..end`"
78+
note="if you want to iterate between `start` until a value `end`, use the exclusive range \
79+
syntax `start..end` or the inclusive range syntax `start..=end`"
5680
),
5781
label="`{Self}` is not an iterator",
5882
message="`{Self}` is not an iterator"

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
351351
trait_ref: ty::PolyTraitRef<'tcx>,
352352
obligation: &PredicateObligation<'tcx>,
353353
) -> OnUnimplementedNote {
354-
let def_id = self.impl_similar_to(trait_ref, obligation)
354+
let def_id = self.impl_similar_to(trait_ref, obligation)
355355
.unwrap_or(trait_ref.def_id());
356356
let trait_ref = *trait_ref.skip_binder();
357357

src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ LL | | }
8484
| |_^ `i32` is not an iterator
8585
|
8686
= help: the trait `std::iter::Iterator` is not implemented for `i32`
87-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
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`
8888
= help: see issue #48214
8989
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
9090

src/test/ui/issues/issue-50480.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
1111
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator
1212
|
1313
= help: the trait `std::iter::Iterator` is not implemented for `i32`
14-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
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`
1515

1616
error[E0204]: the trait `Copy` may not be implemented for this type
1717
--> $DIR/issue-50480.rs:11:17

src/test/ui/iterators/array-of-ranges.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | for _ in [0..1] {}
55
| ^^^^^^ if you meant to iterate between two values, remove the square brackets
66
|
77
= help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
8-
= note: `[start..end]` is an array of one `Range`, you might have meant to have a `Range`: `start..end`
8+
= note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
99
= note: required by `std::iter::IntoIterator::into_iter`
1010

1111
error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator
@@ -15,7 +15,7 @@ LL | for _ in [start..end] {}
1515
| ^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets
1616
|
1717
= help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
18-
= note: `[start..end]` is an array of one `Range`, you might have meant to have a `Range`: `start..end`
18+
= note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
1919
= note: required by `std::iter::IntoIterator::into_iter`
2020

2121
error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator
@@ -25,7 +25,7 @@ LL | for _ in array_of_range {}
2525
| ^^^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets
2626
|
2727
= help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
28-
= note: `[start..end]` is an array of one `Range`, you might have meant to have a `Range`: `start..end`
28+
= note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
2929
= note: required by `std::iter::IntoIterator::into_iter`
3030

3131
error[E0277]: `[std::ops::Range<{integer}>; 2]` is not an iterator

src/test/ui/iterators/bound.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | struct T(S<u8>);
55
| ^^^^^ `u8` is not an iterator
66
|
77
= help: the trait `std::iter::Iterator` is not implemented for `u8`
8-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
8+
= 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`
99
note: required by `S`
1010
--> $DIR/bound.rs:1:1
1111
|

src/test/ui/iterators/integral.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | for _ in 42 {}
55
| ^^ `{integer}` is not an iterator
66
|
77
= help: the trait `std::iter::Iterator` is not implemented for `{integer}`
8-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
8+
= 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`
99
= note: required by `std::iter::IntoIterator::into_iter`
1010

1111
error[E0277]: `u8` is not an iterator
@@ -15,7 +15,7 @@ LL | for _ in 42 as u8 {}
1515
| ^^^^^^^^ `u8` is not an iterator
1616
|
1717
= help: the trait `std::iter::Iterator` is not implemented for `u8`
18-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
18+
= 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`
1919
= note: required by `std::iter::IntoIterator::into_iter`
2020

2121
error[E0277]: `i8` is not an iterator
@@ -25,7 +25,7 @@ LL | for _ in 42 as i8 {}
2525
| ^^^^^^^^ `i8` is not an iterator
2626
|
2727
= help: the trait `std::iter::Iterator` is not implemented for `i8`
28-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
28+
= 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`
2929
= note: required by `std::iter::IntoIterator::into_iter`
3030

3131
error[E0277]: `u16` is not an iterator
@@ -35,7 +35,7 @@ LL | for _ in 42 as u16 {}
3535
| ^^^^^^^^^ `u16` is not an iterator
3636
|
3737
= help: the trait `std::iter::Iterator` is not implemented for `u16`
38-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
38+
= 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`
3939
= note: required by `std::iter::IntoIterator::into_iter`
4040

4141
error[E0277]: `i16` is not an iterator
@@ -45,7 +45,7 @@ LL | for _ in 42 as i16 {}
4545
| ^^^^^^^^^ `i16` is not an iterator
4646
|
4747
= help: the trait `std::iter::Iterator` is not implemented for `i16`
48-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
48+
= 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`
4949
= note: required by `std::iter::IntoIterator::into_iter`
5050

5151
error[E0277]: `u32` is not an iterator
@@ -55,7 +55,7 @@ LL | for _ in 42 as u32 {}
5555
| ^^^^^^^^^ `u32` is not an iterator
5656
|
5757
= help: the trait `std::iter::Iterator` is not implemented for `u32`
58-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
58+
= 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`
5959
= note: required by `std::iter::IntoIterator::into_iter`
6060

6161
error[E0277]: `i32` is not an iterator
@@ -65,7 +65,7 @@ LL | for _ in 42 as i32 {}
6565
| ^^^^^^^^^ `i32` is not an iterator
6666
|
6767
= help: the trait `std::iter::Iterator` is not implemented for `i32`
68-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
68+
= 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`
6969
= note: required by `std::iter::IntoIterator::into_iter`
7070

7171
error[E0277]: `u64` is not an iterator
@@ -75,7 +75,7 @@ LL | for _ in 42 as u64 {}
7575
| ^^^^^^^^^ `u64` is not an iterator
7676
|
7777
= help: the trait `std::iter::Iterator` is not implemented for `u64`
78-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
78+
= 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`
7979
= note: required by `std::iter::IntoIterator::into_iter`
8080

8181
error[E0277]: `i64` is not an iterator
@@ -85,7 +85,7 @@ LL | for _ in 42 as i64 {}
8585
| ^^^^^^^^^ `i64` is not an iterator
8686
|
8787
= help: the trait `std::iter::Iterator` is not implemented for `i64`
88-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
88+
= 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`
8989
= note: required by `std::iter::IntoIterator::into_iter`
9090

9191
error[E0277]: `usize` is not an iterator
@@ -95,7 +95,7 @@ LL | for _ in 42 as usize {}
9595
| ^^^^^^^^^^^ `usize` is not an iterator
9696
|
9797
= help: the trait `std::iter::Iterator` is not implemented for `usize`
98-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
98+
= 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`
9999
= note: required by `std::iter::IntoIterator::into_iter`
100100

101101
error[E0277]: `isize` is not an iterator
@@ -105,7 +105,7 @@ LL | for _ in 42 as isize {}
105105
| ^^^^^^^^^^^ `isize` is not an iterator
106106
|
107107
= help: the trait `std::iter::Iterator` is not implemented for `isize`
108-
= note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end`
108+
= 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`
109109
= note: required by `std::iter::IntoIterator::into_iter`
110110

111111
error[E0277]: `{float}` is not an iterator

0 commit comments

Comments
 (0)