From dae2bb765f149b02f6df066ecfb6fb86a2c2b7eb Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Fri, 26 Aug 2022 16:57:42 +0200 Subject: [PATCH] fix: Amend error message when deriving enums Backported from v4. Original change: https://github.com/clap-rs/clap/pull/4118 --- clap_derive/src/derives/value_enum.rs | 2 +- tests/derive_ui/value_enum_non_unit.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clap_derive/src/derives/value_enum.rs b/clap_derive/src/derives/value_enum.rs index b18b665c..06d514f0 100644 --- a/clap_derive/src/derives/value_enum.rs +++ b/clap_derive/src/derives/value_enum.rs @@ -84,7 +84,7 @@ fn lits( None } else { 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 name = attrs.cased_name(); diff --git a/tests/derive_ui/value_enum_non_unit.stderr b/tests/derive_ui/value_enum_non_unit.stderr index 07cc473e..c4395485 100644 --- a/tests/derive_ui/value_enum_non_unit.stderr +++ b/tests/derive_ui/value_enum_non_unit.stderr @@ -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 | 5 | Foo(usize),