Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Miri error tweaks #63245

Merged
merged 4 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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