about summary refs log tree commit diff
path: root/src/test/ui/const-generics/std
diff options
context:
space:
mode:
authorDan Aloni <alonid@gmail.com>2020-09-02 10:40:56 +0300
committerDan Aloni <alonid@gmail.com>2020-09-02 22:26:37 +0300
commit07e7823c01be1733df2480de19fbbe6b8e9384cf (patch)
tree9e4ff1075680201f9c72b58bf780638ef1fcede3 /src/test/ui/const-generics/std
parent7b2deb562822112cc30d23958e7459564e2c6ef9 (diff)
downloadrust-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/std')
-rw-r--r--src/test/ui/const-generics/std/const-generics-range.min.stderr10
-rw-r--r--src/test/ui/const-generics/std/const-generics-range.rs10
2 files changed, 10 insertions, 10 deletions
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() {}