about summary refs log tree commit diff
path: root/src/test/ui/use
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/use
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/use')
-rw-r--r--src/test/ui/use/use-after-move-based-on-type.stderr2
-rw-r--r--src/test/ui/use/use-after-move-implicity-coerced-object.stderr2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/test/ui/use/use-after-move-based-on-type.stderr b/src/test/ui/use/use-after-move-based-on-type.stderr
index 520f88f55dc..11ce005bb45 100644
--- a/src/test/ui/use/use-after-move-based-on-type.stderr
+++ b/src/test/ui/use/use-after-move-based-on-type.stderr
@@ -2,7 +2,7 @@ error[E0382]: borrow of moved value: `x`
   --> $DIR/use-after-move-based-on-type.rs:4:20
    |
 LL |     let x = "Hello!".to_string();
-   |         - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
+   |         - move occurs because `x` has type `String`, which does not implement the `Copy` trait
 LL |     let _y = x;
    |              - value moved here
 LL |     println!("{}", x);
diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr
index e16bca38067..b3266562d14 100644
--- a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr
+++ b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr
@@ -2,7 +2,7 @@ error[E0382]: borrow of moved value: `n`
   --> $DIR/use-after-move-implicity-coerced-object.rs:28:13
    |
 LL |     let n: Box<_> = box Number { n: 42 };
-   |         - move occurs because `n` has type `std::boxed::Box<Number>`, which does not implement the `Copy` trait
+   |         - move occurs because `n` has type `Box<Number>`, which does not implement the `Copy` trait
 LL |     let mut l: Box<_> = box List { list: Vec::new() };
 LL |     l.push(n);
    |            - value moved here