Skip to content

Commit d6fdfaa

Browse files
committed
hand-held formatting for remaining files
1 parent 4e231ba commit d6fdfaa

File tree

3 files changed

+201
-320
lines changed

3 files changed

+201
-320
lines changed

src/diagnostics.rs

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ impl fmt::Display for TerminationInfo {
2222
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2323
use TerminationInfo::*;
2424
match self {
25-
Exit(code) =>
26-
write!(f, "the evaluated program completed with exit code {}", code),
27-
Abort(msg) =>
28-
write!(f, "{}", msg),
29-
UnsupportedInIsolation(msg) =>
30-
write!(f, "{}", msg),
31-
ExperimentalUb { msg, .. } =>
32-
write!(f, "{}", msg),
33-
Deadlock =>
34-
write!(f, "the evaluated program deadlocked"),
25+
Exit(code) => write!(f, "the evaluated program completed with exit code {}", code),
26+
Abort(msg) => write!(f, "{}", msg),
27+
UnsupportedInIsolation(msg) => write!(f, "{}", msg),
28+
ExperimentalUb { msg, .. } => write!(f, "{}", msg),
29+
Deadlock => write!(f, "the evaluated program deadlocked"),
3530
}
3631
}
3732
}
@@ -60,14 +55,12 @@ pub fn report_error<'tcx, 'mir>(
6055
use TerminationInfo::*;
6156
let title = match info {
6257
Exit(code) => return Some(*code),
63-
Abort(_) =>
64-
"abnormal termination",
65-
UnsupportedInIsolation(_) =>
66-
"unsupported operation",
67-
ExperimentalUb { .. } =>
68-
"Undefined Behavior",
58+
Abort(_) => "abnormal termination",
59+
UnsupportedInIsolation(_) => "unsupported operation",
60+
ExperimentalUb { .. } => "Undefined Behavior",
6961
Deadlock => "deadlock",
7062
};
63+
#[rustfmt::skip]
7164
let helps = match info {
7265
UnsupportedInIsolation(_) =>
7366
vec![format!("pass the flag `-Zmiri-disable-isolation` to disable isolation")],
@@ -81,6 +74,7 @@ pub fn report_error<'tcx, 'mir>(
8174
(title, helps)
8275
}
8376
_ => {
77+
#[rustfmt::skip]
8478
let title = match e.kind() {
8579
Unsupported(_) =>
8680
"unsupported operation",
@@ -93,6 +87,7 @@ pub fn report_error<'tcx, 'mir>(
9387
_ =>
9488
bug!("This error should be impossible in Miri: {}", e),
9589
};
90+
#[rustfmt::skip]
9691
let helps = match e.kind() {
9792
Unsupported(UnsupportedOpInfo::NoMirFor(..)) =>
9893
vec![format!("make sure to use a Miri sysroot, which you can prepare with `cargo miri setup`")],
@@ -120,7 +115,14 @@ pub fn report_error<'tcx, 'mir>(
120115

121116
e.print_backtrace();
122117
let msg = e.to_string();
123-
report_msg(*ecx.tcx, /*error*/true, &format!("{}: {}", title, msg), msg, helps, &ecx.generate_stacktrace());
118+
report_msg(
119+
*ecx.tcx,
120+
/*error*/ true,
121+
&format!("{}: {}", title, msg),
122+
msg,
123+
helps,
124+
&ecx.generate_stacktrace(),
125+
);
124126

125127
// Debug-dump all locals.
126128
for (i, frame) in ecx.active_thread_stack().iter().enumerate() {
@@ -249,7 +251,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
249251
}
250252
// Add popped frame back.
251253
if stacktrace.len() < info.stack_size {
252-
assert!(stacktrace.len() == info.stack_size-1, "we should never pop more than one frame at once");
254+
assert!(
255+
stacktrace.len() == info.stack_size - 1,
256+
"we should never pop more than one frame at once"
257+
);
253258
let frame_info = FrameInfo {
254259
instance: info.instance.unwrap(),
255260
span: info.span,
@@ -259,25 +264,30 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
259264
} else if let Some(instance) = info.instance {
260265
// Adjust topmost frame.
261266
stacktrace[0].span = info.span;
262-
assert_eq!(stacktrace[0].instance, instance, "we should not pop and push a frame in one step");
267+
assert_eq!(
268+
stacktrace[0].instance, instance,
269+
"we should not pop and push a frame in one step"
270+
);
263271
}
264272

265273
// Show diagnostics.
266274
for e in diagnostics.drain(..) {
267275
use NonHaltingDiagnostic::*;
268276
let msg = match e {
269-
CreatedPointerTag(tag) =>
270-
format!("created tag {:?}", tag),
271-
PoppedPointerTag(item) =>
272-
format!("popped tracked tag for item {:?}", item),
273-
CreatedCallId(id) =>
274-
format!("function call with id {}", id),
275-
CreatedAlloc(AllocId(id)) =>
276-
format!("created allocation with id {}", id),
277-
FreedAlloc(AllocId(id)) =>
278-
format!("freed allocation with id {}", id),
277+
CreatedPointerTag(tag) => format!("created tag {:?}", tag),
278+
PoppedPointerTag(item) => format!("popped tracked tag for item {:?}", item),
279+
CreatedCallId(id) => format!("function call with id {}", id),
280+
CreatedAlloc(AllocId(id)) => format!("created allocation with id {}", id),
281+
FreedAlloc(AllocId(id)) => format!("freed allocation with id {}", id),
279282
};
280-
report_msg(*this.tcx, /*error*/false, "tracking was triggered", msg, vec![], &stacktrace);
283+
report_msg(
284+
*this.tcx,
285+
/*error*/ false,
286+
"tracking was triggered",
287+
msg,
288+
vec![],
289+
&stacktrace,
290+
);
281291
}
282292
});
283293
}

src/shims/foreign_items.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
114114
/// by this function.
115115
/// Returns Ok(Some(body)) if processing the foreign item
116116
/// is delegated to another function.
117-
#[rustfmt::skip]
118117
fn emulate_foreign_item(
119118
&mut self,
120119
def_id: DefId,
@@ -149,6 +148,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
149148
let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
150149
return Ok(Some(&*this.load_mir(panic_impl_instance.def, None)?));
151150
}
151+
#[rustfmt::skip]
152152
| "exit"
153153
| "ExitProcess"
154154
=> {
@@ -160,7 +160,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
160160
}
161161
"abort" => {
162162
check_abi(abi, Abi::C { unwind: false })?;
163-
throw_machine_stop!(TerminationInfo::Abort("the program aborted execution".to_owned()))
163+
throw_machine_stop!(TerminationInfo::Abort(
164+
"the program aborted execution".to_owned()
165+
))
164166
}
165167
_ => throw_unsup_format!("can't call (diverging) foreign function: {}", link_name),
166168
},
@@ -175,7 +177,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
175177
// We forward this to the underlying *implementation* in the panic runtime crate.
176178
// Normally, this will be either `libpanic_unwind` or `libpanic_abort`, but it could
177179
// also be a custom user-provided implementation via `#![feature(panic_runtime)]`
178-
"__rust_start_panic" | "__rust_panic_cleanup" => {
180+
#[rustfmt::skip]
181+
"__rust_start_panic" |
182+
"__rust_panic_cleanup" => {
179183
check_abi(abi, Abi::C { unwind: false })?;
180184
// This replicates some of the logic in `inject_panic_runtime`.
181185
// FIXME: is there a way to reuse that logic?
@@ -406,6 +410,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
406410
}
407411

408412
// math functions
413+
#[rustfmt::skip]
409414
| "cbrtf"
410415
| "coshf"
411416
| "sinhf"
@@ -430,6 +435,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
430435
};
431436
this.write_scalar(Scalar::from_u32(f.to_bits()), dest)?;
432437
}
438+
#[rustfmt::skip]
433439
| "_hypotf"
434440
| "hypotf"
435441
| "atan2f"
@@ -448,6 +454,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
448454
};
449455
this.write_scalar(Scalar::from_u32(n.to_bits()), dest)?;
450456
}
457+
#[rustfmt::skip]
451458
| "cbrt"
452459
| "cosh"
453460
| "sinh"
@@ -472,6 +479,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
472479
};
473480
this.write_scalar(Scalar::from_u64(f.to_bits()), dest)?;
474481
}
482+
#[rustfmt::skip]
475483
| "_hypot"
476484
| "hypot"
477485
| "atan2"
@@ -488,6 +496,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
488496
};
489497
this.write_scalar(Scalar::from_u64(n.to_bits()), dest)?;
490498
}
499+
#[rustfmt::skip]
491500
| "_ldexp"
492501
| "ldexp"
493502
| "scalbn"

0 commit comments

Comments
 (0)