about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-02-22 18:29:12 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-02-22 18:30:14 +0000
commita8f8b8de66025e254cbed08a53d5084162605d98 (patch)
tree4c0155688ab4566c857386e1b3dddea6ceb8625b /tests
parentdc37ff82e861428d537ae28e7b92296c4583fb5a (diff)
downloadrust-a8f8b8de66025e254cbed08a53d5084162605d98.tar.gz
rust-a8f8b8de66025e254cbed08a53d5084162605d98.zip
Fix "missing match arm body" suggestion involving `!`
Include the match arm guard in the gated span, so that the suggestion to add a body is correct instead of inserting the body before the guard.

Make the suggestion verbose.

```
error: `match` arm with no body
  --> $DIR/feature-gate-never_patterns.rs:43:9
   |
LL |         Some(_) if false,
   |         ^^^^^^^^^^^^^^^^
   |
help: add a body after the pattern
   |
LL |         Some(_) if false => { todo!() },
   |                          ++++++++++++++
```
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/feature-gates/feature-gate-never_patterns.stderr35
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.stderr7
-rw-r--r--tests/ui/parser/match-arm-without-body.stderr56
3 files changed, 84 insertions, 14 deletions
diff --git a/tests/ui/feature-gates/feature-gate-never_patterns.stderr b/tests/ui/feature-gates/feature-gate-never_patterns.stderr
index dcd5db56da8..473e263c796 100644
--- a/tests/ui/feature-gates/feature-gate-never_patterns.stderr
+++ b/tests/ui/feature-gates/feature-gate-never_patterns.stderr
@@ -58,19 +58,34 @@ error: `match` arm with no body
   --> $DIR/feature-gate-never_patterns.rs:38:9
    |
 LL |         Some(_)
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) => { todo!() }
+   |                 ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/feature-gate-never_patterns.rs:43:9
    |
 LL |         Some(_) if false,
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) if false => { todo!() },
+   |                          ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/feature-gate-never_patterns.rs:45:9
    |
 LL |         Some(_) if false
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) if false => { todo!() }
+   |                          ++++++++++++++
 
 error[E0658]: `!` patterns are experimental
   --> $DIR/feature-gate-never_patterns.rs:50:13
@@ -96,13 +111,23 @@ error: `match` arm with no body
   --> $DIR/feature-gate-never_patterns.rs:64:9
    |
 LL |         Some(_)
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) => { todo!() }
+   |                 ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/feature-gate-never_patterns.rs:70:9
    |
 LL |         Some(_) if false
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) if false => { todo!() }
+   |                          ++++++++++++++
 
 error: a guard on a never pattern will never be run
   --> $DIR/feature-gate-never_patterns.rs:54:19
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
index 1927d80fd72..702e76d59f9 100644
--- a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
@@ -14,7 +14,12 @@ error: `match` arm with no body
   --> $DIR/macro-expand-to-match-arm.rs:14:9
    |
 LL |         arm!(None => {}),
-   |         ^^^^^^^^^^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         arm!(None => {}) => { todo!() },
+   |                          ++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/parser/match-arm-without-body.stderr b/tests/ui/parser/match-arm-without-body.stderr
index 9df8485972f..a65875b787a 100644
--- a/tests/ui/parser/match-arm-without-body.stderr
+++ b/tests/ui/parser/match-arm-without-body.stderr
@@ -68,49 +68,89 @@ error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:7:9
    |
 LL |         Some(_)
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) => { todo!() }
+   |                 ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:30:9
    |
 LL |         Some(_) if true
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) if true => { todo!() }
+   |                         ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:40:9
    |
 LL |         Some(_) if true,
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) if true => { todo!() },
+   |                         ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:45:9
    |
 LL |         Some(_) if true,
-   |         ^^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         Some(_) if true => { todo!() },
+   |                         ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:51:9
    |
 LL |         pat!()
-   |         ^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         pat!() => { todo!() }
+   |                ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:56:9
    |
 LL |         pat!(),
-   |         ^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         pat!() => { todo!() },
+   |                ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:61:9
    |
 LL |         pat!() if true,
-   |         ^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^^^^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         pat!() if true => { todo!() },
+   |                        ++++++++++++++
 
 error: `match` arm with no body
   --> $DIR/match-arm-without-body.rs:72:9
    |
 LL |         pat!(),
-   |         ^^^^^^- help: add a body after the pattern: `=> todo!(),`
+   |         ^^^^^^
+   |
+help: add a body after the pattern
+   |
+LL |         pat!() => { todo!() },
+   |                ++++++++++++++
 
 error: aborting due to 13 previous errors