Skip to content

Commit

Permalink
tests(compile_fail): add test for IsVariant must_use
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLostLambda committed Apr 18, 2024
1 parent 9ec416e commit 2b06cfd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ required-features = ["try_unwrap"]
[[test]]
name = "compile_fail"
path = "tests/compile_fail/mod.rs"
required-features = ["as_ref", "debug", "display", "from", "into"]
required-features = ["as_ref", "debug", "display", "from", "into", "try_from", "is_variant"]

[[test]]
name = "no_std"
Expand Down
10 changes: 10 additions & 0 deletions tests/compile_fail/is_variant/must_use.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[derive(derive_more::IsVariant)]
enum MustUse {
Yes,
}

#[forbid(unused_must_use)]
fn main() {
let must_use = MustUse::Yes;
must_use.is_yes();
}
15 changes: 15 additions & 0 deletions tests/compile_fail/is_variant/must_use.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: unused return value of `MustUse::is_yes` that must be used
--> tests/compile_fail/is_variant/must_use.rs:9:5
|
9 | must_use.is_yes();
| ^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> tests/compile_fail/is_variant/must_use.rs:6:10
|
6 | #[forbid(unused_must_use)]
| ^^^^^^^^^^^^^^^
help: use `let _ = ...` to ignore the resulting value
|
9 | let _ = must_use.is_yes();
| +++++++

0 comments on commit 2b06cfd

Please sign in to comment.