diff --git a/clap_derive/src/derives/subcommand.rs b/clap_derive/src/derives/subcommand.rs index 40e6ce45..ba4192b2 100644 --- a/clap_derive/src/derives/subcommand.rs +++ b/clap_derive/src/derives/subcommand.rs @@ -188,12 +188,18 @@ fn gen_from_subcommand( quote!(::std::string::String), quote!(values_of), ) - } else { + } else if is_simple_ty(subty, "OsString") { ( subty.span(), quote!(::std::ffi::OsString), quote!(values_of_os), ) + } else { + abort!( + ty.span(), + "The type must be either `Vec` or `Vec` \ + to be used with `external_subcommand`." + ); } } diff --git a/clap_derive/tests/ui/external_subcommand_wrong_type.stderr b/clap_derive/tests/ui/external_subcommand_wrong_type.stderr index d4ff9026..21d1bb37 100644 --- a/clap_derive/tests/ui/external_subcommand_wrong_type.stderr +++ b/clap_derive/tests/ui/external_subcommand_wrong_type.stderr @@ -1,3 +1,9 @@ +error: The type must be either `Vec` or `Vec` to be used with `external_subcommand`. + --> $DIR/external_subcommand_wrong_type.rs:7:11 + | +7 | Other(Vec), + | ^^^ + error: The type must be either `Vec` or `Vec` to be used with `external_subcommand`. --> $DIR/external_subcommand_wrong_type.rs:13:11 | @@ -10,12 +16,3 @@ error: The enum variant marked with `external_attribute` must be a single-typed 18 | / #[clap(external_subcommand)] 19 | | Other { a: String }, | |_______________________^ - -error[E0308]: mismatched types - --> $DIR/external_subcommand_wrong_type.rs:7:15 - | -7 | Other(Vec), - | ^^^^^^^ expected struct `std::ffi::CString`, found struct `std::ffi::OsString` - | - = note: expected struct `std::vec::Vec` - found struct `std::vec::Vec`