From 894a83d4098a5b390484473ab8608fdd113ff9ba Mon Sep 17 00:00:00 2001 From: jumbatm Date: Thu, 30 Apr 2020 14:38:02 +1000 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Ralf Jung Co-Authored-By: Oliver Scherer --- src/librustc_mir/interpret/validity.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index ab440cc5ebab..ac05b3b1ff49 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -48,7 +48,7 @@ macro_rules! try_validation { /// as a kind of validation blacklist: /// /// ```rust -/// let v = try_validation_pat(some_fn(), Foo | Bar | Baz, "some failure", "some place"); +/// 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. /// ``` @@ -59,7 +59,7 @@ macro_rules! try_validation_pat { // 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($p) )|* if true => throw_validation_failure!($what, $where $(, $details)?), - Err(e) => Err::(e)?, + Err(e) => Err::(e)?, } }}; } @@ -843,10 +843,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // Run it. match visitor.visit_value(op) { Ok(()) => Ok(()), - // Allow validation failures to be returned. + // Pass through validation failures. Err(err) if matches!(err.kind, err_ub!(ValidationFailure { .. })) => Err(err), - // Also allow InvalidProgram to be returned, because it's likely that different callers - // will want to do different things in this situation. + // Also pass through InvalidProgram, those just indicate that we could not + // validate and each caller will know best what to do with them. Err(err) if matches!(err.kind, InterpError::InvalidProgram(_)) => Err(err), // Avoid other errors as those do not show *where* in the value the issue lies. Err(err) => bug!("Unexpected error during validation: {}", err),