Auto merge of #63245 - RalfJung:miri-error, r=oli-obk

More Miri error tweaks

* Add `err_` version of the `_format!` macros
* Add `UbExperimental` variant so that Miri can mark some UB as experimental (e.g. Stacked Borrows)

r? @oli-obk
This commit is contained in:
bors 2019-08-05 00:57:19 +00:00
commit 11a51488f0
2 changed files with 15 additions and 6 deletions

View File

@ -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"),

View File

@ -9,6 +9,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)*) => {
@ -27,6 +32,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)*) => {