]> git.lizzy.rs Git - rust.git/blobdiff - tests/compile-fail/rc_as_raw.rs
rustup
[rust.git] / tests / compile-fail / rc_as_raw.rs
index 3e6e96456fca6695e3d026571495c01a2672c95c..cb50ca5fcece011f621e643bbffaef13f8b8ccd9 100644 (file)
@@ -1,3 +1,5 @@
+// This should fail even without validation
+// compile-flags: -Zmiri-disable-validation
 #![feature(weak_into_raw)]
 
 use std::rc::{Rc, Weak};
@@ -15,5 +17,5 @@ fn main() {
     drop(strong);
     // But not any more. We can do Weak::as_raw(&weak), but accessing the pointer would lead to
     // undefined behaviour.
-    assert_eq!(42, **unsafe { &*Weak::as_raw(&weak) }); //~ ERROR dangling pointer
+    assert_eq!(42, **unsafe { &*Weak::as_raw(&weak) }); //~ ERROR dereferenced after this allocation got freed
 }