@@ -968,10 +968,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
968
968
969
969
fn frame_in_std ( & self ) -> bool {
970
970
let this = self . eval_context_ref ( ) ;
971
- let Some ( start_fn) = this. tcx . lang_items ( ) . start_fn ( ) else {
972
- // no_std situations
973
- return false ;
974
- } ;
975
971
let frame = this. frame ( ) ;
976
972
// Make an attempt to get at the instance of the function this is inlined from.
977
973
let instance: Option < _ > = try {
@@ -982,13 +978,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
982
978
} ;
983
979
// Fall back to the instance of the function itself.
984
980
let instance = instance. unwrap_or ( frame. instance ) ;
985
- // Now check if this is in the same crate as start_fn.
986
- // As a special exception we also allow unit tests from
987
- // <https://github.com/rust-lang/miri-test-libstd/tree/master/std_miri_test> to call these
988
- // shims .
981
+ // Now check the crate it is in. We could try to be clever here and e.g. check if this is
982
+ // the same crate as `start_fn`, but that would not work for running std tests in Miri, so
983
+ // we'd need some more hacks anyway. So we just check the name of the crate. If someone
984
+ // calls their crate `std` then we'll just let them keep the pieces .
989
985
let frame_crate = this. tcx . def_path ( instance. def_id ( ) ) . krate ;
990
- frame_crate == this. tcx . def_path ( start_fn) . krate
991
- || this. tcx . crate_name ( frame_crate) . as_str ( ) == "std_miri_test"
986
+ let crate_name = this. tcx . crate_name ( frame_crate) ;
987
+ let crate_name = crate_name. as_str ( ) ;
988
+ // On miri-test-libstd, the name of the crate is different.
989
+ crate_name == "std" || crate_name == "std_miri_test"
992
990
}
993
991
994
992
/// Handler that should be called when unsupported functionality is encountered.
0 commit comments