Skip to content

Commit 7e21dce

Browse files
committed
remove handle_unsupported_foreign_item helper
1 parent 66fda4a commit 7e21dce

File tree

5 files changed

+10
-36
lines changed

5 files changed

+10
-36
lines changed

src/tools/miri/src/helpers.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_index::IndexVec;
1414
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1515
use rustc_middle::middle::dependency_format::Linkage;
1616
use rustc_middle::middle::exported_symbols::ExportedSymbol;
17-
use rustc_middle::mir;
1817
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
1918
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
2019
use rustc_session::config::CrateType;
@@ -949,21 +948,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
949948
crate_name == "std" || crate_name == "std_miri_test"
950949
}
951950

952-
/// Handler that should be called when an unsupported foreign item is encountered.
953-
/// This function will either panic within the context of the emulated application
954-
/// or return an error in the Miri process context
955-
fn handle_unsupported_foreign_item(&mut self, error_msg: String) -> InterpResult<'tcx, ()> {
956-
let this = self.eval_context_mut();
957-
if this.machine.panic_on_unsupported {
958-
// message is slightly different here to make automated analysis easier
959-
let error_msg = format!("unsupported Miri functionality: {error_msg}");
960-
this.start_panic(error_msg.as_ref(), mir::UnwindAction::Continue)?;
961-
interp_ok(())
962-
} else {
963-
throw_machine_stop!(TerminationInfo::UnsupportedForeignItem(error_msg));
964-
}
965-
}
966-
967951
fn check_abi_and_shim_symbol_clash(
968952
&mut self,
969953
abi: Abi,

src/tools/miri/src/shims/foreign_items.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8383
return interp_ok(Some(body));
8484
}
8585

86-
this.handle_unsupported_foreign_item(format!(
86+
let error_msg = format!(
8787
"can't call foreign function `{link_name}` on OS `{os}`",
8888
os = this.tcx.sess.target.os,
89-
))?;
90-
return interp_ok(None);
89+
);
90+
if this.machine.panic_on_unsupported {
91+
// message is slightly different here to make automated analysis easier
92+
let error_msg = format!("unsupported Miri functionality: {error_msg}");
93+
this.start_panic(error_msg.as_ref(), mir::UnwindAction::Continue)?;
94+
} else {
95+
throw_machine_stop!(TerminationInfo::UnsupportedForeignItem(error_msg));
96+
}
9197
}
9298
}
9399

src/tools/miri/src/shims/unix/linux/foreign_items.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
168168
this.write_int(result.to_i32()?, dest)?;
169169
}
170170
id => {
171-
this.handle_unsupported_foreign_item(format!(
172-
"can't execute syscall with ID {id}"
173-
))?;
174-
return interp_ok(EmulateItemResult::AlreadyJumped);
171+
throw_unsup_format!("can't execute syscall with ID {id}");
175172
}
176173
}
177174
}

src/tools/miri/tests/panic/unsupported_syscall.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/tools/miri/tests/panic/unsupported_syscall.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)