From 18d0907dcc8ca5b71e6a70ff7eaed30c3e883d84 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 16 Apr 2020 17:41:28 +0200 Subject: [PATCH 1/2] Miri error messages: avoid try terminology --- src/librustc_middle/mir/interpret/error.rs | 8 ++++---- .../consts/transmute-size-mismatch-before-typeck.stderr | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_middle/mir/interpret/error.rs b/src/librustc_middle/mir/interpret/error.rs index 7844fb108406d..ddff9a57818c7 100644 --- a/src/librustc_middle/mir/interpret/error.rs +++ b/src/librustc_middle/mir/interpret/error.rs @@ -305,7 +305,7 @@ impl fmt::Debug for InvalidProgramInfo<'_> { Layout(ref err) => write!(f, "{}", err), TransmuteSizeDiff(from_ty, to_ty) => write!( f, - "tried to transmute from {:?} to {:?}, but their sizes differed", + "transmuting from {:?} to {:?}, which do not have the same size", from_ty, to_ty ), } @@ -431,7 +431,7 @@ impl fmt::Debug for UndefinedBehaviorInfo { "using uninitialized data, but this operation requires initialized memory" ), DeadLocal => write!(f, "accessing a dead local variable"), - ReadFromReturnPlace => write!(f, "tried to read from the return place"), + ReadFromReturnPlace => write!(f, "reading from return place"), } } } @@ -462,9 +462,9 @@ impl fmt::Debug for UnsupportedOpInfo { match self { Unsupported(ref msg) => write!(f, "{}", msg), ReadForeignStatic(did) => { - write!(f, "tried to read from foreign (extern) static {:?}", did) + write!(f, "cannot read from foreign (extern) static {:?}", did) } - NoMirFor(did) => write!(f, "could not load MIR for {:?}", did), + NoMirFor(did) => write!(f, "cannot load MIR for {:?}", did), ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",), ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"), } diff --git a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr index 5a47771459625..0e55d299c40ed 100644 --- a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr +++ b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr @@ -4,7 +4,7 @@ error: any use of this value will cause an error LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | - | tried to transmute from usize to &[u8], but their sizes differed + | transmuting from usize to &[u8], which do not have the same size | = note: `#[deny(const_err)]` on by default From 250b27d996af6df25065756814188236ef6b0e01 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 16 Apr 2020 18:47:05 +0200 Subject: [PATCH 2/2] bikeshed --- src/librustc_middle/mir/interpret/error.rs | 4 ++-- .../ui/consts/transmute-size-mismatch-before-typeck.stderr | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_middle/mir/interpret/error.rs b/src/librustc_middle/mir/interpret/error.rs index ddff9a57818c7..f058d17a9bf28 100644 --- a/src/librustc_middle/mir/interpret/error.rs +++ b/src/librustc_middle/mir/interpret/error.rs @@ -305,7 +305,7 @@ impl fmt::Debug for InvalidProgramInfo<'_> { Layout(ref err) => write!(f, "{}", err), TransmuteSizeDiff(from_ty, to_ty) => write!( f, - "transmuting from {:?} to {:?}, which do not have the same size", + "transmuting `{}` to `{}` is not possible, because these types do not have the same size", from_ty, to_ty ), } @@ -464,7 +464,7 @@ impl fmt::Debug for UnsupportedOpInfo { ReadForeignStatic(did) => { write!(f, "cannot read from foreign (extern) static {:?}", did) } - NoMirFor(did) => write!(f, "cannot load MIR for {:?}", did), + NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did), ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",), ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"), } diff --git a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr index 0e55d299c40ed..b4970c82adb3e 100644 --- a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr +++ b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr @@ -4,7 +4,7 @@ error: any use of this value will cause an error LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | - | transmuting from usize to &[u8], which do not have the same size + | transmuting `usize` to `&[u8]` is not possible, because these types do not have the same size | = note: `#[deny(const_err)]` on by default