Fix the external command subtype check

This commit is contained in:
Luca Barbato 2020-06-25 13:52:14 +02:00
parent 81457178fa
commit 081f3e865c
2 changed files with 13 additions and 10 deletions

View file

@ -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<String>` or `Vec<OsString>` \
to be used with `external_subcommand`."
);
}
}

View file

@ -1,3 +1,9 @@
error: The type must be either `Vec<String>` or `Vec<OsString>` to be used with `external_subcommand`.
--> $DIR/external_subcommand_wrong_type.rs:7:11
|
7 | Other(Vec<CString>),
| ^^^
error: The type must be either `Vec<String>` or `Vec<OsString>` 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<CString>),
| ^^^^^^^ expected struct `std::ffi::CString`, found struct `std::ffi::OsString`
|
= note: expected struct `std::vec::Vec<std::ffi::CString>`
found struct `std::vec::Vec<std::ffi::OsString>`