about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-10 12:03:51 +0000
committerbors <bors@rust-lang.org>2022-08-10 12:03:51 +0000
commit78cbda3bb2cdf80459892bed356553128ef80012 (patch)
treec17c90dacc5ec73003b8970bffdfc327ab211a9d
parent5aef34c01627e4c6a21decca3f442910f173f187 (diff)
parent353f7d539ae628a46ecfa1c316d963633e17e780 (diff)
downloadrust-78cbda3bb2cdf80459892bed356553128ef80012.tar.gz
rust-78cbda3bb2cdf80459892bed356553128ef80012.zip
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.
-rw-r--r--src/helpers.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/helpers.rs b/src/helpers.rs
index 220347ff1b9..7c9f8740eb4 100644
--- a/src/helpers.rs
+++ b/src/helpers.rs
@@ -803,7 +803,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'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.
-        this.tcx.def_path(instance.def_id()).krate == this.tcx.def_path(start_fn).krate
+        // 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.
+        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"
     }
 
     /// Handler that should be called when unsupported functionality is encountered.