Skip to content

Commit eaeb3bc

Browse files
Merge pull request #18137 from parker-timmerman/miri/fix-test
miri: Add separate initializer for SOFT_ASSERTIONS
2 parents 1728c4d + d1a4629 commit eaeb3bc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ore/src/assert.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,23 @@ use crate::env;
5151
// The rules about what you can do in a `ctor` function are somewhat fuzzy,
5252
// because Rust does not explicitly support constructors. But a scan of the
5353
// stdlib suggests that reading environment variables is safe enough.
54+
#[cfg(not(miri))]
5455
#[ctor::ctor]
5556
pub static SOFT_ASSERTIONS: AtomicBool = {
5657
let default = cfg!(debug_assertions) || env::is_var_truthy("MZ_SOFT_ASSERTIONS");
5758
AtomicBool::new(default)
5859
};
5960

61+
/// Always enable soft assertions when running [Miri].
62+
///
63+
/// Note: Miri also doesn't support global constructors, aka [`ctor`], if it ever does we could
64+
/// get rid of this second definition. See <https://github.com/rust-lang/miri/issues/450> for
65+
/// more details.
66+
///
67+
/// [Miri]: https://github.com/rust-lang/miri
68+
#[cfg(miri)]
69+
pub static SOFT_ASSERTIONS: AtomicBool = AtomicBool::new(true);
70+
6071
/// Asserts that a condition is true if soft assertions are enabled.
6172
///
6273
/// Soft assertions have a small runtime cost even when disabled. See

src/stash/tests/stash.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@ async fn test_stash_table(stash: &mut Stash) {
925925
}
926926

927927
#[test]
928-
#[cfg_attr(miri, ignore)] // Broken, see #18122
929928
fn test_table() {
930929
fn uniqueness_violation(a: &String, b: &String) -> bool {
931930
a == b

0 commit comments

Comments
 (0)