-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Synopsis & Solution Adds a `#[must_use]` annotation to the static methods generated by `IsVariant`. I also refactored the derive to use `matches!(...)` instead of a manual `match` block with bools, but that's just a style tweak.
- Loading branch information
1 parent
42d5251
commit e0d1698
Showing
6 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
| +++++++ |