Skip to content

Commit 11a5148

Browse files
committed
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
2 parents d3f8a0b + b9d4c75 commit 11a5148

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Diff for: src/librustc/mir/interpret/error.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ impl fmt::Debug for InvalidProgramInfo<'tcx> {
342342

343343
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
344344
pub enum UndefinedBehaviorInfo {
345-
/// Handle cases which for which we do not have a fixed variant.
345+
/// Free-form case. Only for errors that are never caught!
346346
Ub(String),
347+
/// Free-form case for experimental UB. Only for errors that are never caught!
348+
UbExperimental(String),
347349
/// Unreachable code was executed.
348350
Unreachable,
349351
}
@@ -352,7 +354,7 @@ impl fmt::Debug for UndefinedBehaviorInfo {
352354
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
353355
use UndefinedBehaviorInfo::*;
354356
match self {
355-
Ub(ref msg) =>
357+
Ub(msg) | UbExperimental(msg) =>
356358
write!(f, "{}", msg),
357359
Unreachable =>
358360
write!(f, "entered unreachable code"),
@@ -362,7 +364,7 @@ impl fmt::Debug for UndefinedBehaviorInfo {
362364

363365
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
364366
pub enum UnsupportedOpInfo<'tcx> {
365-
/// Handle cases which for which we do not have a fixed variant.
367+
/// Free-form case. Only for errors that are never caught!
366368
Unsupported(String),
367369

368370
// -- Everything below is not classified yet --
@@ -406,7 +408,6 @@ pub enum UnsupportedOpInfo<'tcx> {
406408
VtableForArgumentlessMethod,
407409
ModifiedConstantMemory,
408410
ModifiedStatic,
409-
AssumptionNotHeld,
410411
TypeNotPrimitive(Ty<'tcx>),
411412
ReallocatedWrongMemoryKind(String, String),
412413
DeallocatedWrongMemoryKind(String, String),
@@ -505,8 +506,6 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
505506
ModifiedStatic =>
506507
write!(f, "tried to modify a static's initial value from another static's \
507508
initializer"),
508-
AssumptionNotHeld =>
509-
write!(f, "`assume` argument was false"),
510509
ReallocateNonBasePtr =>
511510
write!(f, "tried to reallocate with a pointer not to the beginning of an \
512511
existing object"),

Diff for: src/librustc/mir/interpret/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ macro_rules! err_unsup {
99
};
1010
}
1111

12+
#[macro_export]
13+
macro_rules! err_unsup_format {
14+
($($tt:tt)*) => { err_unsup!(Unsupported(format!($($tt)*))) };
15+
}
16+
1217
#[macro_export]
1318
macro_rules! err_inval {
1419
($($tt:tt)*) => {
@@ -27,6 +32,11 @@ macro_rules! err_ub {
2732
};
2833
}
2934

35+
#[macro_export]
36+
macro_rules! err_ub_format {
37+
($($tt:tt)*) => { err_ub!(Ub(format!($($tt)*))) };
38+
}
39+
3040
#[macro_export]
3141
macro_rules! err_panic {
3242
($($tt:tt)*) => {

0 commit comments

Comments
 (0)