Skip to content

Commit c987ab9

Browse files
committed
Auto merge of #1048 - Aaron1011:panic-rustup, r=<try>
Rustup for panic changes This gets Miri working again, but doesn't actually implement unwinding
2 parents 09b0a8a + da61b24 commit c987ab9

File tree

7 files changed

+24
-10
lines changed

7 files changed

+24
-10
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
56237d75b4271a8a2e0f47d86ea76ebf6d966152
1+
a333eed7fc0c903df9d6befcfb40af02148bf255

src/bin/cargo-miri.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,12 @@ path = "lib.rs"
318318
let target = get_arg_flag_value("--target");
319319
let print_sysroot = !ask_user && has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
320320
let mut command = xargo();
321-
command.arg("build").arg("-q");
321+
// This may seen somewhat suprising - we are 'building' libstd
322+
// by running (the equivalent of) `cargo check`. It turns out
323+
// that `cargo check` has exactly the behavior that we want:
324+
// it emits crate metadata (including MIR) without running any
325+
// codegen.
326+
command.arg("check").arg("-q");
322327
command.current_dir(&dir);
323328
command.env("RUSTFLAGS", miri::miri_default_args().join(" "));
324329
command.env("XARGO_HOME", dir.to_str().unwrap());

src/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) {
213213
};
214214
e.print_backtrace();
215215
if let Some(frame) = ecx.stack().last() {
216-
let block = &frame.body.basic_blocks()[frame.block];
216+
let block = &frame.body.basic_blocks()[frame.block.unwrap()];
217217
let span = if frame.stmt < block.statements.len() {
218218
block.statements[frame.stmt].source_info.span
219219
} else {

src/machine.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
173173
args: &[OpTy<'tcx, Tag>],
174174
dest: Option<PlaceTy<'tcx, Tag>>,
175175
ret: Option<mir::BasicBlock>,
176+
_unwind: Option<mir::BasicBlock>,
176177
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
177178
ecx.find_fn(instance, args, dest, ret)
178179
}
@@ -194,8 +195,14 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
194195
span: Span,
195196
instance: ty::Instance<'tcx>,
196197
args: &[OpTy<'tcx, Tag>],
197-
dest: PlaceTy<'tcx, Tag>,
198+
dest: Option<PlaceTy<'tcx, Tag>>,
199+
_ret: Option<mir::BasicBlock>,
200+
_unwind: Option<mir::BasicBlock>
198201
) -> InterpResult<'tcx> {
202+
let dest = match dest {
203+
Some(dest) => dest,
204+
None => throw_ub!(Unreachable)
205+
};
199206
ecx.call_intrinsic(span, instance, args, dest)
200207
}
201208

@@ -353,13 +360,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
353360
fn stack_pop(
354361
ecx: &mut InterpCx<'mir, 'tcx, Self>,
355362
extra: stacked_borrows::CallId,
356-
) -> InterpResult<'tcx> {
357-
Ok(ecx
363+
_unwinding: bool
364+
) -> InterpResult<'tcx, StackPopInfo> {
365+
ecx
358366
.memory
359367
.extra
360368
.stacked_borrows
361369
.borrow_mut()
362-
.end_call(extra))
370+
.end_call(extra);
371+
Ok(StackPopInfo::Normal)
363372
}
364373

365374
#[inline(always)]

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
335335
mir,
336336
Some(ret_place),
337337
// Directly return to caller.
338-
StackPopCleanup::Goto(Some(ret)),
338+
StackPopCleanup::Goto { ret: Some(ret), unwind: None },
339339
)?;
340340
let mut args = this.frame().body.args_iter();
341341

src/shims/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2222
dest: PlaceTy<'tcx, Tag>,
2323
) -> InterpResult<'tcx> {
2424
let this = self.eval_context_mut();
25-
if this.emulate_intrinsic(span, instance, args, dest)? {
25+
if this.emulate_intrinsic(span, instance, args, Some(dest))? {
2626
return Ok(());
2727
}
2828
let tcx = &{this.tcx.tcx};

src/shims/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2727
);
2828

2929
// First, run the common hooks also supported by CTFE.
30-
if this.hook_fn(instance, args, dest)? {
30+
if this.hook_panic_fn(instance, args, dest)? {
3131
this.goto_block(ret)?;
3232
return Ok(None);
3333
}

0 commit comments

Comments
 (0)