From c71228e2f4d6ea82c9538391454801baa7946bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 11 Oct 2018 12:11:23 -0700 Subject: [PATCH] review comments - reword messages - apply custom comments to all types of ranges - fix indentation --- src/libcore/iter/iterator.rs | 32 ++++++++++++++++--- src/librustc/traits/error_reporting.rs | 2 +- .../feature-gate-trivial_bounds.stderr | 2 +- src/test/ui/issues/issue-50480.stderr | 2 +- src/test/ui/iterators/array-of-ranges.stderr | 6 ++-- src/test/ui/iterators/bound.stderr | 2 +- src/test/ui/iterators/integral.stderr | 22 ++++++------- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 9e68ab92882..ff1bd71bd55 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -33,8 +33,32 @@ fn _assert_is_object_safe(_: &dyn Iterator) {} on( _Self="[std::ops::Range; 1]", label="if you meant to iterate between two values, remove the square brackets", - note="`[start..end]` is an array of one `Range`, you might have meant to have a `Range`: \ - `start..end`" + note="`[start..end]` is an array of one `Range`; you might have meant to have a `Range` \ + without the brackets: `start..end`" + ), + on( + _Self="[std::ops::RangeFrom; 1]", + label="if you meant to iterate from a value onwards, remove the square brackets", + note="`[start..]` is an array of one `RangeFrom`; you might have meant to have a \ + `RangeFrom` without the brackets: `start..`" + ), + on( + _Self="[std::ops::RangeTo; 1]", + label="if you meant to iterate until a value, remove the square brackets", + note="`[..end]` is an array of one `RangeTo`; you might have meant to have a \ + `RangeTo` without the brackets: `..end`" + ), + on( + _Self="[std::ops::RangeInclusive; 1]", + label="if you meant to iterate between two values, remove the square brackets", + note="`[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a \ + `RangeInclusive` without the brackets: `start..=end`" + ), + on( + _Self="[std::ops::RangeToInclusive; 1]", + label="if you meant to iterate until a value, remove the square brackets", + note="`[..=end]` is an array of one `RangeToInclusive`; you might have meant to have a \ + `RangeToInclusive` without the brackets: `..=end`" ), on( _Self="&str", @@ -51,8 +75,8 @@ fn _assert_is_object_safe(_: &dyn Iterator) {} ), on( _Self="{integral}", - note="if you want to iterate between `0` until a value `end`, use the range syntax: \ - `0..end`" + 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`" ), label="`{Self}` is not an iterator", message="`{Self}` is not an iterator" diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index a7ebd0c8965..8288a45ad63 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -351,7 +351,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trait_ref: ty::PolyTraitRef<'tcx>, obligation: &PredicateObligation<'tcx>, ) -> OnUnimplementedNote { - let def_id = self.impl_similar_to(trait_ref, obligation) + let def_id = self.impl_similar_to(trait_ref, obligation) .unwrap_or(trait_ref.def_id()); let trait_ref = *trait_ref.skip_binder(); diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index a37980d0d51..14764b4e9f0 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -84,7 +84,7 @@ LL | | } | |_^ `i32` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i32` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable diff --git a/src/test/ui/issues/issue-50480.stderr b/src/test/ui/issues/issue-50480.stderr index 672484f401a..cbff927ac74 100644 --- a/src/test/ui/issues/issue-50480.stderr +++ b/src/test/ui/issues/issue-50480.stderr @@ -11,7 +11,7 @@ LL | struct Foo(NotDefined, ::Item, Vec, String); | ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i32` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` error[E0204]: the trait `Copy` may not be implemented for this type --> $DIR/issue-50480.rs:11:17 diff --git a/src/test/ui/iterators/array-of-ranges.stderr b/src/test/ui/iterators/array-of-ranges.stderr index 95839ebc53a..073baab67b2 100644 --- a/src/test/ui/iterators/array-of-ranges.stderr +++ b/src/test/ui/iterators/array-of-ranges.stderr @@ -5,7 +5,7 @@ LL | for _ in [0..1] {} | ^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` - = note: `[start..end]` is an array of one `Range`, you might have meant to have a `Range`: `start..end` + = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator @@ -15,7 +15,7 @@ LL | for _ in [start..end] {} | ^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` - = note: `[start..end]` is an array of one `Range`, you might have meant to have a `Range`: `start..end` + = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator @@ -25,7 +25,7 @@ LL | for _ in array_of_range {} | ^^^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` - = note: `[start..end]` is an array of one `Range`, you might have meant to have a `Range`: `start..end` + = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `[std::ops::Range<{integer}>; 2]` is not an iterator diff --git a/src/test/ui/iterators/bound.stderr b/src/test/ui/iterators/bound.stderr index 2ddbd93c83c..14057387c4f 100644 --- a/src/test/ui/iterators/bound.stderr +++ b/src/test/ui/iterators/bound.stderr @@ -5,7 +5,7 @@ LL | struct T(S); | ^^^^^ `u8` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `u8` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` note: required by `S` --> $DIR/bound.rs:1:1 | diff --git a/src/test/ui/iterators/integral.stderr b/src/test/ui/iterators/integral.stderr index 3662d97d72e..71e1e81e5af 100644 --- a/src/test/ui/iterators/integral.stderr +++ b/src/test/ui/iterators/integral.stderr @@ -5,7 +5,7 @@ LL | for _ in 42 {} | ^^ `{integer}` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `{integer}` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `u8` is not an iterator @@ -15,7 +15,7 @@ LL | for _ in 42 as u8 {} | ^^^^^^^^ `u8` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `u8` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `i8` is not an iterator @@ -25,7 +25,7 @@ LL | for _ in 42 as i8 {} | ^^^^^^^^ `i8` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i8` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `u16` is not an iterator @@ -35,7 +35,7 @@ LL | for _ in 42 as u16 {} | ^^^^^^^^^ `u16` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `u16` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `i16` is not an iterator @@ -45,7 +45,7 @@ LL | for _ in 42 as i16 {} | ^^^^^^^^^ `i16` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i16` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `u32` is not an iterator @@ -55,7 +55,7 @@ LL | for _ in 42 as u32 {} | ^^^^^^^^^ `u32` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `u32` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `i32` is not an iterator @@ -65,7 +65,7 @@ LL | for _ in 42 as i32 {} | ^^^^^^^^^ `i32` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i32` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `u64` is not an iterator @@ -75,7 +75,7 @@ LL | for _ in 42 as u64 {} | ^^^^^^^^^ `u64` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `u64` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `i64` is not an iterator @@ -85,7 +85,7 @@ LL | for _ in 42 as i64 {} | ^^^^^^^^^ `i64` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i64` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `usize` is not an iterator @@ -95,7 +95,7 @@ LL | for _ in 42 as usize {} | ^^^^^^^^^^^ `usize` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `usize` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `isize` is not an iterator @@ -105,7 +105,7 @@ LL | for _ in 42 as isize {} | ^^^^^^^^^^^ `isize` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `isize` - = note: if you want to iterate between `0` until a value `end`, use the range syntax: `0..end` + = 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` = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `{float}` is not an iterator