Skip to content

Commit ad7089f

Browse files
committed
Auto merge of #1258 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 15dd158 + 87f5495 commit ad7089f

File tree

3 files changed

+41
-27
lines changed

3 files changed

+41
-27
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1edd389cc4c7b5be7a3dd4fe4b986f6017018e54
1+
342c5f33d097b2dc07a2dbc0ca45a37379d2ff60

src/diagnostics.rs

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::cell::RefCell;
2+
use std::fmt;
23

34
use rustc_span::DUMMY_SP;
45

@@ -12,6 +13,26 @@ pub enum TerminationInfo {
1213
ExperimentalUb { msg: String, url: String }
1314
}
1415

16+
impl fmt::Debug for TerminationInfo {
17+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18+
use TerminationInfo::*;
19+
match self {
20+
Exit(code) =>
21+
write!(f, "the evaluated program completed with exit code {}", code),
22+
Abort(None) =>
23+
write!(f, "the evaluated program aborted execution"),
24+
Abort(Some(msg)) =>
25+
write!(f, "the evaluated program aborted execution: {}", msg),
26+
UnsupportedInIsolation(msg) =>
27+
write!(f, "{}", msg),
28+
ExperimentalUb { msg, .. } =>
29+
write!(f, "{}", msg),
30+
}
31+
}
32+
}
33+
34+
impl MachineStopType for TerminationInfo {}
35+
1536
/// Miri specific diagnostics
1637
pub enum NonHaltingDiagnostic {
1738
PoppedTrackedPointerTag(Item),
@@ -25,21 +46,18 @@ pub fn report_error<'tcx, 'mir>(
2546
) -> Option<i64> {
2647
use InterpError::*;
2748

28-
e.print_backtrace();
29-
let (title, msg, helps) = match e.kind {
30-
MachineStop(info) => {
49+
let (title, helps) = match e.kind {
50+
MachineStop(ref info) => {
3151
let info = info.downcast_ref::<TerminationInfo>().expect("invalid MachineStop payload");
3252
use TerminationInfo::*;
33-
let (title, msg) = match info {
53+
let title = match info {
3454
Exit(code) => return Some(*code),
35-
Abort(None) =>
36-
("abnormal termination", format!("the evaluated program aborted execution")),
37-
Abort(Some(msg)) =>
38-
("abnormal termination", format!("the evaluated program aborted execution: {}", msg)),
39-
UnsupportedInIsolation(msg) =>
40-
("unsupported operation", format!("{}", msg)),
41-
ExperimentalUb { msg, .. } =>
42-
("Undefined Behavior", format!("{}", msg)),
55+
Abort(_) =>
56+
"abnormal termination",
57+
UnsupportedInIsolation(_) =>
58+
"unsupported operation",
59+
ExperimentalUb { .. } =>
60+
"Undefined Behavior",
4361
};
4462
let helps = match info {
4563
UnsupportedInIsolation(_) =>
@@ -51,16 +69,16 @@ pub fn report_error<'tcx, 'mir>(
5169
],
5270
_ => vec![],
5371
};
54-
(title, msg, helps)
72+
(title, helps)
5573
}
5674
_ => {
57-
let (title, msg) = match e.kind {
75+
let title = match e.kind {
5876
Unsupported(_) =>
59-
("unsupported operation", e.to_string()),
77+
"unsupported operation",
6078
UndefinedBehavior(_) =>
61-
("Undefined Behavior", e.to_string()),
79+
"Undefined Behavior",
6280
ResourceExhaustion(_) =>
63-
("resource exhaustion", e.to_string()),
81+
"resource exhaustion",
6482
_ =>
6583
bug!("This error should be impossible in Miri: {}", e),
6684
};
@@ -76,9 +94,12 @@ pub fn report_error<'tcx, 'mir>(
7694
],
7795
_ => vec![],
7896
};
79-
(title, msg, helps)
97+
(title, helps)
8098
}
8199
};
100+
101+
e.print_backtrace();
102+
let msg = e.to_string();
82103
report_msg(ecx, &format!("{}: {}", title, msg), msg, &helps, true)
83104
}
84105

src/shims/fs.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, '
114114
let blksize_t_layout = this.libc_ty_layout("blksize_t")?;
115115
let uint32_t_layout = this.libc_ty_layout("uint32_t")?;
116116

117-
// We need to add 32 bits of padding after `st_rdev` if we are on a 64-bit target.
118-
let pad_layout = if this.tcx.sess.target.ptr_width == 64 {
119-
uint32_t_layout
120-
} else {
121-
this.layout_of(this.tcx.mk_unit())?
122-
};
123-
124117
let imms = [
125118
immty_from_uint_checked(0u128, dev_t_layout)?, // st_dev
126119
immty_from_uint_checked(mode, mode_t_layout)?, // st_mode
@@ -129,7 +122,7 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, '
129122
immty_from_uint_checked(0u128, uid_t_layout)?, // st_uid
130123
immty_from_uint_checked(0u128, gid_t_layout)?, // st_gid
131124
immty_from_uint_checked(0u128, dev_t_layout)?, // st_rdev
132-
immty_from_uint_checked(0u128, pad_layout)?, // padding for 64-bit targets
125+
immty_from_uint_checked(0u128, uint32_t_layout)?, // padding
133126
immty_from_uint_checked(access_sec, time_t_layout)?, // st_atime
134127
immty_from_uint_checked(access_nsec, long_layout)?, // st_atime_nsec
135128
immty_from_uint_checked(modified_sec, time_t_layout)?, // st_mtime

0 commit comments

Comments
 (0)