Skip to content

Commit 425a99f

Browse files
committed
Update try_validation_pat! doc comment.
1 parent cb96d41 commit 425a99f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/librustc_mir/interpret/validity.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,22 @@ macro_rules! try_validation {
5050
/// matched. Other errors are passed back to the caller, unchanged. This lets you use the patterns
5151
/// as a kind of validation blacklist:
5252
///
53-
/// ```rust
54-
/// let v = try_validation_pat!(some_fn(), Foo | Bar | Baz, "some failure", path);
53+
/// ```
54+
/// let v = try_validation_pat!(some_fn(), some_path, {
55+
/// Foo | Bar | Baz => { "some failure" },
56+
/// });
5557
/// // Failures that match $p are thrown up as validation errors, but other errors are passed back
5658
/// // unchanged.
5759
/// ```
60+
///
61+
/// An additional expected parameter can also be added to the failure message:
62+
///
63+
/// ```
64+
/// let v = try_validation_pat!(some_fn(), some_path, {
65+
/// Foo | Bar | Baz => { "some failure" } expected { "something that wasn't a failure" },
66+
/// });
67+
/// ```
68+
///
5869
macro_rules! try_validation_pat {
5970
($e:expr, $where:expr, { $( $p:pat )|* => { $what:tt } $( expected { $expected:expr } )? $( , )?}) => {{
6071
match $e {

0 commit comments

Comments
 (0)