Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add test for flattening struct in enum #2850

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied
--> $DIR/flatten_on_subcommand.rs:3:12
--> $DIR/flatten_enum_in_struct.rs:3:12
|
3 | #[clap(flatten)]
| ^^^^^^^ the trait `clap::Args` is not implemented for `SubCmd`
Expand Down
10 changes: 10 additions & 0 deletions clap_derive/tests/ui/flatten_struct_in_enum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[derive(clap::Parser)]
enum Opt {
#[clap(flatten)]
Sub(SubCmd),
}

#[derive(clap::Parser)]
struct SubCmd {}

fn main() {}
26 changes: 26 additions & 0 deletions clap_derive/tests/ui/flatten_struct_in_enum.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error[E0277]: the trait bound `SubCmd: Subcommand` is not satisfied
--> $DIR/flatten_struct_in_enum.rs:1:10
|
1 | #[derive(clap::Parser)]
| ^^^^^^^^^^^^ the trait `Subcommand` is not implemented for `SubCmd`
|
= note: required by `has_subcommand`
= note: this error originates in the derive macro `clap::Parser` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `SubCmd: Subcommand` is not satisfied
--> $DIR/flatten_struct_in_enum.rs:1:10
|
1 | #[derive(clap::Parser)]
| ^^^^^^^^^^^^ the trait `Subcommand` is not implemented for `SubCmd`
|
= note: required by `augment_subcommands`
= note: this error originates in the derive macro `clap::Parser` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `SubCmd: Subcommand` is not satisfied
--> $DIR/flatten_struct_in_enum.rs:1:10
|
1 | #[derive(clap::Parser)]
| ^^^^^^^^^^^^ the trait `Subcommand` is not implemented for `SubCmd`
|
= note: required by `augment_subcommands_for_update`
= note: this error originates in the derive macro `clap::Parser` (in Nightly builds, run with -Z macro-backtrace for more info)