From cce0cb3c39e9a23cdb6d09d4258de2eded5b8f21 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 1 May 2020 10:56:17 +0200 Subject: [PATCH] use hex for invalid bool and char (consistently with validation) --- src/librustc_middle/mir/interpret/error.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc_middle/mir/interpret/error.rs b/src/librustc_middle/mir/interpret/error.rs index 7710ed025511..40454ce3b2db 100644 --- a/src/librustc_middle/mir/interpret/error.rs +++ b/src/librustc_middle/mir/interpret/error.rs @@ -438,8 +438,12 @@ impl fmt::Display for UndefinedBehaviorInfo { WriteToReadOnly(a) => write!(f, "writing to {} which is read-only", a), DerefFunctionPointer(a) => write!(f, "accessing {} which contains a function", a), ValidationFailure(ref err) => write!(f, "type validation failed: {}", err), - InvalidBool(b) => write!(f, "interpreting an invalid 8-bit value as a bool: {}", b), - InvalidChar(c) => write!(f, "interpreting an invalid 32-bit value as a char: {}", c), + InvalidBool(b) => { + write!(f, "interpreting an invalid 8-bit value as a bool: 0x{:2x}", b) + } + InvalidChar(c) => { + write!(f, "interpreting an invalid 32-bit value as a char: 0x{:8x}", c) + } InvalidDiscriminant(val) => write!(f, "enum value has invalid discriminant: {}", val), InvalidFunctionPointer(p) => { write!(f, "using {} as function pointer but it does not point to a function", p)