about summary refs log tree commit diff
path: root/src/test/ui/methods
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/methods
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/methods')
-rw-r--r--src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr4
-rw-r--r--src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr6
-rw-r--r--src/test/ui/methods/method-call-err-msg.stderr8
-rw-r--r--src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr12
-rw-r--r--src/test/ui/methods/method-missing-call.stderr2
5 files changed, 16 insertions, 16 deletions
diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
index f3f3c476809..33e8282c9d2 100644
--- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
+++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
@@ -1,10 +1,10 @@
-error[E0282]: type annotations needed for `std::vec::Vec<T>`
+error[E0282]: type annotations needed for `Vec<T>`
   --> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:17
    |
 LL |     let mut x = Vec::new();
    |         -----   ^^^^^^^^ cannot infer type for type parameter `T`
    |         |
-   |         consider giving `x` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
+   |         consider giving `x` the explicit type `Vec<T>`, where the type parameter `T` is specified
 
 error[E0308]: mismatched types
   --> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20
diff --git a/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr b/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr
index 1b354fc697a..42802ba1d0f 100644
--- a/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr
+++ b/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr
@@ -9,15 +9,15 @@ note: candidate #1 is defined in an impl of the trait `Me2` for the type `usize`
    |
 LL | impl Me2 for usize { fn me(&self) -> usize { *self } }
    |                      ^^^^^^^^^^^^^^^^^^^^^
-   = note: candidate #2 is defined in an impl of the trait `ambig_impl_2_lib::Me` for the type `usize`
+   = note: candidate #2 is defined in an impl of the trait `Me` for the type `usize`
 help: disambiguate the associated function for candidate #1
    |
 LL | fn main() { Me2::me(&1_usize); }
    |             ^^^^^^^^^^^^^^^^^
 help: disambiguate the associated function for candidate #2
    |
-LL | fn main() { ambig_impl_2_lib::Me::me(&1_usize); }
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn main() { Me::me(&1_usize); }
+   |             ^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr
index 4678642dd6d..b0d1bb9823b 100644
--- a/src/test/ui/methods/method-call-err-msg.stderr
+++ b/src/test/ui/methods/method-call-err-msg.stderr
@@ -38,17 +38,17 @@ LL | pub struct Foo;
    | ---------------
    | |
    | method `take` not found for this
-   | doesn't satisfy `Foo: std::iter::Iterator`
+   | doesn't satisfy `Foo: Iterator`
 ...
 LL |      .take()
    |       ^^^^ method not found in `Foo`
    |
    = note: the method `take` exists but the following trait bounds were not satisfied:
-           `Foo: std::iter::Iterator`
-           which is required by `&mut Foo: std::iter::Iterator`
+           `Foo: Iterator`
+           which is required by `&mut Foo: Iterator`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `take`, perhaps you need to implement it:
-           candidate #1: `std::iter::Iterator`
+           candidate #1: `Iterator`
 
 error[E0061]: this function takes 3 arguments but 0 arguments were supplied
   --> $DIR/method-call-err-msg.rs:21:7
diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
index 1bc7f30d04d..08be7ee155e 100644
--- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
+++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
@@ -20,12 +20,12 @@ error[E0034]: multiple applicable items in scope
 LL |     let z = x.foo();
    |               ^^^ multiple `foo` found
    |
-note: candidate #1 is defined in an impl of the trait `internal::X` for the type `T`
+note: candidate #1 is defined in an impl of the trait `X` for the type `T`
   --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:43:9
    |
 LL |         fn foo(self: Smaht<Self, u64>) -> u64 {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `T`
+note: candidate #2 is defined in an impl of the trait `NuisanceFoo` for the type `T`
   --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:70:9
    |
 LL |         fn foo(self) {}
@@ -37,12 +37,12 @@ LL |     fn foo(&self) -> u8;
    |     ^^^^^^^^^^^^^^^^^^^^
 help: disambiguate the associated function for candidate #1
    |
-LL |     let z = internal::X::foo(x);
-   |             ^^^^^^^^^^^^^^^^^^^
+LL |     let z = X::foo(x);
+   |             ^^^^^^^^^
 help: disambiguate the associated function for candidate #2
    |
-LL |     let z = nuisance_foo::NuisanceFoo::foo(x);
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     let z = NuisanceFoo::foo(x);
+   |             ^^^^^^^^^^^^^^^^^^^
 help: disambiguate the associated function for candidate #3
    |
 LL |     let z = FinalFoo::foo(x);
diff --git a/src/test/ui/methods/method-missing-call.stderr b/src/test/ui/methods/method-missing-call.stderr
index bc8a1c85e56..241c50d7ced 100644
--- a/src/test/ui/methods/method-missing-call.stderr
+++ b/src/test/ui/methods/method-missing-call.stderr
@@ -9,7 +9,7 @@ help: use parentheses to call the method
 LL |                         .get_x();
    |                               ^^
 
-error[E0615]: attempted to take value of method `filter_map` on type `std::iter::Filter<std::iter::Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>`
+error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>`
   --> $DIR/method-missing-call.rs:29:16
    |
 LL |               .filter_map;