Skip to content

Commit f1f85d2

Browse files
committed
Make sure we don't warn when fields are used
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.
1 parent 317ddbe commit f1f85d2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

argh/tests/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,3 +1288,21 @@ fn redact_arg_values_produces_errors_with_bad_arguments() {
12881288
}),
12891289
);
12901290
}
1291+
1292+
#[test]
1293+
fn redact_arg_values_does_not_warn_if_used() {
1294+
#[forbid(unused)]
1295+
#[derive(FromArgs, Debug)]
1296+
/// Short description
1297+
struct Cmd {
1298+
#[argh(positional)]
1299+
/// speed of cmd
1300+
speed: u8,
1301+
}
1302+
1303+
let cmd = Cmd::from_args(&["program-name"], &["5"]).unwrap();
1304+
assert_eq!(cmd.speed, 5);
1305+
1306+
let actual = Cmd::redact_arg_values(&["program-name"], &["5"]).unwrap();
1307+
assert_eq!(actual, &["program-name", "speed"]);
1308+
}

0 commit comments

Comments
 (0)