mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 22:18:23 +03:00
24 lines
504 B
Rust
24 lines
504 B
Rust
#![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());
|
|
}
|