fix: Amend error message when deriving enums

Clarify that only unit variants are fully supported, and that
non-unit variants must be skipped.
This commit is contained in:
Miguel Fernandez 2022-08-26 10:42:28 +02:00
parent 6079a871a0
commit 42cb87b4b6
2 changed files with 2 additions and 2 deletions

View file

@ -84,7 +84,7 @@ fn lits(
None None
} else { } else {
if !matches!(variant.fields, Fields::Unit) { if !matches!(variant.fields, Fields::Unit) {
abort!(variant.span(), "`#[derive(ValueEnum)]` only supports non-unit variants, unless they are skipped"); abort!(variant.span(), "`#[derive(ValueEnum)]` only supports unit variants. Non-unit variants must be skipped");
} }
let fields = attrs.field_methods(false); let fields = attrs.field_methods(false);
let name = attrs.cased_name(); let name = attrs.cased_name();

View file

@ -1,4 +1,4 @@
error: `#[derive(ValueEnum)]` only supports non-unit variants, unless they are skipped error: `#[derive(ValueEnum)]` only supports unit variants. Non-unit variants must be skipped
--> tests/derive_ui/value_enum_non_unit.rs:5:5 --> tests/derive_ui/value_enum_non_unit.rs:5:5
| |
5 | Foo(usize), 5 | Foo(usize),