X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fmir%2Finterpret%2Ferror.rs;h=492091a4f25405f5ed1a47161e8fda432e5752cf;hb=270a41c33e6282933ddb3ef405e7089f3e92ea07;hp=e524625f96646b9de4ec0b13a384d89d7ca27a67;hpb=26cbf9158d3c69817fdc9b94949f5d4aa699322b;p=rust.git diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index e524625f966..492091a4f25 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -91,7 +91,7 @@ fn print_backtrace(backtrace: &Backtrace) { impl From for InterpErrorInfo<'_> { fn from(err: ErrorHandled) -> Self { match err { - ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => { + ErrorHandled::Reported(ErrorGuaranteed { .. }) | ErrorHandled::Linted => { err_inval!(ReferencedConstant) } ErrorHandled::TooGeneric => err_inval!(TooGeneric), @@ -160,7 +160,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { TooGeneric => write!(f, "encountered overly generic constant"), ReferencedConstant => write!(f, "referenced constant has errors"), - AlreadyReported(ErrorGuaranteed) => { + AlreadyReported(ErrorGuaranteed { .. }) => { write!(f, "encountered constants with type errors, stopping evaluation") } Layout(ref err) => write!(f, "{}", err), @@ -184,6 +184,8 @@ pub enum CheckInAllocMsg { MemoryAccessTest, /// We are doing pointer arithmetic. PointerArithmeticTest, + /// We are doing pointer offset_from. + OffsetFromTest, /// None of the above -- generic/unspecific inbounds test. InboundsTest, } @@ -199,6 +201,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { CheckInAllocMsg::DerefTest => "dereferencing pointer failed: ", CheckInAllocMsg::MemoryAccessTest => "memory access failed: ", CheckInAllocMsg::PointerArithmeticTest => "pointer arithmetic failed: ", + CheckInAllocMsg::OffsetFromTest => "out-of-bounds offset_from: ", CheckInAllocMsg::InboundsTest => "", } ) @@ -358,6 +361,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { DanglingIntPointer(0, CheckInAllocMsg::InboundsTest) => { write!(f, "null pointer is not a valid pointer for this operation") } + DanglingIntPointer(0, msg) => { + write!(f, "{}null pointer is not a valid pointer", msg) + } DanglingIntPointer(i, msg) => { write!(f, "{}0x{:x} is not a valid pointer", msg, i) } @@ -394,7 +400,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Pointer::new(*alloc, access.access_offset), access.uninit_size.bytes(), pluralize!(access.uninit_size.bytes()), - if access.uninit_size.bytes() != 1 { "are" } else { "is" }, + pluralize!("is", access.uninit_size.bytes()), Pointer::new(*alloc, access.uninit_offset), ), InvalidUninitBytes(None) => write!(