]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/std.rs
55e801b93d03e7260f9ab6822a3a305fc4fa9b6d
[rust.git] / tests / run-pass / std.rs
1 #![crate_type = "lib"]
2 #![feature(custom_attribute, box_syntax)]
3 #![allow(dead_code, unused_attributes)]
4
5 use std::cell::{Cell, RefCell};
6 use std::rc::Rc;
7 use std::sync::Arc;
8
9 #[miri_run]
10 fn rc_cell() -> Rc<Cell<i32>> {
11     let r = Rc::new(Cell::new(42));
12     let x = r.get();
13     r.set(x + x);
14     r
15 }
16
17 // TODO(tsion): borrow code needs to evaluate string statics via Lvalue::Static
18 // TODO(tsion): also requires destructors to run for the second borrow to work
19 // #[miri_run]
20 // fn rc_refcell() -> i32 {
21 //     let r = Rc::new(RefCell::new(42));
22 //     *r.borrow_mut() += 10;
23 //     let x = *r.borrow();
24 //     x
25 // }
26
27 #[miri_run]
28 fn arc() -> Arc<i32> {
29     let a = Arc::new(42);
30     a
31 }
32
33 struct Loop(Rc<RefCell<Option<Loop>>>);
34
35 #[miri_run]
36 fn rc_reference_cycle() -> Loop {
37     let a = Rc::new(RefCell::new(None));
38     let b = a.clone();
39     *a.borrow_mut() = Some(Loop(b));
40     Loop(a)
41 }
42
43 #[miri_run]
44 fn true_assert() {
45     assert_eq!(1, 1);
46 }