Skip to content

Commit 78cbda3

Browse files
committed
Auto merge of #2461 - RalfJung:frame-in-std, r=RalfJung
add special exception for std_miri_test crate to call std-only functions These being the unit tests of std, they have their own copy of `std::sys` and `std::thread`, so the existing check says this is not std. The check is correct but we want to allow this so we just hard-code the crate name. The point of this `frame_in_std` check is to prevent people from directly interacting with shims that aren't really properly implemented, but it doesn't need to be 100% airtight. If someone really wants to call their crate `std_miri_test` in order to access some broken shims... they can keep the pieces.
2 parents 5aef34c + 353f7d5 commit 78cbda3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/helpers.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
803803
// Fall back to the instance of the function itself.
804804
let instance = instance.unwrap_or(frame.instance);
805805
// Now check if this is in the same crate as start_fn.
806-
this.tcx.def_path(instance.def_id()).krate == this.tcx.def_path(start_fn).krate
806+
// As a special exception we also allow unit tests from
807+
// <https://github.com/rust-lang/miri-test-libstd/tree/master/std_miri_test> to call these
808+
// shims.
809+
let frame_crate = this.tcx.def_path(instance.def_id()).krate;
810+
frame_crate == this.tcx.def_path(start_fn).krate
811+
|| this.tcx.crate_name(frame_crate).as_str() == "std_miri_test"
807812
}
808813

809814
/// Handler that should be called when unsupported functionality is encountered.

0 commit comments

Comments
 (0)