about summary refs log tree commit diff
path: root/src/test/ui/pattern/pattern-error-continue.stderr
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-05-03 00:32:44 +0200
committerGitHub <noreply@github.com>2021-05-03 00:32:44 +0200
commitb0c7e64de0d2a7dfb172949c4d1cb01ee144025b (patch)
treed87128ca52e4f13850b5cd26d85bfa0445d3b662 /src/test/ui/pattern/pattern-error-continue.stderr
parent37ce3321ebcc901d15583b5b0266d945130e123b (diff)
parent5cc21d9051e421cab8ca271115b9a6d5ea927679 (diff)
downloadrust-b0c7e64de0d2a7dfb172949c4d1cb01ee144025b.tar.gz
rust-b0c7e64de0d2a7dfb172949c4d1cb01ee144025b.zip
Rollup merge of #84818 - ABouttefeux:enum-suggest, r=jackh726
suggestion for unit enum variant when matched with a patern

resolve #84700

add suggestion for code like
```rust
enum FarmAnimal {
    Worm,
    Cow,
    Bull,
    Chicken { num_eggs: usize },
    Dog (String),
}

fn what_does_the_animal_say(animal: &FarmAnimal) {

    let noise = match animal {
        FarmAnimal::Cow(_) => "moo".to_string(),
        _ => todo!()
    };

    println!("{:?} says: {:?}", animal, noise);
}
```

```
error[E0532]: expected tuple struct or tuple variant, found unit variant `FarmAnimal::Cow`
  --> $DIR/issue-84700.rs:15:9
   |
LL |     Cow,
   |     --- `FarmAnimal::Cow` defined here
...
LL |         FarmAnimal::Cow(_) => "moo".to_string(),
   |         ^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FarmAnimal::Cow`
   ```
Diffstat (limited to 'src/test/ui/pattern/pattern-error-continue.stderr')
-rw-r--r--src/test/ui/pattern/pattern-error-continue.stderr16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/test/ui/pattern/pattern-error-continue.stderr b/src/test/ui/pattern/pattern-error-continue.stderr
index 497c93b2949..44d6a854b3d 100644
--- a/src/test/ui/pattern/pattern-error-continue.stderr
+++ b/src/test/ui/pattern/pattern-error-continue.stderr
@@ -9,11 +9,21 @@ error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
    |
 LL |     B(isize, isize),
    |     --------------- similarly named tuple variant `B` defined here
+LL |     C(isize, isize, isize),
+LL |     D
+   |     - `A::D` defined here
 ...
 LL |         A::D(_) => (),
-   |         ^^^-
-   |            |
-   |            help: a tuple variant with a similar name exists: `B`
+   |         ^^^^^^^
+   |
+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