From 4547b622d8d29df964fa2914213088b148c498fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:32 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_middle/src/mir/interpret/error.rs | 36 +++++++----------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'compiler/rustc_middle/src/mir/interpret/error.rs') diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index b5a50cc15..bd9cd53e1 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -16,8 +16,6 @@ pub enum ErrorHandled { /// Already reported an error for this evaluation, and the compilation is /// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`. Reported(ErrorGuaranteed), - /// Already emitted a lint for this evaluation. - Linted, /// Don't emit an error, the evaluation failed because the MIR was generic /// and the substs didn't fully monomorphize it. TooGeneric, @@ -89,18 +87,6 @@ fn print_backtrace(backtrace: &Backtrace) { eprintln!("\n\nAn error occurred in miri:\n{}", backtrace); } -impl From for InterpErrorInfo<'_> { - fn from(err: ErrorHandled) -> Self { - match err { - ErrorHandled::Reported(ErrorGuaranteed { .. }) | ErrorHandled::Linted => { - err_inval!(ReferencedConstant) - } - ErrorHandled::TooGeneric => err_inval!(TooGeneric), - } - .into() - } -} - impl From for InterpErrorInfo<'_> { fn from(err: ErrorGuaranteed) -> Self { InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into() @@ -138,9 +124,6 @@ impl<'tcx> From> for InterpErrorInfo<'tcx> { pub enum InvalidProgramInfo<'tcx> { /// Resolution can fail if we are in a too generic context. TooGeneric, - /// Cannot compute this constant because it depends on another one - /// which already produced an error. - ReferencedConstant, /// Abort in case errors are already reported. AlreadyReported(ErrorGuaranteed), /// An error occurred during layout computation. @@ -158,9 +141,11 @@ impl fmt::Display for InvalidProgramInfo<'_> { use InvalidProgramInfo::*; match self { TooGeneric => write!(f, "encountered overly generic constant"), - ReferencedConstant => write!(f, "referenced constant has errors"), AlreadyReported(ErrorGuaranteed { .. }) => { - write!(f, "encountered constants with type errors, stopping evaluation") + write!( + f, + "an error has already been reported elsewhere (this should not usually be printed)" + ) } Layout(ref err) => write!(f, "{err}"), FnAbiAdjustForForeignAbi(ref err) => write!(f, "{err}"), @@ -401,16 +386,15 @@ impl fmt::Display for UndefinedBehaviorInfo { pub enum UnsupportedOpInfo { /// Free-form case. Only for errors that are never caught! Unsupported(String), - /// Overwriting parts of a pointer; the resulting state cannot be represented in our - /// `Allocation` data structure. See . - PartialPointerOverwrite(Pointer), - /// Attempting to `copy` parts of a pointer to somewhere else; the resulting state cannot be - /// represented in our `Allocation` data structure. See - /// . - PartialPointerCopy(Pointer), // // The variants below are only reachable from CTFE/const prop, miri will never emit them. // + /// Overwriting parts of a pointer; without knowing absolute addresses, the resulting state + /// cannot be represented by the CTFE interpreter. + PartialPointerOverwrite(Pointer), + /// Attempting to `copy` parts of a pointer to somewhere else; without knowing absolute + /// addresses, the resulting state cannot be represented by the CTFE interpreter. + PartialPointerCopy(Pointer), /// Encountered a pointer where we needed raw bytes. ReadPointerAsBytes, /// Accessing thread local statics -- cgit v1.2.3