diff --git a/clap_derive/src/derives/subcommand.rs b/clap_derive/src/derives/subcommand.rs index b4a955ffdb0..8d73ce610e9 100644 --- a/clap_derive/src/derives/subcommand.rs +++ b/clap_derive/src/derives/subcommand.rs @@ -1,3 +1,16 @@ +// Copyright 2018 Guillaume Pinot (@TeXitoi) , +// Kevin Knapp (@kbknapp) , and +// Andrew Hobden (@hoverbear) +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// This work was derived from Structopt (https://github.com/TeXitoi/structopt) +// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the +// MIT/Apache 2.0 license. use crate::{ attrs::{Attrs, Kind, Name, DEFAULT_CASING, DEFAULT_ENV_CASING}, derives::args, diff --git a/clap_derive/tests/ui/enum_variant_not_args.rs b/clap_derive/tests/ui/enum_variant_not_args.rs new file mode 100644 index 00000000000..8628b925881 --- /dev/null +++ b/clap_derive/tests/ui/enum_variant_not_args.rs @@ -0,0 +1,9 @@ +#[derive(clap::Clap)] +enum Opt { + Sub(SubCmd), +} + +#[derive(clap::Clap)] +enum SubCmd {} + +fn main() {} diff --git a/clap_derive/tests/ui/enum_variant_not_args.stderr b/clap_derive/tests/ui/enum_variant_not_args.stderr new file mode 100644 index 00000000000..f1a9b207a44 --- /dev/null +++ b/clap_derive/tests/ui/enum_variant_not_args.stderr @@ -0,0 +1,7 @@ +error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied + --> $DIR/enum_variant_not_args.rs:3:9 + | +3 | Sub(SubCmd), + | ^^^^^^ the trait `clap::Args` is not implemented for `SubCmd` + | + = note: required by `augment_args` diff --git a/clap_derive/tests/ui/flatten_on_subcommand.rs b/clap_derive/tests/ui/flatten_on_subcommand.rs new file mode 100644 index 00000000000..ad7cd5a038e --- /dev/null +++ b/clap_derive/tests/ui/flatten_on_subcommand.rs @@ -0,0 +1,10 @@ +#[derive(clap::Clap)] +struct Opt { + #[clap(flatten)] + sub: SubCmd, +} + +#[derive(clap::Clap)] +enum SubCmd {} + +fn main() {} diff --git a/clap_derive/tests/ui/flatten_on_subcommand.stderr b/clap_derive/tests/ui/flatten_on_subcommand.stderr new file mode 100644 index 00000000000..cc753951667 --- /dev/null +++ b/clap_derive/tests/ui/flatten_on_subcommand.stderr @@ -0,0 +1,7 @@ +error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied + --> $DIR/flatten_on_subcommand.rs:3:12 + | +3 | #[clap(flatten)] + | ^^^^^^^ the trait `clap::Args` is not implemented for `SubCmd` + | + = note: required by `augment_args`