Skip to content

Commit

Permalink
Make sure we don't warn when fields are used
Browse files Browse the repository at this point in the history
rust-lang/rust#85200 changed rust to emit more
unused warnings if fields in a struct are ultimately never read. This
adds a test to make sure that we don't experience these warnings.
  • Loading branch information
erickt committed Dec 8, 2021
1 parent 2a6bddc commit 903d4ff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions argh/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,21 @@ fn redact_arg_values_produces_errors_with_bad_arguments() {
}),
);
}

#[test]
fn redact_arg_values_does_not_warn_if_used() {
#[forbid(unused)]
#[derive(FromArgs, Debug)]
/// Short description
struct Cmd {
#[argh(positional)]
/// speed of cmd
speed: u8,
}

let cmd = Cmd::from_args(&["program-name"], &["5"]).unwrap();
assert_eq!(cmd.speed, 5);

let actual = Cmd::redact_arg_values(&["program-name"], &["5"]).unwrap();
assert_eq!(actual, &["program-name", "speed"]);
}

0 comments on commit 903d4ff

Please sign in to comment.