diff options
| author | Dan Aloni <alonid@gmail.com> | 2020-09-02 10:40:56 +0300 |
|---|---|---|
| committer | Dan Aloni <alonid@gmail.com> | 2020-09-02 22:26:37 +0300 |
| commit | 07e7823c01be1733df2480de19fbbe6b8e9384cf (patch) | |
| tree | 9e4ff1075680201f9c72b58bf780638ef1fcede3 /src/test/ui/iterators | |
| parent | 7b2deb562822112cc30d23958e7459564e2c6ef9 (diff) | |
| download | rust-07e7823c01be1733df2480de19fbbe6b8e9384cf.tar.gz rust-07e7823c01be1733df2480de19fbbe6b8e9384cf.zip | |
pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
Diffstat (limited to 'src/test/ui/iterators')
| -rw-r--r-- | src/test/ui/iterators/array-of-ranges.stderr | 66 | ||||
| -rw-r--r-- | src/test/ui/iterators/array.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/iterators/bound.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/iterators/integral.stderr | 48 | ||||
| -rw-r--r-- | src/test/ui/iterators/ranges.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/iterators/string.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/iterators/string.stderr | 12 |
7 files changed, 79 insertions, 81 deletions
diff --git a/src/test/ui/iterators/array-of-ranges.stderr b/src/test/ui/iterators/array-of-ranges.stderr index 3dbed9a1065..6271d8107bc 100644 --- a/src/test/ui/iterators/array-of-ranges.stderr +++ b/src/test/ui/iterators/array-of-ranges.stderr @@ -4,49 +4,49 @@ error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator 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]` + = help: the trait `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` without the brackets: `start..end` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` -error[E0277]: `[std::ops::RangeInclusive<{integer}>; 1]` is not an iterator +error[E0277]: `[RangeInclusive<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:4:14 | LL | for _ in [0..=1] {} - | ^^^^^^^ if you meant to iterate between two values, remove the square brackets + | ^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeInclusive<{integer}>; 1]` - = note: `[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a `RangeInclusive` without the brackets: `start..=end` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `[RangeInclusive<{integer}>; 1]` + = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `into_iter` -error[E0277]: `[std::ops::RangeFrom<{integer}>; 1]` is not an iterator +error[E0277]: `[RangeFrom<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:6:14 | LL | for _ in [0..] {} - | ^^^^^ if you meant to iterate from a value onwards, remove the square brackets + | ^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeFrom<{integer}>; 1]` - = note: `[start..]` is an array of one `RangeFrom`; you might have meant to have a `RangeFrom` without the brackets: `start..`, keeping in mind that iterating over an unbounded iterator will run forever unless you `break` or `return` from within the loop - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `[RangeFrom<{integer}>; 1]` + = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `into_iter` -error[E0277]: `[std::ops::RangeTo<{integer}>; 1]` is not an iterator +error[E0277]: `[RangeTo<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:8:14 | LL | for _ in [..1] {} - | ^^^^^ if you meant to iterate until a value, remove the square brackets and add a starting value + | ^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeTo<{integer}>; 1]` - = note: `[..end]` is an array of one `RangeTo`; you might have meant to have a bounded `Range` without the brackets: `0..end` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `[RangeTo<{integer}>; 1]` + = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `into_iter` -error[E0277]: `[std::ops::RangeToInclusive<{integer}>; 1]` is not an iterator +error[E0277]: `[RangeToInclusive<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:10:14 | LL | for _ in [..=1] {} - | ^^^^^^ if you meant to iterate until a value (including it), remove the square brackets and add a starting value + | ^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeToInclusive<{integer}>; 1]` - = note: `[..=end]` is an array of one `RangeToInclusive`; you might have meant to have a bounded `RangeInclusive` without the brackets: `0..=end` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `[RangeToInclusive<{integer}>; 1]` + = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `into_iter` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:14:14 @@ -54,9 +54,9 @@ error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator 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]` + = help: the trait `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` without the brackets: `start..end` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:17:14 @@ -64,9 +64,9 @@ error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator 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]` + = help: the trait `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` without the brackets: `start..end` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` error[E0277]: `[std::ops::Range<{integer}>; 2]` is not an iterator --> $DIR/array-of-ranges.rs:19:14 @@ -74,19 +74,19 @@ error[E0277]: `[std::ops::Range<{integer}>; 2]` is not an iterator LL | for _ in [0..1, 2..3] {} | ^^^^^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 2]` + = help: the trait `Iterator` is not implemented for `[std::ops::Range<{integer}>; 2]` = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` -error[E0277]: `[std::ops::RangeInclusive<{integer}>; 1]` is not an iterator +error[E0277]: `[RangeInclusive<{integer}>; 1]` is not an iterator --> $DIR/array-of-ranges.rs:21:14 | LL | for _ in [0..=1] {} - | ^^^^^^^ if you meant to iterate between two values, remove the square brackets + | ^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeInclusive<{integer}>; 1]` - = note: `[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a `RangeInclusive` without the brackets: `start..=end` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `[RangeInclusive<{integer}>; 1]` + = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `into_iter` error: aborting due to 9 previous errors diff --git a/src/test/ui/iterators/array.stderr b/src/test/ui/iterators/array.stderr index 94731f1c745..f86c82e4917 100644 --- a/src/test/ui/iterators/array.stderr +++ b/src/test/ui/iterators/array.stderr @@ -4,9 +4,9 @@ error[E0277]: `[{integer}; 2]` is not an iterator LL | for _ in [1, 2] {} | ^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[{integer}; 2]` + = help: the trait `Iterator` is not implemented for `[{integer}; 2]` = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` error[E0277]: `[{integer}; 2]` is not an iterator --> $DIR/array.rs:5:14 @@ -14,9 +14,9 @@ error[E0277]: `[{integer}; 2]` is not an iterator LL | for _ in x {} | ^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[{integer}; 2]` + = help: the trait `Iterator` is not implemented for `[{integer}; 2]` = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` error[E0277]: `[{float}; 2]` is not an iterator --> $DIR/array.rs:7:14 @@ -24,9 +24,9 @@ error[E0277]: `[{float}; 2]` is not an iterator LL | for _ in [1.0, 2.0] {} | ^^^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | - = help: the trait `std::iter::Iterator` is not implemented for `[{float}; 2]` + = help: the trait `Iterator` is not implemented for `[{float}; 2]` = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` - = note: required by `std::iter::IntoIterator::into_iter` + = note: required by `into_iter` error: aborting due to 3 previous errors diff --git a/src/test/ui/iterators/bound.stderr b/src/test/ui/iterators/bound.stderr index 1a5aad6c36d..eaf2e66d0f8 100644 --- a/src/test/ui/iterators/bound.stderr +++ b/src/test/ui/iterators/bound.stderr @@ -6,7 +6,7 @@ LL | struct S<I: Iterator>(I); LL | struct T(S<u8>); | ^^^^^ `u8` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `u8` + = help: the trait `Iterator` is not implemented for `u8` = 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: aborting due to previous error diff --git a/src/test/ui/iterators/integral.stderr b/src/test/ui/iterators/integral.stderr index 71e1e81e5af..c4c46412611 100644 --- a/src/test/ui/iterators/integral.stderr +++ b/src/test/ui/iterators/integral.stderr @@ -4,9 +4,9 @@ error[E0277]: `{integer}` is not an iterator LL | for _ in 42 {} | ^^ `{integer}` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `{integer}` + = help: the trait `Iterator` is not implemented for `{integer}` = 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` + = note: required by `into_iter` error[E0277]: `u8` is not an iterator --> $DIR/integral.rs:4:14 @@ -14,9 +14,9 @@ error[E0277]: `u8` is not an iterator LL | for _ in 42 as u8 {} | ^^^^^^^^ `u8` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `u8` + = help: the trait `Iterator` is not implemented for `u8` = 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` + = note: required by `into_iter` error[E0277]: `i8` is not an iterator --> $DIR/integral.rs:6:14 @@ -24,9 +24,9 @@ error[E0277]: `i8` is not an iterator LL | for _ in 42 as i8 {} | ^^^^^^^^ `i8` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `i8` + = help: the trait `Iterator` is not implemented for `i8` = 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` + = note: required by `into_iter` error[E0277]: `u16` is not an iterator --> $DIR/integral.rs:8:14 @@ -34,9 +34,9 @@ error[E0277]: `u16` is not an iterator LL | for _ in 42 as u16 {} | ^^^^^^^^^ `u16` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `u16` + = help: the trait `Iterator` is not implemented for `u16` = 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` + = note: required by `into_iter` error[E0277]: `i16` is not an iterator --> $DIR/integral.rs:10:14 @@ -44,9 +44,9 @@ error[E0277]: `i16` is not an iterator LL | for _ in 42 as i16 {} | ^^^^^^^^^ `i16` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `i16` + = help: the trait `Iterator` is not implemented for `i16` = 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` + = note: required by `into_iter` error[E0277]: `u32` is not an iterator --> $DIR/integral.rs:12:14 @@ -54,9 +54,9 @@ error[E0277]: `u32` is not an iterator LL | for _ in 42 as u32 {} | ^^^^^^^^^ `u32` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `u32` + = help: the trait `Iterator` is not implemented for `u32` = 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` + = note: required by `into_iter` error[E0277]: `i32` is not an iterator --> $DIR/integral.rs:14:14 @@ -64,9 +64,9 @@ error[E0277]: `i32` is not an iterator LL | for _ in 42 as i32 {} | ^^^^^^^^^ `i32` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `i32` + = help: the trait `Iterator` is not implemented for `i32` = 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` + = note: required by `into_iter` error[E0277]: `u64` is not an iterator --> $DIR/integral.rs:16:14 @@ -74,9 +74,9 @@ error[E0277]: `u64` is not an iterator LL | for _ in 42 as u64 {} | ^^^^^^^^^ `u64` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `u64` + = help: the trait `Iterator` is not implemented for `u64` = 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` + = note: required by `into_iter` error[E0277]: `i64` is not an iterator --> $DIR/integral.rs:18:14 @@ -84,9 +84,9 @@ error[E0277]: `i64` is not an iterator LL | for _ in 42 as i64 {} | ^^^^^^^^^ `i64` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `i64` + = help: the trait `Iterator` is not implemented for `i64` = 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` + = note: required by `into_iter` error[E0277]: `usize` is not an iterator --> $DIR/integral.rs:20:14 @@ -94,9 +94,9 @@ error[E0277]: `usize` is not an iterator LL | for _ in 42 as usize {} | ^^^^^^^^^^^ `usize` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `usize` + = help: the trait `Iterator` is not implemented for `usize` = 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` + = note: required by `into_iter` error[E0277]: `isize` is not an iterator --> $DIR/integral.rs:22:14 @@ -104,9 +104,9 @@ error[E0277]: `isize` is not an iterator LL | for _ in 42 as isize {} | ^^^^^^^^^^^ `isize` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `isize` + = help: the trait `Iterator` is not implemented for `isize` = 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` + = note: required by `into_iter` error[E0277]: `{float}` is not an iterator --> $DIR/integral.rs:24:14 @@ -114,8 +114,8 @@ error[E0277]: `{float}` is not an iterator LL | for _ in 42.0 {} | ^^^^ `{float}` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `{float}` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `{float}` + = note: required by `into_iter` error: aborting due to 12 previous errors diff --git a/src/test/ui/iterators/ranges.stderr b/src/test/ui/iterators/ranges.stderr index e5e2d87879d..0324d5f1a92 100644 --- a/src/test/ui/iterators/ranges.stderr +++ b/src/test/ui/iterators/ranges.stderr @@ -1,22 +1,20 @@ -error[E0277]: `std::ops::RangeTo<{integer}>` is not an iterator +error[E0277]: `RangeTo<{integer}>` is not an iterator --> $DIR/ranges.rs:2:14 | LL | for _ in ..10 {} - | ^^^^ if you meant to iterate until a value, add a starting value + | ^^^^ `RangeTo<{integer}>` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `std::ops::RangeTo<{integer}>` - = note: `..end` is a `RangeTo`, which cannot be iterated on; you might have meant to have a bounded `Range`: `0..end` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `RangeTo<{integer}>` + = note: required by `into_iter` -error[E0277]: `std::ops::RangeToInclusive<{integer}>` is not an iterator +error[E0277]: `RangeToInclusive<{integer}>` is not an iterator --> $DIR/ranges.rs:4:14 | LL | for _ in ..=10 {} - | ^^^^^ if you meant to iterate until a value (including it), add a starting value + | ^^^^^ `RangeToInclusive<{integer}>` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `std::ops::RangeToInclusive<{integer}>` - = note: `..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant to have a bounded `RangeInclusive`: `0..=end` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `RangeToInclusive<{integer}>` + = note: required by `into_iter` error: aborting due to 2 previous errors diff --git a/src/test/ui/iterators/string.rs b/src/test/ui/iterators/string.rs index 4373dcaabe5..ad58a463e9b 100644 --- a/src/test/ui/iterators/string.rs +++ b/src/test/ui/iterators/string.rs @@ -1,6 +1,6 @@ fn main() { for _ in "".to_owned() {} - //~^ ERROR `std::string::String` is not an iterator + //~^ ERROR `String` is not an iterator for _ in "" {} //~^ ERROR `&str` is not an iterator } diff --git a/src/test/ui/iterators/string.stderr b/src/test/ui/iterators/string.stderr index 927de952cc8..fecdbd1785f 100644 --- a/src/test/ui/iterators/string.stderr +++ b/src/test/ui/iterators/string.stderr @@ -1,11 +1,11 @@ -error[E0277]: `std::string::String` is not an iterator +error[E0277]: `String` is not an iterator --> $DIR/string.rs:2:14 | LL | for _ in "".to_owned() {} - | ^^^^^^^^^^^^^ `std::string::String` is not an iterator; try calling `.chars()` or `.bytes()` + | ^^^^^^^^^^^^^ `String` is not an iterator | - = help: the trait `std::iter::Iterator` is not implemented for `std::string::String` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `String` + = note: required by `into_iter` error[E0277]: `&str` is not an iterator --> $DIR/string.rs:4:14 @@ -13,8 +13,8 @@ error[E0277]: `&str` is not an iterator LL | for _ in "" {} | ^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` | - = help: the trait `std::iter::Iterator` is not implemented for `&str` - = note: required by `std::iter::IntoIterator::into_iter` + = help: the trait `Iterator` is not implemented for `&str` + = note: required by `into_iter` error: aborting due to 2 previous errors |
