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

Using subcmd field name in subcommand derive #2405

Closed
2 tasks done
omar25h opened this issue Mar 10, 2021 · 0 comments · Fixed by #2406
Closed
2 tasks done

Using subcmd field name in subcommand derive #2405

omar25h opened this issue Mar 10, 2021 · 0 comments · Fixed by #2406
Labels
A-derive Area: #[derive]` macro API C-bug Category: Updating dependencies
Milestone

Comments

@omar25h
Copy link
Contributor

omar25h commented Mar 10, 2021

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

rustc 1.50.0 (cb75ad5db 2021-02-10)

Clap Version

master

Minimal reproducible code

use clap::Clap;

fn main() {
    let _opts = Opts::parse();
}

#[derive(Clap)]
struct Opts {
    #[clap(subcommand)]
    subcmd: SubCommand,
}

#[derive(Clap)]
enum SubCommand {
    Test,
}

Steps to reproduce the bug with the above code

cargo build

Actual Behaviour

error[E0308]: mismatched types
  --> src/main.rs:10:13
   |
10 |     subcmd: SubCommand,
   |             ^^^^^^^^^^ expected enum `Option`, found `&mut SubCommand`
   |
   = note:           expected enum `Option<(&str, &ArgMatches)>`
           found mutable reference `&mut SubCommand`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

Expected Behaviour

The program compiles.

Additional Context

This issue is initially discovered in #2375. Filing as a separate issue because that's different from the original issue described there.

Debug Output

No response

@omar25h omar25h added the C-bug Category: Updating dependencies label Mar 10, 2021
@pksunkara pksunkara added this to the 3.0 milestone Mar 10, 2021
@pksunkara pksunkara added the A-derive Area: #[derive]` macro API label Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API C-bug Category: Updating dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants