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/const-generics | |
| 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/const-generics')
11 files changed, 34 insertions, 34 deletions
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr index ba99c87722c..f860788e778 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr @@ -10,7 +10,7 @@ error[E0392]: parameter `T` is never used LL | pub struct Dependent<T, const X: T>([(); X]); | ^ unused parameter | - = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr index ba99c87722c..f860788e778 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr @@ -10,7 +10,7 @@ error[E0392]: parameter `T` is never used LL | pub struct Dependent<T, const X: T>([(); X]); | ^ unused parameter | - = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-61336-2.full.stderr b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr index d21cd9df054..ef6e60084a5 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr @@ -7,17 +7,17 @@ LL | #![cfg_attr(full, feature(const_generics))] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied +error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-61336-2.rs:10:5 | LL | [x; { N }] - | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` | = note: the `Copy` trait is required because the repeated element will be copied help: consider restricting type parameter `T` | -LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { - | ^^^^^^^^^^^^^^^^^^^ +LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr b/src/test/ui/const-generics/issues/issue-61336-2.min.stderr index 29ab7b1305e..40863a4f718 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.min.stderr @@ -1,14 +1,14 @@ -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied +error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-61336-2.rs:10:5 | LL | [x; { N }] - | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` | = note: the `Copy` trait is required because the repeated element will be copied help: consider restricting type parameter `T` | -LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { - | ^^^^^^^^^^^^^^^^^^^ +LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-61336-2.rs b/src/test/ui/const-generics/issues/issue-61336-2.rs index 25b9271105e..44995157cc9 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.rs +++ b/src/test/ui/const-generics/issues/issue-61336-2.rs @@ -8,7 +8,7 @@ fn f<T: Copy, const N: usize>(x: T) -> [T; N] { fn g<T, const N: usize>(x: T) -> [T; N] { [x; { N }] - //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied + //~^ ERROR the trait bound `T: Copy` is not satisfied } fn main() { diff --git a/src/test/ui/const-generics/issues/issue-61336.full.stderr b/src/test/ui/const-generics/issues/issue-61336.full.stderr index d1b5d5eb941..bdfdffd941d 100644 --- a/src/test/ui/const-generics/issues/issue-61336.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.full.stderr @@ -7,17 +7,17 @@ LL | #![cfg_attr(full, feature(const_generics))] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied +error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-61336.rs:10:5 | LL | [x; N] - | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | ^^^^^^ the trait `Copy` is not implemented for `T` | = note: the `Copy` trait is required because the repeated element will be copied help: consider restricting type parameter `T` | -LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { - | ^^^^^^^^^^^^^^^^^^^ +LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61336.min.stderr b/src/test/ui/const-generics/issues/issue-61336.min.stderr index bced8bbd82f..6c57f9ccbf5 100644 --- a/src/test/ui/const-generics/issues/issue-61336.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.min.stderr @@ -1,14 +1,14 @@ -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied +error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-61336.rs:10:5 | LL | [x; N] - | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | ^^^^^^ the trait `Copy` is not implemented for `T` | = note: the `Copy` trait is required because the repeated element will be copied help: consider restricting type parameter `T` | -LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { - | ^^^^^^^^^^^^^^^^^^^ +LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-61336.rs b/src/test/ui/const-generics/issues/issue-61336.rs index fb55542a1c9..7c34250e6b2 100644 --- a/src/test/ui/const-generics/issues/issue-61336.rs +++ b/src/test/ui/const-generics/issues/issue-61336.rs @@ -8,7 +8,7 @@ fn f<T: Copy, const N: usize>(x: T) -> [T; N] { fn g<T, const N: usize>(x: T) -> [T; N] { [x; N] - //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied + //~^ ERROR the trait bound `T: Copy` is not satisfied } fn main() { diff --git a/src/test/ui/const-generics/issues/issue-61336.stderr b/src/test/ui/const-generics/issues/issue-61336.stderr index 0eee37df3dd..1be907b98ac 100644 --- a/src/test/ui/const-generics/issues/issue-61336.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.stderr @@ -7,17 +7,17 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied +error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-61336.rs:9:5 | LL | [x; N] - | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | ^^^^^^ the trait `Copy` is not implemented for `T` | = note: the `Copy` trait is required because the repeated element will be copied help: consider restricting type parameter `T` | -LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { - | ^^^^^^^^^^^^^^^^^^^ +LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/const-generics/std/const-generics-range.min.stderr b/src/test/ui/const-generics/std/const-generics-range.min.stderr index a71e7442021..97be6ee6445 100644 --- a/src/test/ui/const-generics/std/const-generics-range.min.stderr +++ b/src/test/ui/const-generics/std/const-generics-range.min.stderr @@ -7,7 +7,7 @@ LL | struct _Range<const R: std::ops::Range<usize>>; = note: the only supported types are integers, `bool` and `char` = note: more complex types are supported with `#[feature(const_generics)]` -error: `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter +error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:13:28 | LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; @@ -16,7 +16,7 @@ LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; = note: the only supported types are integers, `bool` and `char` = note: more complex types are supported with `#[feature(const_generics)]` -error: `std::ops::RangeFull` is forbidden as the type of a const generic parameter +error: `RangeFull` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:18:28 | LL | struct _RangeFull<const R: std::ops::RangeFull>; @@ -25,7 +25,7 @@ LL | struct _RangeFull<const R: std::ops::RangeFull>; = note: the only supported types are integers, `bool` and `char` = note: more complex types are supported with `#[feature(const_generics)]` -error: `std::ops::RangeInclusive<usize>` is forbidden as the type of a const generic parameter +error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:24:33 | LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; @@ -34,7 +34,7 @@ LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; = note: the only supported types are integers, `bool` and `char` = note: more complex types are supported with `#[feature(const_generics)]` -error: `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter +error: `RangeTo<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:29:26 | LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; @@ -43,7 +43,7 @@ LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; = note: the only supported types are integers, `bool` and `char` = note: more complex types are supported with `#[feature(const_generics)]` -error: `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic parameter +error: `RangeToInclusive<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:34:35 | LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs index c04f4a3acfb..136ac352890 100644 --- a/src/test/ui/const-generics/std/const-generics-range.rs +++ b/src/test/ui/const-generics/std/const-generics-range.rs @@ -11,28 +11,28 @@ const RANGE : _Range<{ 0 .. 1000 }> = _Range; // `RangeFrom` should be usable within const generics: struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; -//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden +//[min]~^ ERROR `RangeFrom<usize>` is forbidden const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom; // `RangeFull` should be usable within const generics: struct _RangeFull<const R: std::ops::RangeFull>; -//[min]~^ ERROR `std::ops::RangeFull` is forbidden +//[min]~^ ERROR `RangeFull` is forbidden const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull; // Regression test for #70155 // `RangeInclusive` should be usable within const generics: struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; -//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden +//[min]~^ ERROR `RangeInclusive<usize>` is forbidden const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive; // `RangeTo` should be usable within const generics: struct _RangeTo<const R: std::ops::RangeTo<usize>>; -//[min]~^ ERROR `std::ops::RangeTo<usize>` is forbidden +//[min]~^ ERROR `RangeTo<usize>` is forbidden const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo; // `RangeToInclusive` should be usable within const generics: struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; -//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden +//[min]~^ ERROR `RangeToInclusive<usize>` is forbidden const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive; pub fn main() {} |
