about summary refs log tree commit diff
path: root/src/test/ui/self
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/self
parent7b2deb562822112cc30d23958e7459564e2c6ef9 (diff)
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/self')
-rw-r--r--src/test/ui/self/arbitrary-self-types-not-object-safe.curr.stderr4
-rw-r--r--src/test/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr4
-rw-r--r--src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr2
-rw-r--r--src/test/ui/self/point-at-arbitrary-self-type-method.stderr2
-rw-r--r--src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr2
-rw-r--r--src/test/ui/self/self_type_keyword.stderr2
6 files changed, 8 insertions, 8 deletions
diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.curr.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
index 7948f7e9d6b..85da2c6eeb0 100644
--- a/src/test/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
+++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
@@ -26,8 +26,8 @@ LL |     fn foo(self: &Rc<Self>) -> usize;
 LL |     let x = Rc::new(5usize) as Rc<dyn Foo>;
    |             ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
    |
-   = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc<dyn Foo>>` for `std::rc::Rc<usize>`
-   = note: required by cast to type `std::rc::Rc<dyn Foo>`
+   = note: required because of the requirements on the impl of `CoerceUnsized<Rc<dyn Foo>>` for `Rc<usize>`
+   = note: required by cast to type `Rc<dyn Foo>`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
index 74e76b8265f..c4cde2c3561 100644
--- a/src/test/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
+++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
@@ -12,8 +12,8 @@ LL |     fn foo(self: &Rc<Self>) -> usize;
 LL |     let x = Rc::new(5usize) as Rc<dyn Foo>;
    |             ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
    |
-   = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc<dyn Foo>>` for `std::rc::Rc<usize>`
-   = note: required by cast to type `std::rc::Rc<dyn Foo>`
+   = note: required because of the requirements on the impl of `CoerceUnsized<Rc<dyn Foo>>` for `Rc<usize>`
+   = note: required by cast to type `Rc<dyn Foo>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr
index 17099201d11..92241b2fb2d 100644
--- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr
+++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr
@@ -20,7 +20,7 @@ error: lifetime may not live long enough
   --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:13:58
    |
 LL |     fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
-   |            --  ---- has type `std::pin::Pin<&'1 Foo>`    ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
+   |            --  ---- has type `Pin<&'1 Foo>`              ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
    |            |
    |            lifetime `'a` defined here
 
diff --git a/src/test/ui/self/point-at-arbitrary-self-type-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-method.stderr
index 96401cb71d9..2954a499c18 100644
--- a/src/test/ui/self/point-at-arbitrary-self-type-method.stderr
+++ b/src/test/ui/self/point-at-arbitrary-self-type-method.stderr
@@ -5,7 +5,7 @@ LL | struct A;
    | --------- method `foo` not found for this
 ...
 LL |     fn foo(self: Box<Self>) {}
-   |        --- the method is available for `std::boxed::Box<A>` here
+   |        --- the method is available for `Box<A>` here
 ...
 LL |     A.foo();
    |       ^^^ method not found in `A`
diff --git a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr
index 37873031da3..89fe84c0d2d 100644
--- a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr
+++ b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr
@@ -4,7 +4,7 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
 LL | trait B { fn foo(self: Box<Self>); }
    |              ---       --------- the method might not be found because of this arbitrary self type
    |              |
-   |              the method is available for `std::boxed::Box<A>` here
+   |              the method is available for `Box<A>` here
 LL | struct A;
    | --------- method `foo` not found for this
 ...
diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr
index 7997cdc2957..47c04f1eb72 100644
--- a/src/test/ui/self/self_type_keyword.stderr
+++ b/src/test/ui/self/self_type_keyword.stderr
@@ -77,7 +77,7 @@ error[E0392]: parameter `'Self` is never used
 LL | struct Bar<'Self>;
    |            ^^^^^ unused parameter
    |
-   = help: consider removing `'Self`, referring to it in a field, or using a marker such as `std::marker::PhantomData`
+   = help: consider removing `'Self`, referring to it in a field, or using a marker such as `PhantomData`
 
 error: aborting due to 12 previous errors