mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
adjust frame_in_std to recognize std tests
This commit is contained in:
parent
9e35555474
commit
c2e4916cf8
@ -968,10 +968,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
|
||||
fn frame_in_std(&self) -> bool {
|
||||
let this = self.eval_context_ref();
|
||||
let Some(start_fn) = this.tcx.lang_items().start_fn() else {
|
||||
// no_std situations
|
||||
return false;
|
||||
};
|
||||
let frame = this.frame();
|
||||
// Make an attempt to get at the instance of the function this is inlined from.
|
||||
let instance: Option<_> = try {
|
||||
@ -982,13 +978,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
};
|
||||
// Fall back to the instance of the function itself.
|
||||
let instance = instance.unwrap_or(frame.instance);
|
||||
// Now check if this is in the same crate as start_fn.
|
||||
// As a special exception we also allow unit tests from
|
||||
// <https://github.com/rust-lang/miri-test-libstd/tree/master/std_miri_test> to call these
|
||||
// shims.
|
||||
// Now check the crate it is in. We could try to be clever here and e.g. check if this is
|
||||
// the same crate as `start_fn`, but that would not work for running std tests in Miri, so
|
||||
// we'd need some more hacks anyway. So we just check the name of the crate. If someone
|
||||
// calls their crate `std` then we'll just let them keep the pieces.
|
||||
let frame_crate = this.tcx.def_path(instance.def_id()).krate;
|
||||
frame_crate == this.tcx.def_path(start_fn).krate
|
||||
|| this.tcx.crate_name(frame_crate).as_str() == "std_miri_test"
|
||||
let crate_name = this.tcx.crate_name(frame_crate);
|
||||
let crate_name = crate_name.as_str();
|
||||
// On miri-test-libstd, the name of the crate is different.
|
||||
crate_name == "std" || crate_name == "std_miri_test"
|
||||
}
|
||||
|
||||
/// Handler that should be called when unsupported functionality is encountered.
|
||||
|
Loading…
Reference in New Issue
Block a user