about summary refs log tree commit diff
path: root/src/test/ui/pattern/move-ref-patterns
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/pattern/move-ref-patterns
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/pattern/move-ref-patterns')
-rw-r--r--src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.stderr4
-rw-r--r--src/test/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-inside.stderr54
-rw-r--r--src/test/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr4
3 files changed, 31 insertions, 31 deletions
diff --git a/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.stderr b/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.stderr
index eb5391a95de..5335569a972 100644
--- a/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.stderr
+++ b/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.stderr
@@ -49,7 +49,7 @@ LL |     let (a, mut b) = &tup;
    |             -----    ^^^^
    |             |
    |             data moved here
-   |             move occurs because `b` has type `main::X`, which does not implement the `Copy` trait
+   |             move occurs because `b` has type `X`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of a mutable reference
   --> $DIR/feature-gate-move_ref_pattern.rs:20:22
@@ -58,7 +58,7 @@ LL |     let (mut a, b) = &mut tup;
    |          -----       ^^^^^^^^
    |          |
    |          data moved here
-   |          move occurs because `a` has type `main::X`, which does not implement the `Copy` trait
+   |          move occurs because `a` has type `X`, which does not implement the `Copy` trait
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-inside.stderr b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-inside.stderr
index 9159e3e2213..9ad84879595 100644
--- a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-inside.stderr
+++ b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-inside.stderr
@@ -2,7 +2,7 @@ error[E0382]: borrow of moved value: `tup0`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:33:10
    |
 LL |     let mut tup0 = (S, S);
-   |         -------- move occurs because `tup0` has type `(main::S, main::S)`, which does not implement the `Copy` trait
+   |         -------- move occurs because `tup0` has type `(S, S)`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -17,7 +17,7 @@ error[E0382]: borrow of moved value: `tup1`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:34:10
    |
 LL |     let mut tup1 = (S, S, S);
-   |         -------- move occurs because `tup1` has type `(main::S, main::S, main::S)`, which does not implement the `Copy` trait
+   |         -------- move occurs because `tup1` has type `(S, S, S)`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -32,7 +32,7 @@ error[E0382]: borrow of moved value: `tup2`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:35:10
    |
 LL |     let tup2 = (S, S);
-   |         ---- move occurs because `tup2` has type `(main::S, main::S)`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup2` has type `(S, S)`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -47,7 +47,7 @@ error[E0382]: borrow of moved value: `tup3`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:36:10
    |
 LL |     let tup3 = (S, S, S);
-   |         ---- move occurs because `tup3` has type `(main::S, main::S, main::S)`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup3` has type `(S, S, S)`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -62,7 +62,7 @@ error[E0382]: borrow of moved value: `tup4`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:41:10
    |
 LL |     let tup4 = (S, S);
-   |         ---- move occurs because `tup4` has type `(main::S, main::S)`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup4` has type `(S, S)`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -77,7 +77,7 @@ error[E0382]: borrow of moved value: `arr0`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:43:10
    |
 LL |     let mut arr0 = [S, S, S];
-   |         -------- move occurs because `arr0` has type `[main::S; 3]`, which does not implement the `Copy` trait
+   |         -------- move occurs because `arr0` has type `[S; 3]`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -92,7 +92,7 @@ error[E0382]: borrow of moved value: `arr1`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:44:36
    |
 LL |     let mut arr1 = [S, S, S, S, S];
-   |         -------- move occurs because `arr1` has type `[main::S; 5]`, which does not implement the `Copy` trait
+   |         -------- move occurs because `arr1` has type `[S; 5]`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -107,7 +107,7 @@ error[E0382]: borrow of moved value: `arr2`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:45:10
    |
 LL |     let arr2 = [S, S, S];
-   |         ---- move occurs because `arr2` has type `[main::S; 3]`, which does not implement the `Copy` trait
+   |         ---- move occurs because `arr2` has type `[S; 3]`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -122,7 +122,7 @@ error[E0382]: borrow of moved value: `arr3`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:46:36
    |
 LL |     let arr3 = [S, S, S, S, S];
-   |         ---- move occurs because `arr3` has type `[main::S; 5]`, which does not implement the `Copy` trait
+   |         ---- move occurs because `arr3` has type `[S; 5]`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -137,7 +137,7 @@ error[E0382]: borrow of moved value: `tup0`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:77:10
    |
 LL |     let mut tup0: Option<(S, S)> = None;
-   |         -------- move occurs because `tup0` has type `std::option::Option<(main::S, main::S)>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `tup0` has type `Option<(S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -151,7 +151,7 @@ error[E0382]: borrow of moved value: `tup1`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:78:10
    |
 LL |     let mut tup1: Option<(S, S, S)> = None;
-   |         -------- move occurs because `tup1` has type `std::option::Option<(main::S, main::S, main::S)>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `tup1` has type `Option<(S, S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -166,7 +166,7 @@ error[E0382]: borrow of moved value: `tup2`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:79:10
    |
 LL |     let tup2: Option<(S, S)> = None;
-   |         ---- move occurs because `tup2` has type `std::option::Option<(main::S, main::S)>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup2` has type `Option<(S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -181,7 +181,7 @@ error[E0382]: borrow of moved value: `tup3`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:80:10
    |
 LL |     let tup3: Option<(S, S, S)> = None;
-   |         ---- move occurs because `tup3` has type `std::option::Option<(main::S, main::S, main::S)>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup3` has type `Option<(S, S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -196,7 +196,7 @@ error[E0382]: borrow of moved value: `tup4`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:81:21
    |
 LL |     let tup4: Option<(S, S)> = None;
-   |         ---- move occurs because `tup4` has type `std::option::Option<(main::S, main::S)>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup4` has type `Option<(S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -211,7 +211,7 @@ error[E0382]: borrow of moved value: `arr0`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:82:10
    |
 LL |     let mut arr0: Option<[S; 3]> = None;
-   |         -------- move occurs because `arr0` has type `std::option::Option<[main::S; 3]>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `arr0` has type `Option<[S; 3]>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -226,7 +226,7 @@ error[E0382]: borrow of moved value: `arr1`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:83:35
    |
 LL |     let mut arr1: Option<[S; 5]> = None;
-   |         -------- move occurs because `arr1` has type `std::option::Option<[main::S; 5]>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `arr1` has type `Option<[S; 5]>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -241,7 +241,7 @@ error[E0382]: borrow of moved value: `arr2`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:84:10
    |
 LL |     let arr2: Option<[S; 3]> = None;
-   |         ---- move occurs because `arr2` has type `std::option::Option<[main::S; 3]>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `arr2` has type `Option<[S; 3]>`, which does not implement the `Copy` trait
 LL |     let arr3: Option<[S; 5]> = None;
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -256,7 +256,7 @@ error[E0382]: borrow of moved value: `arr3`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:85:35
    |
 LL |     let arr3: Option<[S; 5]> = None;
-   |         ---- move occurs because `arr3` has type `std::option::Option<[main::S; 5]>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `arr3` has type `Option<[S; 5]>`, which does not implement the `Copy` trait
 LL |     let mut closure = || {
    |                       -- value moved into closure here
 ...
@@ -270,7 +270,7 @@ error[E0382]: borrow of moved value: `tup0`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:113:10
    |
 LL |     let mut tup0: Option<(S, S)> = None;
-   |         -------- move occurs because `tup0` has type `std::option::Option<(main::S, main::S)>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `tup0` has type `Option<(S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -284,7 +284,7 @@ error[E0382]: borrow of moved value: `tup1`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:114:10
    |
 LL |     let mut tup1: Option<(S, S, S)> = None;
-   |         -------- move occurs because `tup1` has type `std::option::Option<(main::S, main::S, main::S)>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `tup1` has type `Option<(S, S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -299,7 +299,7 @@ error[E0382]: borrow of moved value: `tup2`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:115:10
    |
 LL |     let tup2: Option<(S, S)> = None;
-   |         ---- move occurs because `tup2` has type `std::option::Option<(main::S, main::S)>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup2` has type `Option<(S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -314,7 +314,7 @@ error[E0382]: borrow of moved value: `tup3`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:116:10
    |
 LL |     let tup3: Option<(S, S, S)> = None;
-   |         ---- move occurs because `tup3` has type `std::option::Option<(main::S, main::S, main::S)>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup3` has type `Option<(S, S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -329,7 +329,7 @@ error[E0382]: borrow of moved value: `tup4`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:117:21
    |
 LL |     let tup4: Option<(S, S)> = None;
-   |         ---- move occurs because `tup4` has type `std::option::Option<(main::S, main::S)>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `tup4` has type `Option<(S, S)>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -344,7 +344,7 @@ error[E0382]: borrow of moved value: `arr0`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:118:10
    |
 LL |     let mut arr0: Option<[S; 3]> = None;
-   |         -------- move occurs because `arr0` has type `std::option::Option<[main::S; 3]>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `arr0` has type `Option<[S; 3]>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -359,7 +359,7 @@ error[E0382]: borrow of moved value: `arr1`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:119:35
    |
 LL |     let mut arr1: Option<[S; 5]> = None;
-   |         -------- move occurs because `arr1` has type `std::option::Option<[main::S; 5]>`, which does not implement the `Copy` trait
+   |         -------- move occurs because `arr1` has type `Option<[S; 5]>`, which does not implement the `Copy` trait
 ...
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -374,7 +374,7 @@ error[E0382]: borrow of moved value: `arr2`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:120:10
    |
 LL |     let arr2: Option<[S; 3]> = None;
-   |         ---- move occurs because `arr2` has type `std::option::Option<[main::S; 3]>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `arr2` has type `Option<[S; 3]>`, which does not implement the `Copy` trait
 LL |     let arr3: Option<[S; 5]> = None;
 LL |     let mut closure = || {
    |                       -- value moved into closure here
@@ -389,7 +389,7 @@ error[E0382]: borrow of moved value: `arr3`
   --> $DIR/move-ref-patterns-closure-captures-inside.rs:121:35
    |
 LL |     let arr3: Option<[S; 5]> = None;
-   |         ---- move occurs because `arr3` has type `std::option::Option<[main::S; 5]>`, which does not implement the `Copy` trait
+   |         ---- move occurs because `arr3` has type `Option<[S; 5]>`, which does not implement the `Copy` trait
 LL |     let mut closure = || {
    |                       -- value moved into closure here
 ...
diff --git a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr
index fe7f71e6c46..f92699f5c3c 100644
--- a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr
+++ b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr
@@ -5,7 +5,7 @@ LL |     let (a, mut b) = &p;
    |             -----    ^^
    |             |
    |             data moved here
-   |             move occurs because `b` has type `main::U`, which does not implement the `Copy` trait
+   |             move occurs because `b` has type `U`, which does not implement the `Copy` trait
 
 error[E0507]: cannot move out of a mutable reference
   --> $DIR/move-ref-patterns-default-binding-modes.rs:14:22
@@ -14,7 +14,7 @@ LL |     let (a, mut b) = &mut p;
    |             -----    ^^^^^^
    |             |
    |             data moved here
-   |             move occurs because `b` has type `main::U`, which does not implement the `Copy` trait
+   |             move occurs because `b` has type `U`, which does not implement the `Copy` trait
 
 error: aborting due to 2 previous errors