about summary refs log tree commit diff
path: root/library/std/src/sys/unix/stack_overflow.rs
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 /library/std/src/sys/unix/stack_overflow.rs
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 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions