TeXitoi / structopt

Parse command line arguments by defining a struct.
Other
2.7k stars 149 forks source link

Test ui/skip_without_default is broken #505

Closed michiel-de-muynck closed 2 years ago

michiel-de-muynck commented 2 years ago

Currently, the test tests/ui/skip_without_default.rs tests that the following code

use structopt::StructOpt;

#[derive(Debug)]
enum Kind {
    A,
    B,
}

#[derive(StructOpt, Debug)]
#[structopt(name = "test")]
pub struct Opt {
    #[structopt(short)]
    number: u32,
    #[structopt(skip)]
    k: Kind,
}

fn main() {
    let opt = Opt::from_args();
    println!("{:?}", opt);
}

outputs

error[E0277]: the trait bound `Kind: Default` is not satisfied
   --> $DIR/skip_without_default.rs:22:17
    |
22  |     #[structopt(skip)]
    |                 ^^^^ the trait `Default` is not implemented for `Kind`
    |
note: required by `std::default::Default::default`

However, with stable rust version 1.55.0 on Windows (rustc --version outputs rustc 1.55.0 (c8dfcfe04 2021-09-06)) it instead outputs

error[E0277]: the trait bound `Kind: Default` is not satisfied
   --> tests/ui/skip_without_default.rs:22:17
    |
22  |     #[structopt(skip)]
    |                 ^^^^ the trait `Default` is not implemented for `Kind`
    |
note: required by `std::default::Default::default`
   --> $RUST/core/src/default.rs
    |
    |     fn default() -> Self;
    |     ^^^^^^^^^^^^^^^^^^^^^

What I find confusing is that there is a commit that already specifically tries to fix this test for Rust 1.55.0. Does the compiler generate different output on different machines?

TeXitoi commented 2 years ago

Strange, tests pass here, 1.55.0 from rustup on linux