rust/tests/ui/suggestions/issue-84700.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
717 B
Rust
Raw Normal View History

// test for suggestion on fieldless enum variant
#[derive(PartialEq, Debug)]
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(),
//~^ ERROR expected tuple struct or tuple variant, found unit variant `FarmAnimal::Cow`
FarmAnimal::Chicken(_) => "cluck, cluck!".to_string(),
//~^ ERROR expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken`
FarmAnimal::Dog{..} => "woof!".to_string(),
_ => todo!()
};
println!("{:?} says: {:?}", animal, noise);
}
fn main() {}