summary refs log tree commit diff
path: root/src/test/ui/parser
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/parser
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/parser')
-rw-r--r--src/test/ui/parser/fn-header-semantic-fail.stderr4
-rw-r--r--src/test/ui/parser/lex-bad-char-literals-6.stderr4
-rw-r--r--src/test/ui/parser/removed-syntax-with-2.rs2
-rw-r--r--src/test/ui/parser/removed-syntax-with-2.stderr2
-rw-r--r--src/test/ui/parser/struct-literal-in-for.stderr4
-rw-r--r--src/test/ui/parser/unclosed-delimiter-in-dep.stderr2
6 files changed, 9 insertions, 9 deletions
diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr
index d6b36fbb714..4193b3ee695 100644
--- a/src/test/ui/parser/fn-header-semantic-fail.stderr
+++ b/src/test/ui/parser/fn-header-semantic-fail.stderr
@@ -178,7 +178,7 @@ LL |         async fn ft1() {}
    |                        expected `()`, found opaque type
    |
    = note: expected fn pointer `fn()`
-              found fn pointer `fn() -> impl std::future::Future`
+              found fn pointer `fn() -> impl Future`
 
 error[E0053]: method `ft5` has an incompatible type for trait
   --> $DIR/fn-header-semantic-fail.rs:34:48
@@ -193,7 +193,7 @@ LL |         const async unsafe extern "C" fn ft5() {}
    |                                                expected `()`, found opaque type
    |
    = note: expected fn pointer `unsafe extern "C" fn()`
-              found fn pointer `unsafe extern "C" fn() -> impl std::future::Future`
+              found fn pointer `unsafe extern "C" fn() -> impl Future`
 
 error: aborting due to 20 previous errors
 
diff --git a/src/test/ui/parser/lex-bad-char-literals-6.stderr b/src/test/ui/parser/lex-bad-char-literals-6.stderr
index 82c46ad82c7..48b8fc6a729 100644
--- a/src/test/ui/parser/lex-bad-char-literals-6.stderr
+++ b/src/test/ui/parser/lex-bad-char-literals-6.stderr
@@ -37,7 +37,7 @@ error[E0277]: can't compare `&str` with `char`
 LL |     if x == y {}
    |          ^^ no implementation for `&str == char`
    |
-   = help: the trait `std::cmp::PartialEq<char>` is not implemented for `&str`
+   = help: the trait `PartialEq<char>` is not implemented for `&str`
 
 error[E0308]: mismatched types
   --> $DIR/lex-bad-char-literals-6.rs:15:20
@@ -53,7 +53,7 @@ error[E0277]: can't compare `&str` with `char`
 LL |     if x == z {}
    |          ^^ no implementation for `&str == char`
    |
-   = help: the trait `std::cmp::PartialEq<char>` is not implemented for `&str`
+   = help: the trait `PartialEq<char>` is not implemented for `&str`
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/parser/removed-syntax-with-2.rs b/src/test/ui/parser/removed-syntax-with-2.rs
index f666da49696..8a489e71990 100644
--- a/src/test/ui/parser/removed-syntax-with-2.rs
+++ b/src/test/ui/parser/removed-syntax-with-2.rs
@@ -7,5 +7,5 @@ fn main() {
     let a = S { foo: (), bar: () };
     let b = S { foo: (), with a };
     //~^ ERROR expected one of `,` or `}`, found `a`
-    //~| ERROR missing field `bar` in initializer of `main::S`
+    //~| ERROR missing field `bar` in initializer of `S`
 }
diff --git a/src/test/ui/parser/removed-syntax-with-2.stderr b/src/test/ui/parser/removed-syntax-with-2.stderr
index 024c97cc9c1..2c96dceb587 100644
--- a/src/test/ui/parser/removed-syntax-with-2.stderr
+++ b/src/test/ui/parser/removed-syntax-with-2.stderr
@@ -6,7 +6,7 @@ LL |     let b = S { foo: (), with a };
    |             |
    |             while parsing this struct
 
-error[E0063]: missing field `bar` in initializer of `main::S`
+error[E0063]: missing field `bar` in initializer of `S`
   --> $DIR/removed-syntax-with-2.rs:8:13
    |
 LL |     let b = S { foo: (), with a };
diff --git a/src/test/ui/parser/struct-literal-in-for.stderr b/src/test/ui/parser/struct-literal-in-for.stderr
index 2e59914864a..42f5f1e7e73 100644
--- a/src/test/ui/parser/struct-literal-in-for.stderr
+++ b/src/test/ui/parser/struct-literal-in-for.stderr
@@ -23,8 +23,8 @@ LL | |         x: 3
 LL | |     }.hi() {
    | |__________^ `bool` is not an iterator
    |
-   = help: the trait `std::iter::Iterator` is not implemented for `bool`
-   = note: required by `std::iter::IntoIterator::into_iter`
+   = help: the trait `Iterator` is not implemented for `bool`
+   = note: required by `into_iter`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/parser/unclosed-delimiter-in-dep.stderr b/src/test/ui/parser/unclosed-delimiter-in-dep.stderr
index a32a27bf987..d63a50034c5 100644
--- a/src/test/ui/parser/unclosed-delimiter-in-dep.stderr
+++ b/src/test/ui/parser/unclosed-delimiter-in-dep.stderr
@@ -18,7 +18,7 @@ LL |     let _: usize = unclosed_delim_mod::new();
    |            expected due to this
    |
    = note: expected type `usize`
-              found enum `std::result::Result<unclosed_delim_mod::Value, ()>`
+              found enum `std::result::Result<Value, ()>`
 
 error: aborting due to 2 previous errors