Skip to content

Commit

Permalink
Auto merge of #63245 - RalfJung:miri-error, r=oli-obk
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 5, 2019
2 parents d3f8a0b + b9d4c75 commit 11a5148
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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"),
Expand All @@ -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 --
Expand Down Expand Up @@ -406,7 +408,6 @@ pub enum UnsupportedOpInfo<'tcx> {
VtableForArgumentlessMethod,
ModifiedConstantMemory,
ModifiedStatic,
AssumptionNotHeld,
TypeNotPrimitive(Ty<'tcx>),
ReallocatedWrongMemoryKind(String, String),
DeallocatedWrongMemoryKind(String, String),
Expand Down Expand Up @@ -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"),
Expand Down
10 changes: 10 additions & 0 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*) => {
Expand All @@ -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)*) => {
Expand Down

0 comments on commit 11a5148

Please sign in to comment.