Change:
}; macro_rules! throw_validation_failure { <del> ($what:expr, $where:expr, $details:expr) => {{ let mut msg = format!("encountered {}", $what); let where_ = &$where; if !where_.is_empty() { msg.push_str(" at "); write_path(&mut msg, where_); } write!(&mut msg, ", but expected {}", $details).unwrap(); throw_ub!(ValidationFailure(msg)) }}; ($what:expr, $where:expr) => {{ </del> <ins> ($what:expr, $where:expr $(, $details:expr )?) => {{ </ins> let mut msg = format!("encountered {}", $what); let where_ = &$where; if !where_.is_empty() { msg.push_str(" at "); write_path(&mut msg, where_); } <ins> $( write!(&mut msg, ", but expected {}", $details).unwrap(); )? </ins> throw_ub!(ValidationFailure(msg)) }}; } <ins> /// Returns a validation failure for any Err value of $e. // FIXME: Replace all usages of try_validation! with try_validation_pat!. </ins> macro_rules! try_validation { <del> ($e:expr, $what:expr, $where:expr, $details:expr) => {{ match $e { Ok(x) => x, // We re-throw the error, so we are okay with allocation: // this can only slow down builds that fail anyway. Err(_) => throw_validation_failure!($what, $where, $details), } </del> <ins> ($e:expr, $what:expr, $where:expr $(, $details:expr )?) => {{ try_validation_pat!($e, _, $what, $where $(, $details )?) </ins> }}; <del> ($e:expr, $what:expr, $where:expr) => {{ </del> <ins> } /// Like try_validation, but will throw a validation error if any of the patterns in $p are /// matched. Other errors are passed back to the caller, unchanged. This lets you use the patterns /// as a kind of validation blacklist: /// /// ```rust /// let v = try_validation_pat!(some_fn(), Foo | Bar | Baz, "some failure", path); /// // Failures that match $p are thrown up as validation errors, but other errors are passed back /// // unchanged. /// ``` macro_rules! try_validation_pat { ($e:expr, $( $p:pat )|*, $what:expr, $where:expr $(, $details:expr )?) => {{ </ins> match $e { Ok(x) => x, <del> // We re-throw the error, so we are okay with allocation: // this can only slow down builds that fail anyway. Err(_) => throw_validation_failure!($what, $where), </del> <ins> // We catch the error and turn it into a validation failure. We are okay with // allocation here as this can only slow down builds that fail anyway. $( Err(InterpErrorInfo { kind: $p, .. }) )|* if true => throw_validation_failure!($what, $where $(, $details)?), Err(e) => Err::<!, _>(e)?, </ins> } }}; }

Discussion:
The lint should fire on the following code, but it does not: (This testcase now exists in-tree as a FIXME in .) Cc <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
I'd like to take this. claim
I have some plans to follow-up on with some cleanup. That might at least partially resolve this issue here. So it's probably best to wait until after that is done.
All right, landed, so what I planned here is done. The remaining issue is about associated consts. The issue there is that fails, or maybe we are hitting an , but I have not tried further. The issue is all yours, :)
Great! I'll start investigating.
Never mind, that one is already fixed on beta.
got reverted in , so we have to reopen this.