use std::num::NonZeroU64;
use std::rc::Rc;
use std::time::Instant;
+use std::fmt;
use log::trace;
use rand::rngs::StdRng;
}
}
+impl MayLeak for MiriMemoryKind {
+ #[inline(always)]
+ fn may_leak(self) -> bool {
+ use self::MiriMemoryKind::*;
+ match self {
+ Rust | C | WinHeap | Env => false,
+ Machine | Global => true,
+ }
+ }
+}
+
+impl fmt::Display for MiriMemoryKind {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ use self::MiriMemoryKind::*;
+ match self {
+ Rust => write!(f, "Rust heap"),
+ C => write!(f, "C heap"),
+ WinHeap => write!(f, "Windows heap"),
+ Machine => write!(f, "machine-managed memory"),
+ Env => write!(f, "environment variable"),
+ Global => write!(f, "global"),
+ }
+ }
+}
+
/// Extra per-allocation data
#[derive(Debug, Clone)]
pub struct AllocExtra {
}
}
}
-
-impl MayLeak for MiriMemoryKind {
- #[inline(always)]
- fn may_leak(self) -> bool {
- use self::MiriMemoryKind::*;
- match self {
- Rust | C | WinHeap | Env => false,
- Machine | Global => true,
- }
- }
-}
test(None, |_old_val| { debug_assert!(false); loop {} });
test(None, |_old_val| { unsafe { (1 as *const i32).read() }; loop {} }); // trigger debug-assertion in libstd
- // Cleanup: reset to default hook.
- drop(std::panic::take_hook());
-
eprintln!("Success!"); // Make sure we get this in stderr
}