diff options
| author | Ralf Jung <post@ralfj.de> | 2024-04-02 08:23:38 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-04-04 09:23:02 +0200 |
| commit | c2e4916cf8b28404f60523f22c096652c172070d (patch) | |
| tree | cd91e0be124995b6f689b2ff49eb1e1385fcd876 | |
| parent | 9e35555474a40d20ebe8d29da56f2d715af21cdd (diff) | |
| download | rust-c2e4916cf8b28404f60523f22c096652c172070d.tar.gz rust-c2e4916cf8b28404f60523f22c096652c172070d.zip | |
adjust frame_in_std to recognize std tests
| -rw-r--r-- | src/tools/miri/src/helpers.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index c12fe0e086d..7ab73e1139e 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -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. |
