Skip to content

Hard to know how to respond to 3.2.0 deprecation messages in the derive API #3822

@Alexhuszagh

Description

@Alexhuszagh

Maintainer's note:


Please complete the following tasks

Rust Version

rustc 1.61.0 (fe5b13d68 2022-05-18)

Clap Version

3.2.1 (or 3.2.0)

Minimal reproducible code

main.rs

use clap::{Parser, Subcommand};

#[derive(Parser, Debug)]
#[clap(version, about, long_about = None)]
struct Cli {
    #[clap(subcommand)]
    command: Commands,
}

#[derive(Subcommand, Debug)]
enum Commands {
    /// Simple Command.
    GetArgs {
        /// Provide verbose diagnostic output.
        #[clap(short, long)]
        verbose: bool,
        /// Sample optional string.
        #[clap(long)]
        value: Option<String>,
        /// Just a list of valies
        list: Vec<String>
    },
}

fn main() {
    let cli = Cli::parse();
    match &cli.command {
        Commands::GetArgs { verbose, value, list } => {
            println!("verbose={:?}", verbose);
            println!("value={:?}", value);
            println!("list={:?}", list);
        }
    }
}

Cargo.toml

[package]
name = "test"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version = "3.2.1", features = ["derive"] }

Steps to reproduce the bug with the above code

Use clap >= 3.2.0, this does not produce any warnings in 3.1.18.

cargo build

Actual Behaviour

warning: use of deprecated unit variant `clap::ArgAction::StoreValue`: Replaced with `ArgAction::Set` or `ArgAction::Append`
  --> src/main.rs:17:9
   |
17 | /         /// Sample optional string.
18 | |         #[clap(long)]
19 | |         value: Option<String>,
   | |_____________________________^
   |
   = note: `#[warn(deprecated)]` on by default

warning: use of deprecated unit variant `clap::ArgAction::StoreValue`: Replaced with `ArgAction::Set` or `ArgAction::Append`
  --> src/main.rs:20:9
   |
20 | /         /// Just a list of valies
21 | |         list: Vec<String>
   | |_________________________^

warning: use of deprecated associated function `clap::ArgMatches::is_present`: Replaced with either `ArgAction::SetTrue` or `ArgMatches::contains_id(...)`
  --> src/main.rs:16:18
   |
16 |         verbose: bool,
   |                  ^^^^

warning: use of deprecated associated function `clap::Arg::<'help>::validator`: Replaced with `Arg::value_parser(...)`
  --> src/main.rs:17:9
   |
17 | /         /// Sample optional string.
18 | |         #[clap(long)]
19 | |         value: Option<String>,
   | |_____________________________^

warning: use of deprecated associated function `clap::Arg::<'help>::multiple_occurrences`: Replaced with `Arg::action` (Issue #3772)
  --> src/main.rs:21:15
   |
21 |         list: Vec<String>
   |               ^^^^^^^^^^^

warning: use of deprecated associated function `clap::Arg::<'help>::validator`: Replaced with `Arg::value_parser(...)`
  --> src/main.rs:20:9
   |
20 | /         /// Just a list of valies
21 | |         list: Vec<String>
   | |_________________________^

warning: `clap` (bin "clap") generated 6 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/clap get-args`

Expected Behaviour

None of these warnings should occur, I believe.

Additional Context

No response

Debug Output

The debug output is the same as the above output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-deriveArea: #[derive]` macro APIC-bugCategory: bugE-mediumCall for participation: Experience needed to fix: Medium / intermediate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions