diff options
| -rw-r--r-- | src/librustc/mir/interpret/error.rs | 11 | ||||
| -rw-r--r-- | src/librustc/mir/interpret/mod.rs | 10 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 6a8cd9b46ae..aa36b55ae37 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -342,8 +342,10 @@ impl fmt::Debug for InvalidProgramInfo<'tcx> { #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum UndefinedBehaviorInfo { - /// Handle cases which for which we do not have a fixed variant. + /// Free-form case. Only for errors that are never caught! Ub(String), + /// Free-form case for experimental UB. Only for errors that are never caught! + UbExperimental(String), /// Unreachable code was executed. Unreachable, } @@ -352,7 +354,7 @@ impl fmt::Debug for UndefinedBehaviorInfo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use UndefinedBehaviorInfo::*; match self { - Ub(ref msg) => + Ub(msg) | UbExperimental(msg) => write!(f, "{}", msg), Unreachable => write!(f, "entered unreachable code"), @@ -362,7 +364,7 @@ impl fmt::Debug for UndefinedBehaviorInfo { #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum UnsupportedOpInfo<'tcx> { - /// Handle cases which for which we do not have a fixed variant. + /// Free-form case. Only for errors that are never caught! Unsupported(String), // -- Everything below is not classified yet -- @@ -406,7 +408,6 @@ pub enum UnsupportedOpInfo<'tcx> { VtableForArgumentlessMethod, ModifiedConstantMemory, ModifiedStatic, - AssumptionNotHeld, TypeNotPrimitive(Ty<'tcx>), ReallocatedWrongMemoryKind(String, String), DeallocatedWrongMemoryKind(String, String), @@ -505,8 +506,6 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> { ModifiedStatic => write!(f, "tried to modify a static's initial value from another static's \ initializer"), - AssumptionNotHeld => - write!(f, "`assume` argument was false"), ReallocateNonBasePtr => write!(f, "tried to reallocate with a pointer not to the beginning of an \ existing object"), diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 65f4c9c47d0..1ec95c29a4a 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -10,6 +10,11 @@ macro_rules! err_unsup { } #[macro_export] +macro_rules! err_unsup_format { + ($($tt:tt)*) => { err_unsup!(Unsupported(format!($($tt)*))) }; +} + +#[macro_export] macro_rules! err_inval { ($($tt:tt)*) => { $crate::mir::interpret::InterpError::InvalidProgram( @@ -28,6 +33,11 @@ macro_rules! err_ub { } #[macro_export] +macro_rules! err_ub_format { + ($($tt:tt)*) => { err_ub!(Ub(format!($($tt)*))) }; +} + +#[macro_export] macro_rules! err_panic { ($($tt:tt)*) => { $crate::mir::interpret::InterpError::Panic( |
