]> git.lizzy.rs Git - rust.git/commitdiff
Move StructWrappedNullablePointer-using test to bugs dir.
authorScott Olson <scott@solson.me>
Mon, 9 May 2016 01:30:17 +0000 (19:30 -0600)
committerScott Olson <scott@solson.me>
Mon, 9 May 2016 01:30:17 +0000 (19:30 -0600)
tests/compile-fail/bugs/struct_wrapped_nullable_pointer.rs [new file with mode: 0644]
tests/run-pass/std.rs

diff --git a/tests/compile-fail/bugs/struct_wrapped_nullable_pointer.rs b/tests/compile-fail/bugs/struct_wrapped_nullable_pointer.rs
new file mode 100644 (file)
index 0000000..880ca42
--- /dev/null
@@ -0,0 +1,23 @@
+#![feature(custom_attribute, box_syntax)]
+#![allow(dead_code, unused_attributes)]
+
+// error-pattern:can't handle destination layout StructWrappedNullablePointer
+
+use std::cell::RefCell;
+use std::rc::Rc;
+
+struct Loop(Rc<RefCell<Option<Loop>>>);
+
+#[miri_run]
+fn rc_reference_cycle() -> Loop {
+    let a = Rc::new(RefCell::new(None));
+    let b = a.clone();
+    *a.borrow_mut() = Some(Loop(b));
+    Loop(a)
+}
+
+#[miri_run]
+fn main() {
+    let x = rc_reference_cycle().0;
+    assert!(x.borrow().is_some());
+}
index 1d4dc8befef8c6e73455f872514e29a948015330..b5bb7c7dbdb9f09a7e5281f16c9ec8580b16eec1 100644 (file)
@@ -1,7 +1,7 @@
 #![feature(custom_attribute, box_syntax)]
 #![allow(dead_code, unused_attributes)]
 
-use std::cell::{Cell, RefCell};
+use std::cell::Cell;
 use std::rc::Rc;
 use std::sync::Arc;
 
@@ -29,16 +29,6 @@ fn arc() -> Arc<i32> {
     a
 }
 
-struct Loop(Rc<RefCell<Option<Loop>>>);
-
-#[miri_run]
-fn rc_reference_cycle() -> Loop {
-    let a = Rc::new(RefCell::new(None));
-    let b = a.clone();
-    *a.borrow_mut() = Some(Loop(b));
-    Loop(a)
-}
-
 #[miri_run]
 fn true_assert() {
     assert_eq!(1, 1);
@@ -46,8 +36,6 @@ fn true_assert() {
 
 #[miri_run]
 fn main() {
-    //let x = rc_reference_cycle().0;
-    //assert!(x.borrow().is_some());
     assert_eq!(*arc(), 42);
     assert_eq!(rc_cell().get(), 84);
 }