about summary refs log tree commit diff
path: root/src/test/ui/pattern
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-11 19:26:01 +0000
committerbors <bors@rust-lang.org>2021-08-11 19:26:01 +0000
commitccffcafd55e58f769d4b0efc0064bf65e76998e4 (patch)
tree725b619b120ee18a4bada33b6f7fb4385e06d6df /src/test/ui/pattern
parent362e0f55eb1f36d279e5c4a58fb0fe5f9a2c579d (diff)
parent657caa5bf293e9d910a54dac10dc536e7c26e50b (diff)
downloadrust-ccffcafd55e58f769d4b0efc0064bf65e76998e4.tar.gz
rust-ccffcafd55e58f769d4b0efc0064bf65e76998e4.zip
Auto merge of #86532 - estebank:delete-suggestion-underline, r=petrochenkov
Make deleted code in a suggestion clearer

Show suggestions that include deletions in a way similar to `diff`'s output.

<img width="628" alt="" src="https://user-images.githubusercontent.com/1606434/123350316-9078e580-d50f-11eb-89b9-78431b85e23f.png">

For changes that do not have deletions, use `+` as an underline for additions and `~` as an underline for replacements.

<img width="631" alt="" src="https://user-images.githubusercontent.com/1606434/123701745-1ac68f80-d817-11eb-950b-09e5afd7532f.png">

For multiline suggestions, we now use `~` in the gutter to signal replacements and `+` to signal whole line replacements/additions.

<img width="834" alt="" src="https://user-images.githubusercontent.com/1606434/123701331-8eb46800-d816-11eb-9dcd-ef9098071afb.png">

In all cases we now use color to highlight the specific spans and snippets.
Diffstat (limited to 'src/test/ui/pattern')
-rw-r--r--src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr4
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr4
-rw-r--r--src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr4
-rw-r--r--src/test/ui/pattern/issue-74539.stderr4
-rw-r--r--src/test/ui/pattern/issue-74702.stderr2
-rw-r--r--src/test/ui/pattern/pat-tuple-underfield.stderr24
-rw-r--r--src/test/ui/pattern/pattern-error-continue.stderr4
-rw-r--r--src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr6
8 files changed, 26 insertions, 26 deletions
diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr
index 6ff0dadf0d1..4249a74b3ed 100644
--- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr
+++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr
@@ -49,7 +49,7 @@ LL |         Some(ref _y @ _z) => {}
 help: borrow this field in the pattern to avoid moving `x.0`
    |
 LL |         Some(ref _y @ ref _z) => {}
-   |                       ^^^
+   |                       +++
 
 error[E0382]: borrow of moved value
   --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:26:14
@@ -64,7 +64,7 @@ LL |         Some(ref mut _y @ _z) => {}
 help: borrow this field in the pattern to avoid moving `x.0`
    |
 LL |         Some(ref mut _y @ ref _z) => {}
-   |                           ^^^
+   |                           +++
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
index e6a1e5ef07c..c019aae3dfc 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
@@ -299,7 +299,7 @@ LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
 help: borrow this field in the pattern to avoid moving the value
    |
 LL |         ref a @ Some((ref b @ ref mut c, ref d @ e)) => {}
-   |                               ^^^
+   |                               +++
 
 error[E0382]: borrow of moved value
   --> $DIR/borrowck-pat-by-move-and-ref.rs:69:38
@@ -314,7 +314,7 @@ LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
 help: borrow this field in the pattern to avoid moving the value
    |
 LL |         ref a @ Some((ref b @ mut c, ref d @ ref e)) => {}
-   |                                              ^^^
+   |                                              +++
 
 error[E0382]: borrow of moved value
   --> $DIR/borrowck-pat-by-move-and-ref.rs:11:11
diff --git a/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr b/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
index 9bdbf0bf9f4..7f5da8f3c2d 100644
--- a/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
+++ b/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
@@ -21,11 +21,11 @@ LL |     let P() = U {};
 help: use `_` to explicitly ignore each field
    |
 LL |     let P(_) = U {};
-   |           ^
+   |           +
 help: use `..` to ignore all fields
    |
 LL |     let P(..) = U {};
-   |           ^^
+   |           ++
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/pattern/issue-74539.stderr b/src/test/ui/pattern/issue-74539.stderr
index f7644c19ea0..7d998af7fb3 100644
--- a/src/test/ui/pattern/issue-74539.stderr
+++ b/src/test/ui/pattern/issue-74539.stderr
@@ -8,7 +8,7 @@ LL |         E::A(x @ ..) => {
 help: if you don't need to use the contents of x, discard the tuple's remaining fields
    |
 LL |         E::A(..) => {
-   |              ^^
+   |              ~~
 
 error: `..` patterns are not allowed here
   --> $DIR/issue-74539.rs:8:18
@@ -30,7 +30,7 @@ LL |         E::A(x @ ..) => {
 help: use `_` to explicitly ignore each field
    |
 LL |         E::A(x @ .., _) => {
-   |                    ^^^
+   |                    +++
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/pattern/issue-74702.stderr b/src/test/ui/pattern/issue-74702.stderr
index aca5c9aed96..f2e2c8f021b 100644
--- a/src/test/ui/pattern/issue-74702.stderr
+++ b/src/test/ui/pattern/issue-74702.stderr
@@ -8,7 +8,7 @@ LL |     let (foo @ ..,) = (0, 0);
 help: if you don't need to use the contents of foo, discard the tuple's remaining fields
    |
 LL |     let (..,) = (0, 0);
-   |          ^^
+   |          ~~
 
 error: `..` patterns are not allowed here
   --> $DIR/issue-74702.rs:2:16
diff --git a/src/test/ui/pattern/pat-tuple-underfield.stderr b/src/test/ui/pattern/pat-tuple-underfield.stderr
index 70c21dbafe9..2fbcb6d67ba 100644
--- a/src/test/ui/pattern/pat-tuple-underfield.stderr
+++ b/src/test/ui/pattern/pat-tuple-underfield.stderr
@@ -19,7 +19,7 @@ LL |         S(x) => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         S(x, _) => {}
-   |            ^^^
+   |            +++
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
   --> $DIR/pat-tuple-underfield.rs:14:9
@@ -33,11 +33,11 @@ LL |         S(_) => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         S(_, _) => {}
-   |            ^^^
+   |            +++
 help: use `..` to ignore all fields
    |
 LL |         S(..) => {}
-   |           ^^
+   |           ~~
 
 error[E0023]: this pattern has 0 fields, but the corresponding tuple struct has 2 fields
   --> $DIR/pat-tuple-underfield.rs:20:9
@@ -51,11 +51,11 @@ LL |         S() => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         S(_, _) => {}
-   |           ^^^^
+   |           ++++
 help: use `..` to ignore all fields
    |
 LL |         S(..) => {}
-   |           ^^
+   |           ++
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
   --> $DIR/pat-tuple-underfield.rs:27:9
@@ -69,7 +69,7 @@ LL |         E::S(x) => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         E::S(x, _) => {}
-   |               ^^^
+   |               +++
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
   --> $DIR/pat-tuple-underfield.rs:32:9
@@ -83,11 +83,11 @@ LL |         E::S(_) => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         E::S(_, _) => {}
-   |               ^^^
+   |               +++
 help: use `..` to ignore all fields
    |
 LL |         E::S(..) => {}
-   |              ^^
+   |              ~~
 
 error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 2 fields
   --> $DIR/pat-tuple-underfield.rs:38:9
@@ -101,11 +101,11 @@ LL |         E::S() => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         E::S(_, _) => {}
-   |              ^^^^
+   |              ++++
 help: use `..` to ignore all fields
    |
 LL |         E::S(..) => {}
-   |              ^^
+   |              ++
 
 error[E0023]: this pattern has 2 fields, but the corresponding tuple struct has 4 fields
   --> $DIR/pat-tuple-underfield.rs:50:9
@@ -119,11 +119,11 @@ LL |         Point4(   a   ,     _    ) => {}
 help: use `_` to explicitly ignore each field
    |
 LL |         Point4(   a   ,     _    , _, _) => {}
-   |                                  ^^^^^^
+   |                                  ++++++
 help: use `..` to ignore the rest of the fields
    |
 LL |         Point4(   a, ..) => {}
-   |                    ^^^^
+   |                    ~~~~
 
 error: aborting due to 8 previous errors
 
diff --git a/src/test/ui/pattern/pattern-error-continue.stderr b/src/test/ui/pattern/pattern-error-continue.stderr
index 44d6a854b3d..3f28ffed291 100644
--- a/src/test/ui/pattern/pattern-error-continue.stderr
+++ b/src/test/ui/pattern/pattern-error-continue.stderr
@@ -19,11 +19,11 @@ LL |         A::D(_) => (),
 help: use this syntax instead
    |
 LL |         A::D => (),
-   |         ^^^^
+   |         ~~~~
 help: a tuple variant with a similar name exists
    |
 LL |         A::B(_) => (),
-   |            ^
+   |            ~
 
 error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
   --> $DIR/pattern-error-continue.rs:17:9
diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
index 29aa0c1c926..02eff28015d 100644
--- a/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
+++ b/src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
@@ -49,7 +49,7 @@ LL |       let E::A = e;
 help: you might want to use `if let` to ignore the variant that isn't matched
    |
 LL |     if let E::A = e { /* */ }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0004]: non-exhaustive patterns: `&B` and `&C` not covered
   --> $DIR/non-exhaustive-defined-here.rs:40:11
@@ -102,7 +102,7 @@ LL |       let E::A = e;
 help: you might want to use `if let` to ignore the variant that isn't matched
    |
 LL |     if let E::A = e { /* */ }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0004]: non-exhaustive patterns: `&&mut &B` and `&&mut &C` not covered
   --> $DIR/non-exhaustive-defined-here.rs:48:11
@@ -198,7 +198,7 @@ LL |       let Opt::Some(ref _x) = e;
 help: you might want to use `if let` to ignore the variant that isn't matched
    |
 LL |     if let Opt::Some(ref _x) = e { /* */ }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 8 previous errors