tests: remove uses of Gc.
This commit is contained in:
parent
aa59693565
commit
58bea31ca0
206 changed files with 322 additions and 3702 deletions
|
@ -541,14 +541,6 @@ mod tests {
|
||||||
assert!(y.upgrade().is_none());
|
assert!(y.upgrade().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn gc_inside() {
|
|
||||||
// see issue #11532
|
|
||||||
use std::gc::GC;
|
|
||||||
let a = Rc::new(RefCell::new(box(GC) 1i));
|
|
||||||
assert!(a.try_borrow_mut().is_some());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn weak_self_cyclic() {
|
fn weak_self_cyclic() {
|
||||||
struct Cycle {
|
struct Cycle {
|
||||||
|
|
|
@ -532,7 +532,6 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::fmt::Show;
|
use std::fmt::Show;
|
||||||
use std::prelude::*;
|
use std::prelude::*;
|
||||||
use std::gc::{GC, Gc};
|
|
||||||
use std::hash;
|
use std::hash;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
use test;
|
use test;
|
||||||
|
@ -587,43 +586,6 @@ mod tests {
|
||||||
assert_eq!(*d.get(3), 4);
|
assert_eq!(*d.get(3), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
fn test_boxes() {
|
|
||||||
let a: Gc<int> = box(GC) 5;
|
|
||||||
let b: Gc<int> = box(GC) 72;
|
|
||||||
let c: Gc<int> = box(GC) 64;
|
|
||||||
let d: Gc<int> = box(GC) 175;
|
|
||||||
|
|
||||||
let mut deq = RingBuf::new();
|
|
||||||
assert_eq!(deq.len(), 0);
|
|
||||||
deq.push_front(a);
|
|
||||||
deq.push_front(b);
|
|
||||||
deq.push(c);
|
|
||||||
assert_eq!(deq.len(), 3);
|
|
||||||
deq.push(d);
|
|
||||||
assert_eq!(deq.len(), 4);
|
|
||||||
assert_eq!(deq.front(), Some(&b));
|
|
||||||
assert_eq!(deq.back(), Some(&d));
|
|
||||||
assert_eq!(deq.pop_front(), Some(b));
|
|
||||||
assert_eq!(deq.pop(), Some(d));
|
|
||||||
assert_eq!(deq.pop(), Some(c));
|
|
||||||
assert_eq!(deq.pop(), Some(a));
|
|
||||||
assert_eq!(deq.len(), 0);
|
|
||||||
deq.push(c);
|
|
||||||
assert_eq!(deq.len(), 1);
|
|
||||||
deq.push_front(b);
|
|
||||||
assert_eq!(deq.len(), 2);
|
|
||||||
deq.push(d);
|
|
||||||
assert_eq!(deq.len(), 3);
|
|
||||||
deq.push_front(a);
|
|
||||||
assert_eq!(deq.len(), 4);
|
|
||||||
assert_eq!(*deq.get(0), a);
|
|
||||||
assert_eq!(*deq.get(1), b);
|
|
||||||
assert_eq!(*deq.get(2), c);
|
|
||||||
assert_eq!(*deq.get(3), d);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn test_parameterized<T:Clone + PartialEq + Show>(a: T, b: T, c: T, d: T) {
|
fn test_parameterized<T:Clone + PartialEq + Show>(a: T, b: T, c: T, d: T) {
|
||||||
let mut deq = RingBuf::new();
|
let mut deq = RingBuf::new();
|
||||||
|
@ -755,12 +717,6 @@ mod tests {
|
||||||
test_parameterized::<int>(5, 72, 64, 175);
|
test_parameterized::<int>(5, 72, 64, 175);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_param_at_int() {
|
|
||||||
test_parameterized::<Gc<int>>(box(GC) 5, box(GC) 72,
|
|
||||||
box(GC) 64, box(GC) 175);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_param_taggy() {
|
fn test_param_taggy() {
|
||||||
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
|
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
|
||||||
|
|
|
@ -529,9 +529,8 @@ fn test_rposition() {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_rposition_fail() {
|
fn test_rposition_fail() {
|
||||||
use std::gc::GC;
|
let v = [(box 0i, box 0i), (box 0i, box 0i),
|
||||||
let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i),
|
(box 0i, box 0i), (box 0i, box 0i)];
|
||||||
(box 0i, box(GC) 0i), (box 0i, box(GC) 0i)];
|
|
||||||
let mut i = 0i;
|
let mut i = 0i;
|
||||||
v.iter().rposition(|_elt| {
|
v.iter().rposition(|_elt| {
|
||||||
if i == 2 {
|
if i == 2 {
|
||||||
|
|
|
@ -572,7 +572,6 @@ fn test_repr() {
|
||||||
use std::io::stdio::println;
|
use std::io::stdio::println;
|
||||||
use std::char::is_alphabetic;
|
use std::char::is_alphabetic;
|
||||||
use std::mem::swap;
|
use std::mem::swap;
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn exact_test<T>(t: &T, e:&str) {
|
fn exact_test<T>(t: &T, e:&str) {
|
||||||
let mut m = io::MemWriter::new();
|
let mut m = io::MemWriter::new();
|
||||||
|
@ -587,7 +586,6 @@ fn test_repr() {
|
||||||
exact_test(&1.234f64, "1.234f64");
|
exact_test(&1.234f64, "1.234f64");
|
||||||
exact_test(&("hello"), "\"hello\"");
|
exact_test(&("hello"), "\"hello\"");
|
||||||
|
|
||||||
exact_test(&(box(GC) 10i), "box(GC) 10");
|
|
||||||
exact_test(&(box 10i), "box 10");
|
exact_test(&(box 10i), "box 10");
|
||||||
exact_test(&(&10i), "&10");
|
exact_test(&(&10i), "&10");
|
||||||
let mut x = 10i;
|
let mut x = 10i;
|
||||||
|
@ -601,8 +599,6 @@ fn test_repr() {
|
||||||
"&[\"hi\", \"there\"]");
|
"&[\"hi\", \"there\"]");
|
||||||
exact_test(&(P{a:10, b:1.234}),
|
exact_test(&(P{a:10, b:1.234}),
|
||||||
"repr::P{a: 10, b: 1.234f64}");
|
"repr::P{a: 10, b: 1.234f64}");
|
||||||
exact_test(&(box(GC) P{a:10, b:1.234}),
|
|
||||||
"box(GC) repr::P{a: 10, b: 1.234f64}");
|
|
||||||
exact_test(&(box P{a:10, b:1.234}),
|
exact_test(&(box P{a:10, b:1.234}),
|
||||||
"box repr::P{a: 10, b: 1.234f64}");
|
"box repr::P{a: 10, b: 1.234f64}");
|
||||||
|
|
||||||
|
|
|
@ -411,7 +411,6 @@ mod tests {
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use std::prelude::*;
|
use std::prelude::*;
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::task;
|
use std::task;
|
||||||
|
|
||||||
|
@ -467,11 +466,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tls_multiple_types() {
|
fn test_tls_multiple_types() {
|
||||||
static str_key: Key<String> = &KeyValueKey;
|
static str_key: Key<String> = &KeyValueKey;
|
||||||
static box_key: Key<Gc<()>> = &KeyValueKey;
|
static box_key: Key<Box<int>> = &KeyValueKey;
|
||||||
static int_key: Key<int> = &KeyValueKey;
|
static int_key: Key<int> = &KeyValueKey;
|
||||||
task::spawn(proc() {
|
task::spawn(proc() {
|
||||||
str_key.replace(Some("string data".to_string()));
|
str_key.replace(Some("string data".to_string()));
|
||||||
box_key.replace(Some(box(GC) ()));
|
box_key.replace(Some(box 0));
|
||||||
int_key.replace(Some(42));
|
int_key.replace(Some(42));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -479,13 +478,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tls_overwrite_multiple_types() {
|
fn test_tls_overwrite_multiple_types() {
|
||||||
static str_key: Key<String> = &KeyValueKey;
|
static str_key: Key<String> = &KeyValueKey;
|
||||||
static box_key: Key<Gc<()>> = &KeyValueKey;
|
static box_key: Key<Box<int>> = &KeyValueKey;
|
||||||
static int_key: Key<int> = &KeyValueKey;
|
static int_key: Key<int> = &KeyValueKey;
|
||||||
task::spawn(proc() {
|
task::spawn(proc() {
|
||||||
str_key.replace(Some("string data".to_string()));
|
str_key.replace(Some("string data".to_string()));
|
||||||
str_key.replace(Some("string data 2".to_string()));
|
str_key.replace(Some("string data 2".to_string()));
|
||||||
box_key.replace(Some(box(GC) ()));
|
box_key.replace(Some(box 0));
|
||||||
box_key.replace(Some(box(GC) ()));
|
box_key.replace(Some(box 1));
|
||||||
int_key.replace(Some(42));
|
int_key.replace(Some(42));
|
||||||
// This could cause a segfault if overwriting-destruction is done
|
// This could cause a segfault if overwriting-destruction is done
|
||||||
// with the crazy polymorphic transmute rather than the provided
|
// with the crazy polymorphic transmute rather than the provided
|
||||||
|
@ -498,13 +497,13 @@ mod tests {
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_tls_cleanup_on_failure() {
|
fn test_tls_cleanup_on_failure() {
|
||||||
static str_key: Key<String> = &KeyValueKey;
|
static str_key: Key<String> = &KeyValueKey;
|
||||||
static box_key: Key<Gc<()>> = &KeyValueKey;
|
static box_key: Key<Box<int>> = &KeyValueKey;
|
||||||
static int_key: Key<int> = &KeyValueKey;
|
static int_key: Key<int> = &KeyValueKey;
|
||||||
str_key.replace(Some("parent data".to_string()));
|
str_key.replace(Some("parent data".to_string()));
|
||||||
box_key.replace(Some(box(GC) ()));
|
box_key.replace(Some(box 0));
|
||||||
task::spawn(proc() {
|
task::spawn(proc() {
|
||||||
str_key.replace(Some("string data".to_string()));
|
str_key.replace(Some("string data".to_string()));
|
||||||
box_key.replace(Some(box(GC) ()));
|
box_key.replace(Some(box 2));
|
||||||
int_key.replace(Some(42));
|
int_key.replace(Some(42));
|
||||||
fail!();
|
fail!();
|
||||||
});
|
});
|
||||||
|
|
|
@ -554,23 +554,14 @@ mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::prelude::*;
|
use std::prelude::*;
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn local_heap() {
|
|
||||||
let a = box(GC) 5i;
|
|
||||||
let b = a;
|
|
||||||
assert!(*a == 5);
|
|
||||||
assert!(*b == 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tls() {
|
fn tls() {
|
||||||
local_data_key!(key: Gc<String>)
|
local_data_key!(key: String)
|
||||||
key.replace(Some(box(GC) "data".to_string()));
|
key.replace(Some("data".to_string()));
|
||||||
assert_eq!(key.get().unwrap().as_slice(), "data");
|
assert_eq!(key.get().unwrap().as_slice(), "data");
|
||||||
local_data_key!(key2: Gc<String>)
|
local_data_key!(key2: String)
|
||||||
key2.replace(Some(box(GC) "data".to_string()));
|
key2.replace(Some("data".to_string()));
|
||||||
assert_eq!(key2.get().unwrap().as_slice(), "data");
|
assert_eq!(key2.get().unwrap().as_slice(), "data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,23 +596,6 @@ mod test {
|
||||||
assert!(rx.recv() == 10);
|
assert!(rx.recv() == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn heap_cycles() {
|
|
||||||
use std::cell::RefCell;
|
|
||||||
|
|
||||||
struct List {
|
|
||||||
next: Option<Gc<RefCell<List>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
let a = box(GC) RefCell::new(List { next: None });
|
|
||||||
let b = box(GC) RefCell::new(List { next: Some(a) });
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut a = a.borrow_mut();
|
|
||||||
a.next = Some(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_begin_unwind() {
|
fn test_begin_unwind() {
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
pub struct Entry<A,B> {
|
pub struct Entry<A,B> {
|
||||||
key: A,
|
key: A,
|
||||||
|
@ -19,7 +18,7 @@ pub struct Entry<A,B> {
|
||||||
|
|
||||||
pub struct alist<A,B> {
|
pub struct alist<A,B> {
|
||||||
eq_fn: extern "Rust" fn(A,A) -> bool,
|
eq_fn: extern "Rust" fn(A,A) -> bool,
|
||||||
data: Gc<RefCell<Vec<Entry<A,B>>>>,
|
data: Box<RefCell<Vec<Entry<A,B>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
|
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
|
||||||
|
@ -47,7 +46,7 @@ pub fn new_int_alist<B:'static>() -> alist<int, B> {
|
||||||
fn eq_int(a: int, b: int) -> bool { a == b }
|
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||||
return alist {
|
return alist {
|
||||||
eq_fn: eq_int,
|
eq_fn: eq_int,
|
||||||
data: box(GC) RefCell::new(Vec::new()),
|
data: box RefCell::new(Vec::new()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +56,6 @@ pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
|
||||||
fn eq_int(a: int, b: int) -> bool { a == b }
|
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||||
return alist {
|
return alist {
|
||||||
eq_fn: eq_int,
|
eq_fn: eq_int,
|
||||||
data: box(GC) RefCell::new(Vec::new()),
|
data: box RefCell::new(Vec::new()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,8 @@ pub mod name_pool {
|
||||||
|
|
||||||
pub mod rust {
|
pub mod rust {
|
||||||
pub use name_pool::add;
|
pub use name_pool::add;
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
pub type rt = Gc<()>;
|
pub type rt = Box<()>;
|
||||||
|
|
||||||
pub trait cx {
|
pub trait cx {
|
||||||
fn cx(&self);
|
fn cx(&self);
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::gc::Gc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub type header_map = HashMap<String, Gc<RefCell<Vec<Gc<String>>>>>;
|
pub type header_map = HashMap<String, Rc<RefCell<Vec<Rc<String>>>>>;
|
||||||
|
|
||||||
// the unused ty param is necessary so this gets monomorphized
|
// the unused ty param is necessary so this gets monomorphized
|
||||||
pub fn request<T>(req: &header_map) {
|
pub fn request<T>(req: &header_map) {
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
pub type map = Gc<HashMap<uint, uint>>;
|
pub type map = Box<HashMap<uint, uint>>;
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,6 @@ pub mod testtypes {
|
||||||
VarB(uint, uint)
|
VarB(uint, uint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skipping ty_box
|
|
||||||
|
|
||||||
// Tests ty_uniq (of u8)
|
// Tests ty_uniq (of u8)
|
||||||
pub type FooUniq = Box<u8>;
|
pub type FooUniq = Box<u8>;
|
||||||
|
|
||||||
|
|
|
@ -10,18 +10,15 @@
|
||||||
|
|
||||||
#![feature(unsafe_destructor)]
|
#![feature(unsafe_destructor)]
|
||||||
|
|
||||||
extern crate collections;
|
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
use time::precise_time_s;
|
use time::precise_time_s;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::vec;
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
enum List<T> {
|
enum List<T> {
|
||||||
Nil, Cons(T, Gc<List<T>>)
|
Nil, Cons(T, Box<List<T>>)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UniqueList {
|
enum UniqueList {
|
||||||
|
@ -53,15 +50,13 @@ type nillist = List<()>;
|
||||||
// Filled with things that have to be unwound
|
// Filled with things that have to be unwound
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
managed: Gc<nillist>,
|
|
||||||
unique: Box<nillist>,
|
unique: Box<nillist>,
|
||||||
tuple: (Gc<nillist>, Box<nillist>),
|
vec: Vec<Box<nillist>>,
|
||||||
vec: Vec<Gc<nillist>>,
|
|
||||||
res: r
|
res: r
|
||||||
}
|
}
|
||||||
|
|
||||||
struct r {
|
struct r {
|
||||||
_l: Gc<nillist>,
|
_l: Box<nillist>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
|
@ -69,7 +64,7 @@ impl Drop for r {
|
||||||
fn drop(&mut self) {}
|
fn drop(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn r(l: Gc<nillist>) -> r {
|
fn r(l: Box<nillist>) -> r {
|
||||||
r {
|
r {
|
||||||
_l: l
|
_l: l
|
||||||
}
|
}
|
||||||
|
@ -85,22 +80,17 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
|
||||||
let st = match st {
|
let st = match st {
|
||||||
None => {
|
None => {
|
||||||
State {
|
State {
|
||||||
managed: box(GC) Nil,
|
|
||||||
unique: box Nil,
|
unique: box Nil,
|
||||||
tuple: (box(GC) Nil, box Nil),
|
vec: vec!(box Nil),
|
||||||
vec: vec!(box(GC) Nil),
|
res: r(box Nil)
|
||||||
res: r(box(GC) Nil)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(st) => {
|
Some(st) => {
|
||||||
State {
|
State {
|
||||||
managed: box(GC) Cons((), st.managed),
|
unique: box Cons((), box *st.unique),
|
||||||
unique: box Cons((), box(GC) *st.unique),
|
|
||||||
tuple: (box(GC) Cons((), st.tuple.ref0().clone()),
|
|
||||||
box Cons((), box(GC) *st.tuple.ref1().clone())),
|
|
||||||
vec: st.vec.clone().append(
|
vec: st.vec.clone().append(
|
||||||
&[box(GC) Cons((), *st.vec.last().unwrap())]),
|
&[box Cons((), *st.vec.last().unwrap())]),
|
||||||
res: r(box(GC) Cons((), st.res._l))
|
res: r(box Cons((), st.res._l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,30 +8,25 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct clam {
|
struct clam {
|
||||||
x: Gc<int>,
|
x: Box<int>,
|
||||||
y: Gc<int>,
|
y: Box<int>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fish {
|
struct fish {
|
||||||
a: Gc<int>,
|
a: Box<int>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: clam = clam{x: box(GC) 1, y: box(GC) 2};
|
let a: clam = clam{x: box 1, y: box 2};
|
||||||
let b: clam = clam{x: box(GC) 10, y: box(GC) 20};
|
let b: clam = clam{x: box 10, y: box 20};
|
||||||
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Gc<int>`
|
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
|
||||||
println!("{:?}", z);
|
println!("{}", z);
|
||||||
assert_eq!(z, 21);
|
assert_eq!(z, 21);
|
||||||
let forty: fish = fish{a: box(GC) 40};
|
let forty: fish = fish{a: box 40};
|
||||||
let two: fish = fish{a: box(GC) 2};
|
let two: fish = fish{a: box 2};
|
||||||
let answer: int = forty.a + two.a;
|
let answer: int = forty.a + two.a;
|
||||||
//~^ ERROR binary operation `+` cannot be applied to type `Gc<int>`
|
//~^ ERROR binary operation `+` cannot be applied to type `Box<int>`
|
||||||
println!("{:?}", answer);
|
println!("{}", answer);
|
||||||
assert_eq!(answer, 42);
|
assert_eq!(answer, 42);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct A;
|
|
||||||
|
|
||||||
impl A {
|
|
||||||
fn foo(&mut self) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let a = box(GC) A;
|
|
||||||
a.foo();
|
|
||||||
//~^ ERROR cannot borrow immutable dereference of `Gc` `*a` as mutable
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Verify that managed pointers scope is treated like owned pointers.
|
|
||||||
// regression test for #11586
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{GC, Gc};
|
|
||||||
|
|
||||||
fn foo(x: &Gc<int>) -> &int {
|
|
||||||
match x {
|
|
||||||
&ref y => {
|
|
||||||
&**y // Do not expect an error here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bar() {
|
|
||||||
let a = 3i;
|
|
||||||
let mut y = &a;
|
|
||||||
if true {
|
|
||||||
let x = box(GC) 3i;
|
|
||||||
y = &*x; //~ ERROR `*x` does not live long enough
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_POISON_ON_FREE=1
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn borrow(x: &int, f: |x: &int|) {
|
|
||||||
let before = *x;
|
|
||||||
f(x);
|
|
||||||
let after = *x;
|
|
||||||
assert_eq!(before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct F { f: Box<int> }
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let mut x = box(GC) F {f: box 3};
|
|
||||||
borrow(&*x.f, |b_x| {
|
|
||||||
//~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert_eq!(&(*x.f) as *const int, &(*b_x) as *const int);
|
|
||||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
|
||||||
x = box(GC) F {f: box 4};
|
|
||||||
|
|
||||||
println!("&*b_x = {:p}", &(*b_x));
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert!(&(*x.f) as *const int != &(*b_x) as *const int);
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_POISON_ON_FREE=1
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn borrow(x: &int, f: |x: &int|) {
|
|
||||||
let before = *x;
|
|
||||||
f(x);
|
|
||||||
let after = *x;
|
|
||||||
assert_eq!(before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct F { f: Box<int> }
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let mut x = box box(GC) F{f: box 3};
|
|
||||||
borrow(&*x.f, |b_x| {
|
|
||||||
//~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert_eq!(&(*x.f) as *const int, &(*b_x) as *const int);
|
|
||||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
|
||||||
*x = box(GC) F{f: box 4};
|
|
||||||
|
|
||||||
println!("&*b_x = {:p}", &(*b_x));
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert!(&(*x.f) as *const int != &(*b_x) as *const int);
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_POISON_ON_FREE=1
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn borrow(x: &int, f: |x: &int|) {
|
|
||||||
let before = *x;
|
|
||||||
f(x);
|
|
||||||
let after = *x;
|
|
||||||
assert_eq!(before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let mut x = box(GC) 3;
|
|
||||||
borrow(&*x, |b_x| {
|
|
||||||
//~^ ERROR cannot borrow `x` as mutable because `*x` is also borrowed as immutable
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert_eq!(&(*x) as *const int, &(*b_x) as *const int);
|
|
||||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
|
||||||
x = box(GC) 22;
|
|
||||||
|
|
||||||
println!("&*b_x = {:p}", &(*b_x));
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert!(&(*x) as *const int != &(*b_x) as *const int);
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_POISON_ON_FREE=1
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn testfn(cond: bool) {
|
|
||||||
let mut x = box(GC) 3i;
|
|
||||||
let mut y = box(GC) 4i;
|
|
||||||
|
|
||||||
// borrow x and y
|
|
||||||
let r_x = &*x;
|
|
||||||
let r_y = &*y;
|
|
||||||
let mut r = r_x;
|
|
||||||
let mut exp = 3;
|
|
||||||
|
|
||||||
if cond {
|
|
||||||
r = r_y;
|
|
||||||
exp = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("*r = {}, exp = {}", *r, exp);
|
|
||||||
assert_eq!(*r, exp);
|
|
||||||
|
|
||||||
x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed
|
|
||||||
y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed
|
|
||||||
|
|
||||||
println!("*r = {}, exp = {}", *r, exp);
|
|
||||||
assert_eq!(*r, exp);
|
|
||||||
assert_eq!(x, box(GC) 5i);
|
|
||||||
assert_eq!(y, box(GC) 6i);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
testfn(true);
|
|
||||||
testfn(false);
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_POISON_ON_FREE=1
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn borrow(x: &int, f: |x: &int|) {
|
|
||||||
let before = *x;
|
|
||||||
f(x);
|
|
||||||
let after = *x;
|
|
||||||
assert_eq!(before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct F { f: Box<int> }
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let mut x = box(GC) F {f: box 3};
|
|
||||||
borrow(&*(*x).f, |b_x| {
|
|
||||||
//~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert_eq!(&(*x.f) as *const int, &(*b_x) as *const int);
|
|
||||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
|
||||||
x = box(GC) F {f: box 4};
|
|
||||||
|
|
||||||
println!("&*b_x = {:p}", &(*b_x));
|
|
||||||
assert_eq!(*b_x, 3);
|
|
||||||
assert!(&(*x.f) as *const int != &(*b_x) as *const int);
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn f<T>(x: T) -> Gc<T> {
|
|
||||||
box(GC) x //~ ERROR the parameter type `T` may not live long enough
|
|
||||||
}
|
|
||||||
|
|
||||||
fn g<T:'static>(x: T) -> Gc<T> {
|
|
||||||
box(GC) x // ok
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -11,7 +11,6 @@
|
||||||
// Verifies all possible restrictions for static items values.
|
// Verifies all possible restrictions for static items values.
|
||||||
|
|
||||||
use std::kinds::marker;
|
use std::kinds::marker;
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct WithDtor;
|
struct WithDtor;
|
||||||
|
|
||||||
|
@ -124,9 +123,6 @@ static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) =
|
||||||
static mut STATIC17: SafeEnum = Variant1;
|
static mut STATIC17: SafeEnum = Variant1;
|
||||||
//~^ ERROR mutable static items are not allowed to have destructors
|
//~^ ERROR mutable static items are not allowed to have destructors
|
||||||
|
|
||||||
static STATIC18: Gc<SafeStruct> = box(GC) SafeStruct{field1: Variant1, field2: Variant2(0)};
|
|
||||||
//~^ ERROR static items are not allowed to have custom pointers
|
|
||||||
|
|
||||||
static STATIC19: Box<int> = box 3;
|
static STATIC19: Box<int> = box 3;
|
||||||
//~^ ERROR static items are not allowed to have custom pointers
|
//~^ ERROR static items are not allowed to have custom pointers
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// Testing that we can't store a reference it task-local storage
|
// Testing that we can't store a reference in task-local storage
|
||||||
|
|
||||||
use std::gc::{GC, Gc};
|
local_data_key!(key: Box<&int>)
|
||||||
|
|
||||||
local_data_key!(key: Gc<&int>)
|
|
||||||
//~^ ERROR missing lifetime specifier
|
//~^ ERROR missing lifetime specifier
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -8,12 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::gc::{GC,Gc};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: Box<int> = box 0;
|
let x: Box<int> = box 0;
|
||||||
let y: Gc<int> = box (GC) 0;
|
|
||||||
|
|
||||||
println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
|
println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
|
||||||
println!("{}", y + 1); //~ ERROR binary operation `+` cannot be applied to type `Gc<int>`
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,14 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
// test that autoderef of a type like this does not
|
// test that autoderef of a type like this does not
|
||||||
// cause compiler to loop. Note that no instances
|
// cause compiler to loop. Note that no instances
|
||||||
// of such a type could ever be constructed.
|
// of such a type could ever be constructed.
|
||||||
struct t { //~ ERROR this type cannot be instantiated
|
struct S { //~ ERROR this type cannot be instantiated
|
||||||
x: x,
|
x: X,
|
||||||
to_str: (),
|
to_str: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct x(Gc<t>); //~ ERROR this type cannot be instantiated
|
struct X(Box<S>); //~ ERROR this type cannot be instantiated
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -8,17 +8,14 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
struct P { child: Option<Box<P>> }
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
struct P { child: Option<Gc<P>> }
|
|
||||||
trait PTrait {
|
trait PTrait {
|
||||||
fn getChildOption(&self) -> Option<Gc<P>>;
|
fn getChildOption(&self) -> Option<Box<P>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PTrait for P {
|
impl PTrait for P {
|
||||||
fn getChildOption(&self) -> Option<Gc<P>> {
|
fn getChildOption(&self) -> Option<Box<P>> {
|
||||||
static childVal: Gc<P> = self.child.get();
|
static childVal: Box<P> = self.child.get();
|
||||||
//~^ ERROR attempt to use a non-constant value in a constant
|
//~^ ERROR attempt to use a non-constant value in a constant
|
||||||
fail!();
|
fail!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
mod my_mod {
|
mod my_mod {
|
||||||
pub struct MyStruct {
|
pub struct MyStruct {
|
||||||
priv_field: int
|
priv_field: int
|
||||||
|
@ -29,11 +27,8 @@ fn main() {
|
||||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||||
let _woohoo = (box my_struct).priv_field;
|
let _woohoo = (box my_struct).priv_field;
|
||||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||||
let _woohoo = (box(GC) my_struct).priv_field;
|
|
||||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
|
||||||
(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
||||||
(box my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
(box my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
||||||
(box(GC) my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
|
||||||
let nope = my_struct.priv_field;
|
let nope = my_struct.priv_field;
|
||||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,11 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
struct BarStruct;
|
struct BarStruct;
|
||||||
|
|
||||||
impl<'a> BarStruct {
|
impl<'a> BarStruct {
|
||||||
fn foo(&'a mut self) -> Gc<BarStruct> { self }
|
fn foo(&'a mut self) -> Box<BarStruct> { self }
|
||||||
//~^ ERROR: error: mismatched types: expected `Gc<BarStruct>`, found `&'a mut BarStruct
|
//~^ ERROR: error: mismatched types: expected `Box<BarStruct>`, found `&'a mut BarStruct
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -10,10 +10,9 @@
|
||||||
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
// Regresion test for issue 7364
|
// Regresion test for issue 7364
|
||||||
static managed: Gc<RefCell<int>> = box(GC) RefCell::new(0);
|
static boxed: Box<RefCell<int>> = box RefCell::new(0);
|
||||||
//~^ ERROR static items are not allowed to have custom pointers
|
//~^ ERROR static items are not allowed to have custom pointers
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
fn assert_copy<T:Copy>() { }
|
fn assert_copy<T:Copy>() { }
|
||||||
trait Dummy { }
|
trait Dummy { }
|
||||||
|
@ -76,8 +75,7 @@ fn test<'a,T,U:Copy>(_: &'a int) {
|
||||||
// structs containing non-POD are not ok
|
// structs containing non-POD are not ok
|
||||||
assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::kinds::Copy` is not implemented
|
assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::kinds::Copy` is not implemented
|
||||||
|
|
||||||
// managed or ref counted types are not ok
|
// ref counted types are not ok
|
||||||
assert_copy::<Gc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
|
|
||||||
assert_copy::<Rc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
|
assert_copy::<Rc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
f: Gc<int>,
|
f: Rc<int>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Foo {
|
impl Drop for Foo {
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
use std::rc::Rc;
|
||||||
|
|
||||||
fn foo(_x: Gc<uint>) {}
|
fn foo(_x: Rc<uint>) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = box(GC) 3u;
|
let x = Rc::new(3u);
|
||||||
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
|
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
|
||||||
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
|
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
|
||||||
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
|
let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
#![forbid(heap_memory)]
|
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct Foo {
|
|
||||||
x: Gc<int>, //~ ERROR type uses managed
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Bar { x: Box<int> } //~ ERROR type uses owned
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _x : Bar = Bar {x : box 10i}; //~ ERROR type uses owned
|
|
||||||
|
|
||||||
box(GC) 2i; //~ ERROR type uses managed
|
|
||||||
|
|
||||||
box 2i; //~ ERROR type uses owned
|
|
||||||
fn g(_: Box<Clone>) {} //~ ERROR type uses owned
|
|
||||||
proc() {}; //~ ERROR type uses owned
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
|
||||||
#![forbid(managed_heap_memory)]
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct Foo {
|
|
||||||
x: Gc<int> //~ ERROR type uses managed
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _x : Foo = Foo {x : box(GC) 10};
|
|
||||||
//~^ ERROR type uses managed
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
// Tests that the new `box` syntax works with unique pointers and GC pointers.
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
use std::boxed::{Box, HEAP};
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let x: Gc<int> = box(HEAP) 2; //~ ERROR mismatched types
|
|
||||||
let y: Gc<int> = box(HEAP)(1 + 2); //~ ERROR mismatched types
|
|
||||||
let z: Box<int> = box(GC)(4 + 5); //~ ERROR mismatched types
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
|
|
||||||
#![feature(unsafe_destructor)]
|
#![feature(unsafe_destructor)]
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::gc::{Gc, GC};
|
use std::rc::Rc;
|
||||||
|
|
||||||
struct Port<T>(Gc<T>);
|
#[deriving(Show)]
|
||||||
|
struct Port<T>(Rc<T>);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[deriving(Show)]
|
||||||
struct foo {
|
struct foo {
|
||||||
_x: Port<()>,
|
_x: Port<()>,
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let x = foo(Port(box(GC) ()));
|
let x = foo(Port(Rc::new(())));
|
||||||
|
|
||||||
task::spawn(proc() {
|
task::spawn(proc() {
|
||||||
let y = x;
|
let y = x;
|
||||||
//~^ ERROR `core::kinds::Send` is not implemented
|
//~^ ERROR `core::kinds::Send` is not implemented
|
||||||
println!("{:?}", y);
|
println!("{}", y);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let f;
|
let f;
|
||||||
let g;
|
let g;
|
||||||
g = f;
|
g = f;
|
||||||
f = box(GC) g; //~ ERROR cyclic type of infinite size
|
f = box g; //~ ERROR cyclic type of infinite size
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let f;
|
let f;
|
||||||
f = box(GC) f; //~ ERROR cyclic type of infinite size
|
f = box f; //~ ERROR cyclic type of infinite size
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
#![feature(unsafe_destructor)]
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::cell::Cell;
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct r {
|
|
||||||
i: Gc<Cell<int>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unsafe_destructor]
|
|
||||||
impl Drop for r {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
self.i.set(self.i.get() + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn r(i: Gc<Cell<int>>) -> r {
|
|
||||||
r {
|
|
||||||
i: i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct A {
|
|
||||||
y: r,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let i = box(GC) Cell::new(0);
|
|
||||||
{
|
|
||||||
// Can't do this copy
|
|
||||||
let x = box box box A {y: r(i)};
|
|
||||||
let _z = x.clone(); //~ ERROR not implemented
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
||||||
println!("{:?}", *i);
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Test no-special rooting is used for managed boxes
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn testfn(cond: bool) {
|
|
||||||
let mut x = box(GC) 3i;
|
|
||||||
let mut y = box(GC) 4i;
|
|
||||||
|
|
||||||
let mut a = &*x;
|
|
||||||
|
|
||||||
let mut exp = 3i;
|
|
||||||
if cond {
|
|
||||||
a = &*y;
|
|
||||||
|
|
||||||
exp = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed
|
|
||||||
y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed
|
|
||||||
assert_eq!(*a, exp);
|
|
||||||
assert_eq!(x, box(GC) 5i);
|
|
||||||
assert_eq!(y, box(GC) 6i);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {}
|
|
|
@ -9,8 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
struct point {
|
struct point {
|
||||||
x: int,
|
x: int,
|
||||||
y: int,
|
y: int,
|
||||||
|
@ -20,7 +18,7 @@ fn x_coord<'r>(p: &'r point) -> &'r int {
|
||||||
return &p.x;
|
return &p.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo<'a>(p: Gc<point>) -> &'a int {
|
fn foo<'a>(p: Box<point>) -> &'a int {
|
||||||
let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough
|
let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough
|
||||||
assert_eq!(*xc, 3);
|
assert_eq!(*xc, 3);
|
||||||
return xc;
|
return xc;
|
||||||
|
|
|
@ -9,11 +9,9 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
fn borrow<T>(x: &T) -> &T {x}
|
fn borrow<T>(x: &T) -> &T {x}
|
||||||
|
|
||||||
fn foo(cond: || -> bool, make_box: || -> Gc<int>) {
|
fn foo(cond: || -> bool, make_box: || -> Box<int>) {
|
||||||
let mut y: ∫
|
let mut y: ∫
|
||||||
loop {
|
loop {
|
||||||
let x = make_box();
|
let x = make_box();
|
||||||
|
|
|
@ -12,27 +12,25 @@
|
||||||
// Check that we correctly infer that b and c must be region
|
// Check that we correctly infer that b and c must be region
|
||||||
// parameterized because they reference a which requires a region.
|
// parameterized because they reference a which requires a region.
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
type a<'a> = &'a int;
|
type a<'a> = &'a int;
|
||||||
type b<'a> = Gc<a<'a>>;
|
type b<'a> = Box<a<'a>>;
|
||||||
|
|
||||||
struct c<'a> {
|
struct c<'a> {
|
||||||
f: Gc<b<'a>>
|
f: Box<b<'a>>
|
||||||
}
|
}
|
||||||
|
|
||||||
trait set_f<'a> {
|
trait set_f<'a> {
|
||||||
fn set_f_ok(&mut self, b: Gc<b<'a>>);
|
fn set_f_ok(&mut self, b: Box<b<'a>>);
|
||||||
fn set_f_bad(&mut self, b: Gc<b>);
|
fn set_f_bad(&mut self, b: Box<b>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> set_f<'a> for c<'a> {
|
impl<'a> set_f<'a> for c<'a> {
|
||||||
fn set_f_ok(&mut self, b: Gc<b<'a>>) {
|
fn set_f_ok(&mut self, b: Box<b<'a>>) {
|
||||||
self.f = b;
|
self.f = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_f_bad(&mut self, b: Gc<b>) {
|
fn set_f_bad(&mut self, b: Box<b>) {
|
||||||
self.f = b; //~ ERROR mismatched types: expected `Gc<Gc<&'a int>>`, found `Gc<Gc<&int>>`
|
self.f = b; //~ ERROR mismatched types: expected `Box<Box<&'a int>>`, found `Box<Box<&int>>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,10 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn f<T:'static>(_: T) {}
|
fn f<T:'static>(_: T) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = box(GC) 3i;
|
let x = box 3i;
|
||||||
f(x);
|
f(x);
|
||||||
let x = &3i; //~ ERROR borrowed value does not live long enough
|
let x = &3i; //~ ERROR borrowed value does not live long enough
|
||||||
f(x);
|
f(x);
|
||||||
|
|
|
@ -11,13 +11,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct Foo<'a> {
|
struct Foo<'a> {
|
||||||
x: &'a int
|
x: &'a int
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let f = Foo { x: &*(box(GC) 3) }; //~ ERROR borrowed value does not live long enough
|
let f = Foo { x: &*(box 3) }; //~ ERROR borrowed value does not live long enough
|
||||||
assert_eq!(*f.x, 3);
|
assert_eq!(*f.x, 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,16 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
struct foo {
|
struct foo {
|
||||||
a: int,
|
a: int,
|
||||||
b: int,
|
b: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
type bar = Gc<foo>;
|
type bar = Box<foo>;
|
||||||
|
|
||||||
fn want_foo(f: foo) {}
|
fn want_foo(f: foo) {}
|
||||||
fn have_bar(b: bar) {
|
fn have_bar(b: bar) {
|
||||||
want_foo(b); //~ ERROR (expected struct foo, found Gc-ptr)
|
want_foo(b); //~ ERROR (expected struct foo, found box)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -9,15 +9,13 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
trait Mumbo {
|
trait Mumbo {
|
||||||
fn jumbo(&self, x: Gc<uint>) -> uint;
|
fn jumbo(&self, x: &uint) -> uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mumbo for uint {
|
impl Mumbo for uint {
|
||||||
// Cannot have a larger effect than the trait:
|
// Cannot have a larger effect than the trait:
|
||||||
unsafe fn jumbo(&self, x: Gc<uint>) { *self + *x; }
|
unsafe fn jumbo(&self, x: &uint) { *self + *x; }
|
||||||
//~^ ERROR expected normal fn, found unsafe fn
|
//~^ ERROR expected normal fn, found unsafe fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
use std::rc::Rc;
|
||||||
|
|
||||||
fn f<T:Send>(_i: T) {
|
fn f<T:Send>(_i: T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let i = box box(GC) 100i;
|
let i = box Rc::new(100i);
|
||||||
f(i); //~ ERROR `core::kinds::Send` is not implemented
|
f(i); //~ ERROR `core::kinds::Send` is not implemented
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,15 @@
|
||||||
|
|
||||||
#![feature(unsafe_destructor)]
|
#![feature(unsafe_destructor)]
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct r {
|
#[deriving(Show)]
|
||||||
i: Gc<Cell<int>>,
|
struct r<'a> {
|
||||||
|
i: &'a Cell<int>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl Drop for r {
|
impl<'a> Drop for r<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.i.set(self.i.get() + 1);
|
self.i.set(self.i.get() + 1);
|
||||||
|
@ -31,13 +30,13 @@ fn f<T>(_i: Vec<T> , _j: Vec<T> ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let i1 = box(GC) Cell::new(0);
|
let i1 = &Cell::new(0);
|
||||||
let i2 = box(GC) Cell::new(1);
|
let i2 = &Cell::new(1);
|
||||||
let r1 = vec!(box r { i: i1 });
|
let r1 = vec!(box r { i: i1 });
|
||||||
let r2 = vec!(box r { i: i2 });
|
let r2 = vec!(box r { i: i2 });
|
||||||
f(r1.clone(), r2.clone());
|
f(r1.clone(), r2.clone());
|
||||||
//~^ ERROR the trait `core::clone::Clone` is not implemented
|
//~^ ERROR the trait `core::clone::Clone` is not implemented
|
||||||
//~^^ ERROR the trait `core::clone::Clone` is not implemented
|
//~^^ ERROR the trait `core::clone::Clone` is not implemented
|
||||||
println!("{:?}", (r2, i1.get()));
|
println!("{}", (r2, i1.get()));
|
||||||
println!("{:?}", (r1, i2.get()));
|
println!("{}", (r1, i2.get()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
// Test that a class with an unsendable field can't be
|
// Test that a class with an unsendable field can't be
|
||||||
// sent
|
// sent
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
use std::rc::Rc;
|
||||||
|
|
||||||
struct foo {
|
struct foo {
|
||||||
i: int,
|
i: int,
|
||||||
j: Gc<String>,
|
j: Rc<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(i:int, j: Gc<String>) -> foo {
|
fn foo(i:int, j: Rc<String>) -> foo {
|
||||||
foo {
|
foo {
|
||||||
i: i,
|
i: i,
|
||||||
j: j
|
j: j
|
||||||
|
@ -29,5 +29,5 @@ fn foo(i:int, j: Gc<String>) -> foo {
|
||||||
fn main() {
|
fn main() {
|
||||||
let cat = "kitty".to_string();
|
let cat = "kitty".to_string();
|
||||||
let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented
|
let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented
|
||||||
tx.send(foo(42, box(GC) (cat))); //~ ERROR `core::kinds::Send` is not implemented
|
tx.send(foo(42, Rc::new(cat))); //~ ERROR `core::kinds::Send` is not implemented
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// ignore-android: FIXME(#10381)
|
|
||||||
|
|
||||||
|
|
||||||
// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only
|
|
||||||
// its numerical value.
|
|
||||||
|
|
||||||
// compile-flags:-g
|
|
||||||
|
|
||||||
// === GDB TESTS ===================================================================================
|
|
||||||
|
|
||||||
// gdb-command:rbreak zzz
|
|
||||||
// gdb-command:run
|
|
||||||
// gdb-command:finish
|
|
||||||
// gdb-command:print *bool_ref
|
|
||||||
// gdb-check:$1 = true
|
|
||||||
|
|
||||||
// gdb-command:print *int_ref
|
|
||||||
// gdb-check:$2 = -1
|
|
||||||
|
|
||||||
// gdb-command:print *char_ref
|
|
||||||
// gdb-check:$3 = 97
|
|
||||||
|
|
||||||
// gdb-command:print/d *i8_ref
|
|
||||||
// gdb-check:$4 = 68
|
|
||||||
|
|
||||||
// gdb-command:print *i16_ref
|
|
||||||
// gdb-check:$5 = -16
|
|
||||||
|
|
||||||
// gdb-command:print *i32_ref
|
|
||||||
// gdb-check:$6 = -32
|
|
||||||
|
|
||||||
// gdb-command:print *i64_ref
|
|
||||||
// gdb-check:$7 = -64
|
|
||||||
|
|
||||||
// gdb-command:print *uint_ref
|
|
||||||
// gdb-check:$8 = 1
|
|
||||||
|
|
||||||
// gdb-command:print/d *u8_ref
|
|
||||||
// gdb-check:$9 = 100
|
|
||||||
|
|
||||||
// gdb-command:print *u16_ref
|
|
||||||
// gdb-check:$10 = 16
|
|
||||||
|
|
||||||
// gdb-command:print *u32_ref
|
|
||||||
// gdb-check:$11 = 32
|
|
||||||
|
|
||||||
// gdb-command:print *u64_ref
|
|
||||||
// gdb-check:$12 = 64
|
|
||||||
|
|
||||||
// gdb-command:print *f32_ref
|
|
||||||
// gdb-check:$13 = 2.5
|
|
||||||
|
|
||||||
// gdb-command:print *f64_ref
|
|
||||||
// gdb-check:$14 = 3.5
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
|
||||||
|
|
||||||
// lldb-command:type format add -f decimal char
|
|
||||||
// lldb-command:type format add -f decimal 'unsigned char'
|
|
||||||
// lldb-command:run
|
|
||||||
|
|
||||||
// lldb-command:print *bool_ref
|
|
||||||
// lldb-check:[...]$0 = true
|
|
||||||
|
|
||||||
// lldb-command:print *int_ref
|
|
||||||
// lldb-check:[...]$1 = -1
|
|
||||||
|
|
||||||
// LLDB can't handle 32bit chars yet
|
|
||||||
// d ebugger:print *char_ref
|
|
||||||
// c heck:[...]$x = 97
|
|
||||||
|
|
||||||
// lldb-command:print *i8_ref
|
|
||||||
// lldb-check:[...]$2 = 68
|
|
||||||
|
|
||||||
// lldb-command:print *i16_ref
|
|
||||||
// lldb-check:[...]$3 = -16
|
|
||||||
|
|
||||||
// lldb-command:print *i32_ref
|
|
||||||
// lldb-check:[...]$4 = -32
|
|
||||||
|
|
||||||
// lldb-command:print *i64_ref
|
|
||||||
// lldb-check:[...]$5 = -64
|
|
||||||
|
|
||||||
// lldb-command:print *uint_ref
|
|
||||||
// lldb-check:[...]$6 = 1
|
|
||||||
|
|
||||||
// lldb-command:print *u8_ref
|
|
||||||
// lldb-check:[...]$7 = 100
|
|
||||||
|
|
||||||
// lldb-command:print *u16_ref
|
|
||||||
// lldb-check:[...]$8 = 16
|
|
||||||
|
|
||||||
// lldb-command:print *u32_ref
|
|
||||||
// lldb-check:[...]$9 = 32
|
|
||||||
|
|
||||||
// lldb-command:print *u64_ref
|
|
||||||
// lldb-check:[...]$10 = 64
|
|
||||||
|
|
||||||
// lldb-command:print *f32_ref
|
|
||||||
// lldb-check:[...]$11 = 2.5
|
|
||||||
|
|
||||||
// lldb-command:print *f64_ref
|
|
||||||
// lldb-check:[...]$12 = 3.5
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let bool_box: Gc<bool> = box(GC) true;
|
|
||||||
let bool_ref: &bool = &*bool_box;
|
|
||||||
|
|
||||||
let int_box: Gc<int> = box(GC) -1;
|
|
||||||
let int_ref: &int = &*int_box;
|
|
||||||
|
|
||||||
let char_box: Gc<char> = box(GC) 'a';
|
|
||||||
let char_ref: &char = &*char_box;
|
|
||||||
|
|
||||||
let i8_box: Gc<i8> = box(GC) 68;
|
|
||||||
let i8_ref: &i8 = &*i8_box;
|
|
||||||
|
|
||||||
let i16_box: Gc<i16> = box(GC) -16;
|
|
||||||
let i16_ref: &i16 = &*i16_box;
|
|
||||||
|
|
||||||
let i32_box: Gc<i32> = box(GC) -32;
|
|
||||||
let i32_ref: &i32 = &*i32_box;
|
|
||||||
|
|
||||||
let i64_box: Gc<i64> = box(GC) -64;
|
|
||||||
let i64_ref: &i64 = &*i64_box;
|
|
||||||
|
|
||||||
let uint_box: Gc<uint> = box(GC) 1;
|
|
||||||
let uint_ref: &uint = &*uint_box;
|
|
||||||
|
|
||||||
let u8_box: Gc<u8> = box(GC) 100;
|
|
||||||
let u8_ref: &u8 = &*u8_box;
|
|
||||||
|
|
||||||
let u16_box: Gc<u16> = box(GC) 16;
|
|
||||||
let u16_ref: &u16 = &*u16_box;
|
|
||||||
|
|
||||||
let u32_box: Gc<u32> = box(GC) 32;
|
|
||||||
let u32_ref: &u32 = &*u32_box;
|
|
||||||
|
|
||||||
let u64_box: Gc<u64> = box(GC) 64;
|
|
||||||
let u64_ref: &u64 = &*u64_box;
|
|
||||||
|
|
||||||
let f32_box: Gc<f32> = box(GC) 2.5;
|
|
||||||
let f32_ref: &f32 = &*f32_box;
|
|
||||||
|
|
||||||
let f64_box: Gc<f64> = box(GC) 3.5;
|
|
||||||
let f64_ref: &f64 = &*f64_box;
|
|
||||||
|
|
||||||
zzz(); // #break
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zzz() {()}
|
|
|
@ -29,15 +29,6 @@
|
||||||
// gdb-command:print *ref_to_unnamed
|
// gdb-command:print *ref_to_unnamed
|
||||||
// gdb-check:$4 = {x = 11, y = 24.5}
|
// gdb-check:$4 = {x = 11, y = 24.5}
|
||||||
|
|
||||||
// gdb-command:print *managed_val_ref
|
|
||||||
// gdb-check:$5 = {x = 12, y = 25.5}
|
|
||||||
|
|
||||||
// gdb-command:print *managed_val_interior_ref_1
|
|
||||||
// gdb-check:$6 = 12
|
|
||||||
|
|
||||||
// gdb-command:print *managed_val_interior_ref_2
|
|
||||||
// gdb-check:$7 = 25.5
|
|
||||||
|
|
||||||
// gdb-command:print *unique_val_ref
|
// gdb-command:print *unique_val_ref
|
||||||
// gdb-check:$8 = {x = 13, y = 26.5}
|
// gdb-check:$8 = {x = 13, y = 26.5}
|
||||||
|
|
||||||
|
@ -64,15 +55,6 @@
|
||||||
// lldb-command:print *ref_to_unnamed
|
// lldb-command:print *ref_to_unnamed
|
||||||
// lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 }
|
// lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 }
|
||||||
|
|
||||||
// lldb-command:print *managed_val_ref
|
|
||||||
// lldb-check:[...]$4 = SomeStruct { x: 12, y: 25.5 }
|
|
||||||
|
|
||||||
// lldb-command:print *managed_val_interior_ref_1
|
|
||||||
// lldb-check:[...]$5 = 12
|
|
||||||
|
|
||||||
// lldb-command:print *managed_val_interior_ref_2
|
|
||||||
// lldb-check:[...]$6 = 25.5
|
|
||||||
|
|
||||||
// lldb-command:print *unique_val_ref
|
// lldb-command:print *unique_val_ref
|
||||||
// lldb-check:[...]$7 = SomeStruct { x: 13, y: 26.5 }
|
// lldb-check:[...]$7 = SomeStruct { x: 13, y: 26.5 }
|
||||||
|
|
||||||
|
@ -84,8 +66,6 @@
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct SomeStruct {
|
struct SomeStruct {
|
||||||
x: int,
|
x: int,
|
||||||
y: f64
|
y: f64
|
||||||
|
@ -98,11 +78,6 @@ fn main() {
|
||||||
let stack_val_interior_ref_2: &f64 = &stack_val.y;
|
let stack_val_interior_ref_2: &f64 = &stack_val.y;
|
||||||
let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };
|
let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };
|
||||||
|
|
||||||
let managed_val = box(GC) SomeStruct { x: 12, y: 25.5 };
|
|
||||||
let managed_val_ref: &SomeStruct = &*managed_val;
|
|
||||||
let managed_val_interior_ref_1: &int = &managed_val.x;
|
|
||||||
let managed_val_interior_ref_2: &f64 = &managed_val.y;
|
|
||||||
|
|
||||||
let unique_val = box SomeStruct { x: 13, y: 26.5 };
|
let unique_val = box SomeStruct { x: 13, y: 26.5 };
|
||||||
let unique_val_ref: &SomeStruct = &*unique_val;
|
let unique_val_ref: &SomeStruct = &*unique_val;
|
||||||
let unique_val_interior_ref_1: &int = &unique_val.x;
|
let unique_val_interior_ref_1: &int = &unique_val.x;
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
// gdb-command:print *ref_to_unnamed
|
// gdb-command:print *ref_to_unnamed
|
||||||
// gdb-check:$2 = {-15, -20}
|
// gdb-check:$2 = {-15, -20}
|
||||||
|
|
||||||
// gdb-command:print *managed_val_ref
|
|
||||||
// gdb-check:$3 = {-16, -21}
|
|
||||||
|
|
||||||
// gdb-command:print *unique_val_ref
|
// gdb-command:print *unique_val_ref
|
||||||
// gdb-check:$4 = {-17, -22}
|
// gdb-check:$4 = {-17, -22}
|
||||||
|
|
||||||
|
@ -42,25 +39,17 @@
|
||||||
// lldb-command:print *ref_to_unnamed
|
// lldb-command:print *ref_to_unnamed
|
||||||
// lldb-check:[...]$1 = (-15, -20)
|
// lldb-check:[...]$1 = (-15, -20)
|
||||||
|
|
||||||
// lldb-command:print *managed_val_ref
|
|
||||||
// lldb-check:[...]$2 = (-16, -21)
|
|
||||||
|
|
||||||
// lldb-command:print *unique_val_ref
|
// lldb-command:print *unique_val_ref
|
||||||
// lldb-check:[...]$3 = (-17, -22)
|
// lldb-check:[...]$3 = (-17, -22)
|
||||||
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let stack_val: (i16, f32) = (-14, -19f32);
|
let stack_val: (i16, f32) = (-14, -19f32);
|
||||||
let stack_val_ref: &(i16, f32) = &stack_val;
|
let stack_val_ref: &(i16, f32) = &stack_val;
|
||||||
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
|
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
|
||||||
|
|
||||||
let managed_val: Gc<(i16, f32)> = box(GC) (-16, -21f32);
|
|
||||||
let managed_val_ref: &(i16, f32) = &*managed_val;
|
|
||||||
|
|
||||||
let unique_val: Box<(i16, f32)> = box() (-17, -22f32);
|
let unique_val: Box<(i16, f32)> = box() (-17, -22f32);
|
||||||
let unique_val_ref: &(i16, f32) = &*unique_val;
|
let unique_val_ref: &(i16, f32) = &*unique_val;
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,6 @@
|
||||||
// gdb-check:$1 = 1
|
// gdb-check:$1 = 1
|
||||||
// gdb-command:print *b
|
// gdb-command:print *b
|
||||||
// gdb-check:$2 = {2, 3.5}
|
// gdb-check:$2 = {2, 3.5}
|
||||||
// gdb-command:print c->val
|
|
||||||
// gdb-check:$3 = 4
|
|
||||||
// gdb-command:print d->val
|
|
||||||
// gdb-check:$4 = false
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
// === LLDB TESTS ==================================================================================
|
||||||
|
@ -35,20 +31,12 @@
|
||||||
// lldb-check:[...]$0 = 1
|
// lldb-check:[...]$0 = 1
|
||||||
// lldb-command:print *b
|
// lldb-command:print *b
|
||||||
// lldb-check:[...]$1 = (2, 3.5)
|
// lldb-check:[...]$1 = (2, 3.5)
|
||||||
// lldb-command:print c->val
|
|
||||||
// lldb-check:[...]$2 = 4
|
|
||||||
// lldb-command:print d->val
|
|
||||||
// lldb-check:[...]$3 = false
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = box 1i;
|
let a = box 1i;
|
||||||
let b = box() (2i, 3.5f64);
|
let b = box() (2i, 3.5f64);
|
||||||
let c = box(GC) 4i;
|
|
||||||
let d = box(GC) false;
|
|
||||||
|
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,9 @@
|
||||||
// gdb-command:print *unique
|
// gdb-command:print *unique
|
||||||
// gdb-check:$1 = {x = 99, y = 999, z = 9999, w = 99999}
|
// gdb-check:$1 = {x = 99, y = 999, z = 9999, w = 99999}
|
||||||
|
|
||||||
// gdb-command:print managed->val
|
|
||||||
// gdb-check:$2 = {x = 88, y = 888, z = 8888, w = 88888}
|
|
||||||
|
|
||||||
// gdb-command:print *unique_dtor
|
// gdb-command:print *unique_dtor
|
||||||
// gdb-check:$3 = {x = 77, y = 777, z = 7777, w = 77777}
|
// gdb-check:$3 = {x = 77, y = 777, z = 7777, w = 77777}
|
||||||
|
|
||||||
// gdb-command:print managed_dtor->val
|
|
||||||
// gdb-check:$4 = {x = 33, y = 333, z = 3333, w = 33333}
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
// === LLDB TESTS ==================================================================================
|
||||||
|
|
||||||
|
@ -38,19 +32,11 @@
|
||||||
// lldb-command:print *unique
|
// lldb-command:print *unique
|
||||||
// lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }
|
// lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }
|
||||||
|
|
||||||
// lldb-command:print managed->val
|
|
||||||
// lldb-check:[...]$1 = StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 }
|
|
||||||
|
|
||||||
// lldb-command:print *unique_dtor
|
// lldb-command:print *unique_dtor
|
||||||
// lldb-check:[...]$2 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }
|
// lldb-check:[...]$2 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }
|
||||||
|
|
||||||
// lldb-command:print managed_dtor->val
|
|
||||||
// lldb-check:[...]$3 = StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 }
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct StructWithSomePadding {
|
struct StructWithSomePadding {
|
||||||
x: i16,
|
x: i16,
|
||||||
y: i32,
|
y: i32,
|
||||||
|
@ -72,11 +58,8 @@ impl Drop for StructWithDestructor {
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 };
|
let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 };
|
||||||
let managed = box(GC) StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 };
|
|
||||||
|
|
||||||
let unique_dtor = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 };
|
let unique_dtor = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 };
|
||||||
let managed_dtor = box(GC) StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 };
|
|
||||||
|
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,6 @@
|
||||||
// gdb-check:$3 = {4444.5, 5555, 6666, 7777.5}
|
// gdb-check:$3 = {4444.5, 5555, 6666, 7777.5}
|
||||||
// gdb-command:continue
|
// gdb-command:continue
|
||||||
|
|
||||||
// gdb-command:finish
|
|
||||||
// gdb-command:print self->val
|
|
||||||
// gdb-check:$4 = 8888
|
|
||||||
// gdb-command:continue
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
// === LLDB TESTS ==================================================================================
|
||||||
|
|
||||||
|
@ -55,12 +50,6 @@
|
||||||
// lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5)
|
// lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5)
|
||||||
// lldb-command:continue
|
// lldb-command:continue
|
||||||
|
|
||||||
// lldb-command:print self->val
|
|
||||||
// lldb-check:[...]$3 = 8888
|
|
||||||
// lldb-command:continue
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
trait Trait {
|
trait Trait {
|
||||||
fn method(self) -> Self;
|
fn method(self) -> Self;
|
||||||
}
|
}
|
||||||
|
@ -91,18 +80,10 @@ impl Trait for (f64, int, int, f64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for Gc<int> {
|
|
||||||
fn method(self) -> Gc<int> {
|
|
||||||
zzz(); // #break
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = (1111 as int).method();
|
let _ = (1111 as int).method();
|
||||||
let _ = Struct { x: 2222, y: 3333 }.method();
|
let _ = Struct { x: 2222, y: 3333 }.method();
|
||||||
let _ = (4444.5, 5555, 6666, 7777.5).method();
|
let _ = (4444.5, 5555, 6666, 7777.5).method();
|
||||||
let _ = (box(GC) 8888).method();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn zzz() { () }
|
fn zzz() { () }
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// ignore-android: FIXME(#10381)
|
|
||||||
|
|
||||||
// compile-flags:-g
|
|
||||||
|
|
||||||
// === GDB TESTS ===================================================================================
|
|
||||||
|
|
||||||
// gdb-command:rbreak zzz
|
|
||||||
// gdb-command:run
|
|
||||||
// gdb-command:finish
|
|
||||||
|
|
||||||
// gdb-command:print the_a->val
|
|
||||||
// gdb-check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}}
|
|
||||||
|
|
||||||
// gdb-command:print the_b->val
|
|
||||||
// gdb-check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}}
|
|
||||||
|
|
||||||
// gdb-command:print univariant->val
|
|
||||||
// gdb-check:$3 = {{-9747455}}
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
|
||||||
|
|
||||||
// lldb-command:run
|
|
||||||
|
|
||||||
// lldb-command:print the_a->val
|
|
||||||
// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
|
|
||||||
|
|
||||||
// lldb-command:print the_b->val
|
|
||||||
// lldb-check:[...]$1 = TheB(0, 286331153, 286331153)
|
|
||||||
|
|
||||||
// lldb-command:print univariant->val
|
|
||||||
// lldb-check:[...]$2 = TheOnlyCase(-9747455)
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
|
||||||
#![feature(struct_variant)]
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
|
|
||||||
// the size of the discriminant value is machine dependent, this has be taken into account when
|
|
||||||
// datatype layout should be predictable as in this case.
|
|
||||||
enum ABC {
|
|
||||||
TheA { x: i64, y: i64 },
|
|
||||||
TheB (i64, i32, i32),
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a special case since it does not have the implicit discriminant field.
|
|
||||||
enum Univariant {
|
|
||||||
TheOnlyCase(i64)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
|
|
||||||
// In order to avoid endianess trouble all of the following test values consist of a single
|
|
||||||
// repeated byte. This way each interpretation of the union should look the same, no matter if
|
|
||||||
// this is a big or little endian machine.
|
|
||||||
|
|
||||||
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
|
|
||||||
// 0b01111100011111000111110001111100 = 2088533116
|
|
||||||
// 0b0111110001111100 = 31868
|
|
||||||
// 0b01111100 = 124
|
|
||||||
let the_a = box(GC) TheA { x: 0, y: 8970181431921507452 };
|
|
||||||
|
|
||||||
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
|
|
||||||
// 0b00010001000100010001000100010001 = 286331153
|
|
||||||
// 0b0001000100010001 = 4369
|
|
||||||
// 0b00010001 = 17
|
|
||||||
let the_b = box(GC) TheB (0, 286331153, 286331153);
|
|
||||||
|
|
||||||
let univariant = box(GC) TheOnlyCase(-9747455);
|
|
||||||
|
|
||||||
zzz(); // #break
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zzz() {()}
|
|
|
@ -1,63 +0,0 @@
|
||||||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// ignore-android: FIXME(#10381)
|
|
||||||
|
|
||||||
|
|
||||||
// compile-flags:-g
|
|
||||||
|
|
||||||
// === GDB TESTS ===================================================================================
|
|
||||||
|
|
||||||
// gdb-command:rbreak zzz
|
|
||||||
// gdb-command:run
|
|
||||||
// gdb-command:finish
|
|
||||||
|
|
||||||
// gdb-command:print unique.ptr[0]->val
|
|
||||||
// gdb-check:$1 = 10
|
|
||||||
|
|
||||||
// gdb-command:print unique.ptr[1]->val
|
|
||||||
// gdb-check:$2 = 11
|
|
||||||
|
|
||||||
// gdb-command:print unique.ptr[2]->val
|
|
||||||
// gdb-check:$3 = 12
|
|
||||||
|
|
||||||
// gdb-command:print unique.ptr[3]->val
|
|
||||||
// gdb-check:$4 = 13
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
|
||||||
|
|
||||||
// lldb-command:run
|
|
||||||
|
|
||||||
// lldb-command:print unique.ptr[0]->val
|
|
||||||
// lldb-check:[...]$0 = 10
|
|
||||||
|
|
||||||
// lldb-command:print unique.ptr[1]->val
|
|
||||||
// lldb-check:[...]$1 = 11
|
|
||||||
|
|
||||||
// lldb-command:print unique.ptr[2]->val
|
|
||||||
// lldb-check:[...]$2 = 12
|
|
||||||
|
|
||||||
// lldb-command:print unique.ptr[3]->val
|
|
||||||
// lldb-check:[...]$3 = 13
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
|
|
||||||
let unique: Vec<Gc<i64>> = vec!(box(GC) 10, box(GC) 11, box(GC) 12, box(GC) 13);
|
|
||||||
|
|
||||||
zzz(); // #break
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zzz() {()}
|
|
|
@ -1,62 +0,0 @@
|
||||||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// ignore-android: FIXME(#10381)
|
|
||||||
|
|
||||||
|
|
||||||
// compile-flags:-g
|
|
||||||
|
|
||||||
// === GDB TESTS ===================================================================================
|
|
||||||
|
|
||||||
// gdb-command:set print pretty off
|
|
||||||
// gdb-command:rbreak zzz
|
|
||||||
// gdb-command:run
|
|
||||||
// gdb-command:finish
|
|
||||||
|
|
||||||
// gdb-command:print *ordinary_unique
|
|
||||||
// gdb-check:$1 = {-1, -2}
|
|
||||||
|
|
||||||
// gdb-command:print managed_within_unique->x
|
|
||||||
// gdb-check:$2 = -3
|
|
||||||
|
|
||||||
// gdb-command:print managed_within_unique->y->val
|
|
||||||
// gdb-check:$3 = -4
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
|
||||||
|
|
||||||
// lldb-command:run
|
|
||||||
|
|
||||||
// lldb-command:print *ordinary_unique
|
|
||||||
// lldb-check:[...]$0 = (-1, -2)
|
|
||||||
|
|
||||||
// lldb-command:print managed_within_unique->x
|
|
||||||
// lldb-check:[...]$1 = -3
|
|
||||||
|
|
||||||
// lldb-command:print managed_within_unique->y->val
|
|
||||||
// lldb-check:[...]$2 = -4
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
|
||||||
|
|
||||||
use std::gc::{GC, Gc};
|
|
||||||
|
|
||||||
struct ContainsManaged {
|
|
||||||
x: int,
|
|
||||||
y: Gc<int>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let ordinary_unique = box() (-1i, -2i);
|
|
||||||
|
|
||||||
let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4i };
|
|
||||||
|
|
||||||
zzz(); // #break
|
|
||||||
}
|
|
||||||
|
|
||||||
fn zzz() {()}
|
|
|
@ -29,11 +29,6 @@
|
||||||
// gdb-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
|
// gdb-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
|
||||||
// gdb-check:$4 = 3
|
// gdb-check:$4 = 3
|
||||||
|
|
||||||
// gdb-command:print box_unique->val.value
|
|
||||||
// gdb-check:$5 = 4
|
|
||||||
// gdb-command:print box_unique->val.next.RUST$ENCODED$ENUM$0$Empty.val->value
|
|
||||||
// gdb-check:$6 = 5
|
|
||||||
|
|
||||||
// gdb-command:print vec_unique[0].value
|
// gdb-command:print vec_unique[0].value
|
||||||
// gdb-check:$7 = 6.5
|
// gdb-check:$7 = 6.5
|
||||||
// gdb-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
|
// gdb-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
|
||||||
|
@ -44,32 +39,6 @@
|
||||||
// gdb-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
|
// gdb-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
|
||||||
// gdb-check:$10 = 9.5
|
// gdb-check:$10 = 9.5
|
||||||
|
|
||||||
// MANAGED
|
|
||||||
// gdb-command:print stack_managed.value
|
|
||||||
// gdb-check:$11 = 10
|
|
||||||
// gdb-command:print stack_managed.next.RUST$ENCODED$ENUM$0$Empty.val->val.value
|
|
||||||
// gdb-check:$12 = 11
|
|
||||||
|
|
||||||
// gdb-command:print unique_managed->value
|
|
||||||
// gdb-check:$13 = 12
|
|
||||||
// gdb-command:print unique_managed->next.RUST$ENCODED$ENUM$0$Empty.val->val.value
|
|
||||||
// gdb-check:$14 = 13
|
|
||||||
|
|
||||||
// gdb-command:print box_managed.val->value
|
|
||||||
// gdb-check:$15 = 14
|
|
||||||
// gdb-command:print box_managed->val->next.RUST$ENCODED$ENUM$0$Empty.val->val.value
|
|
||||||
// gdb-check:$16 = 15
|
|
||||||
|
|
||||||
// gdb-command:print vec_managed[0].value
|
|
||||||
// gdb-check:$17 = 16.5
|
|
||||||
// gdb-command:print vec_managed[0].next.RUST$ENCODED$ENUM$0$Empty.val->val.value
|
|
||||||
// gdb-check:$18 = 17.5
|
|
||||||
|
|
||||||
// gdb-command:print borrowed_managed->value
|
|
||||||
// gdb-check:$19 = 18.5
|
|
||||||
// gdb-command:print borrowed_managed->next.RUST$ENCODED$ENUM$0$Empty.val->val.value
|
|
||||||
// gdb-check:$20 = 19.5
|
|
||||||
|
|
||||||
// LONG CYCLE
|
// LONG CYCLE
|
||||||
// gdb-command:print long_cycle1.value
|
// gdb-command:print long_cycle1.value
|
||||||
// gdb-check:$21 = 20
|
// gdb-check:$21 = 20
|
||||||
|
@ -106,8 +75,6 @@
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
#![feature(struct_variant)]
|
#![feature(struct_variant)]
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
enum Opt<T> {
|
enum Opt<T> {
|
||||||
Empty,
|
Empty,
|
||||||
Val { val: T }
|
Val { val: T }
|
||||||
|
@ -118,11 +85,6 @@ struct UniqueNode<T> {
|
||||||
value: T
|
value: T
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ManagedNode<T> {
|
|
||||||
next: Opt<Gc<ManagedNode<T>>>,
|
|
||||||
value: T
|
|
||||||
}
|
|
||||||
|
|
||||||
struct LongCycle1<T> {
|
struct LongCycle1<T> {
|
||||||
next: Box<LongCycle2<T>>,
|
next: Box<LongCycle2<T>>,
|
||||||
value: T,
|
value: T,
|
||||||
|
@ -184,16 +146,6 @@ fn main() {
|
||||||
value: 2,
|
value: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
let box_unique: Gc<UniqueNode<u64>> = box(GC) UniqueNode {
|
|
||||||
next: Val {
|
|
||||||
val: box UniqueNode {
|
|
||||||
next: Empty,
|
|
||||||
value: 5,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
value: 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
let vec_unique: [UniqueNode<f32>, ..1] = [UniqueNode {
|
let vec_unique: [UniqueNode<f32>, ..1] = [UniqueNode {
|
||||||
next: Val {
|
next: Val {
|
||||||
val: box UniqueNode {
|
val: box UniqueNode {
|
||||||
|
@ -214,56 +166,6 @@ fn main() {
|
||||||
value: 8.5,
|
value: 8.5,
|
||||||
};
|
};
|
||||||
|
|
||||||
let stack_managed: ManagedNode<u16> = ManagedNode {
|
|
||||||
next: Val {
|
|
||||||
val: box(GC) ManagedNode {
|
|
||||||
next: Empty,
|
|
||||||
value: 11,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
value: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
let unique_managed: Box<ManagedNode<u32>> = box ManagedNode {
|
|
||||||
next: Val {
|
|
||||||
val: box(GC) ManagedNode {
|
|
||||||
next: Empty,
|
|
||||||
value: 13,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
value: 12,
|
|
||||||
};
|
|
||||||
|
|
||||||
let box_managed: Gc<ManagedNode<u64>> = box(GC) ManagedNode {
|
|
||||||
next: Val {
|
|
||||||
val: box(GC) ManagedNode {
|
|
||||||
next: Empty,
|
|
||||||
value: 15,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
value: 14,
|
|
||||||
};
|
|
||||||
|
|
||||||
let vec_managed: [ManagedNode<f32>, ..1] = [ManagedNode {
|
|
||||||
next: Val {
|
|
||||||
val: box(GC) ManagedNode {
|
|
||||||
next: Empty,
|
|
||||||
value: 17.5,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
value: 16.5,
|
|
||||||
}];
|
|
||||||
|
|
||||||
let borrowed_managed: &ManagedNode<f64> = &ManagedNode {
|
|
||||||
next: Val {
|
|
||||||
val: box(GC) ManagedNode {
|
|
||||||
next: Empty,
|
|
||||||
value: 19.5,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
value: 18.5,
|
|
||||||
};
|
|
||||||
|
|
||||||
// LONG CYCLE
|
// LONG CYCLE
|
||||||
let long_cycle1: LongCycle1<u16> = LongCycle1 {
|
let long_cycle1: LongCycle1<u16> = LongCycle1 {
|
||||||
next: box LongCycle2 {
|
next: box LongCycle2 {
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
// gdb-check:$4 = {a = -3, b = 4.5, c = 5}
|
// gdb-check:$4 = {a = -3, b = 4.5, c = 5}
|
||||||
// gdb-command:print *owned
|
// gdb-command:print *owned
|
||||||
// gdb-check:$5 = 6
|
// gdb-check:$5 = 6
|
||||||
// gdb-command:print managed->val
|
|
||||||
// gdb-check:$6 = 7
|
|
||||||
// gdb-command:print closure_local
|
// gdb-command:print closure_local
|
||||||
// gdb-check:$7 = 8
|
// gdb-check:$7 = 8
|
||||||
// gdb-command:continue
|
// gdb-command:continue
|
||||||
|
@ -45,8 +43,6 @@
|
||||||
// gdb-check:$11 = {a = -3, b = 4.5, c = 5}
|
// gdb-check:$11 = {a = -3, b = 4.5, c = 5}
|
||||||
// gdb-command:print *owned
|
// gdb-command:print *owned
|
||||||
// gdb-check:$12 = 6
|
// gdb-check:$12 = 6
|
||||||
// gdb-command:print managed->val
|
|
||||||
// gdb-check:$13 = 7
|
|
||||||
// gdb-command:print closure_local
|
// gdb-command:print closure_local
|
||||||
// gdb-check:$14 = 8
|
// gdb-check:$14 = 8
|
||||||
// gdb-command:continue
|
// gdb-command:continue
|
||||||
|
@ -66,8 +62,6 @@
|
||||||
// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
|
// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
|
||||||
// lldb-command:print *owned
|
// lldb-command:print *owned
|
||||||
// lldb-check:[...]$4 = 6
|
// lldb-check:[...]$4 = 6
|
||||||
// lldb-command:print managed->val
|
|
||||||
// lldb-check:[...]$5 = 7
|
|
||||||
// lldb-command:print closure_local
|
// lldb-command:print closure_local
|
||||||
// lldb-check:[...]$6 = 8
|
// lldb-check:[...]$6 = 8
|
||||||
// lldb-command:continue
|
// lldb-command:continue
|
||||||
|
@ -82,16 +76,12 @@
|
||||||
// lldb-check:[...]$10 = Struct { a: -3, b: 4.5, c: 5 }
|
// lldb-check:[...]$10 = Struct { a: -3, b: 4.5, c: 5 }
|
||||||
// lldb-command:print *owned
|
// lldb-command:print *owned
|
||||||
// lldb-check:[...]$11 = 6
|
// lldb-check:[...]$11 = 6
|
||||||
// lldb-command:print managed->val
|
|
||||||
// lldb-check:[...]$12 = 7
|
|
||||||
// lldb-command:print closure_local
|
// lldb-command:print closure_local
|
||||||
// lldb-check:[...]$13 = 8
|
// lldb-check:[...]$13 = 8
|
||||||
// lldb-command:continue
|
// lldb-command:continue
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct Struct {
|
struct Struct {
|
||||||
a: int,
|
a: int,
|
||||||
b: f64,
|
b: f64,
|
||||||
|
@ -110,14 +100,13 @@ fn main() {
|
||||||
|
|
||||||
let struct_ref = &a_struct;
|
let struct_ref = &a_struct;
|
||||||
let owned = box 6;
|
let owned = box 6;
|
||||||
let managed = box(GC) 7;
|
|
||||||
|
|
||||||
let closure = || {
|
let closure = || {
|
||||||
let closure_local = 8;
|
let closure_local = 8;
|
||||||
|
|
||||||
let nested_closure = || {
|
let nested_closure = || {
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
variable = constant + a_struct.a + struct_ref.a + *owned + *managed + closure_local;
|
variable = constant + a_struct.a + struct_ref.a + *owned + closure_local;
|
||||||
};
|
};
|
||||||
|
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
// gdb-check:$4 = {a = -3, b = 4.5, c = 5}
|
// gdb-check:$4 = {a = -3, b = 4.5, c = 5}
|
||||||
// gdb-command:print *owned
|
// gdb-command:print *owned
|
||||||
// gdb-check:$5 = 6
|
// gdb-check:$5 = 6
|
||||||
// gdb-command:print managed->val
|
|
||||||
// gdb-check:$6 = 7
|
|
||||||
|
|
||||||
|
|
||||||
// === LLDB TESTS ==================================================================================
|
// === LLDB TESTS ==================================================================================
|
||||||
|
@ -46,13 +44,9 @@
|
||||||
// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
|
// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
|
||||||
// lldb-command:print *owned
|
// lldb-command:print *owned
|
||||||
// lldb-check:[...]$4 = 6
|
// lldb-check:[...]$4 = 6
|
||||||
// lldb-command:print managed->val
|
|
||||||
// lldb-check:[...]$5 = 7
|
|
||||||
|
|
||||||
#![allow(unused_variable)]
|
#![allow(unused_variable)]
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct Struct {
|
struct Struct {
|
||||||
a: int,
|
a: int,
|
||||||
b: f64,
|
b: f64,
|
||||||
|
@ -71,11 +65,10 @@ fn main() {
|
||||||
|
|
||||||
let struct_ref = &a_struct;
|
let struct_ref = &a_struct;
|
||||||
let owned = box 6;
|
let owned = box 6;
|
||||||
let managed = box(GC) 7;
|
|
||||||
|
|
||||||
let closure = || {
|
let closure = || {
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
variable = constant + a_struct.a + struct_ref.a + *owned + *managed;
|
variable = constant + a_struct.a + struct_ref.a + *owned;
|
||||||
};
|
};
|
||||||
|
|
||||||
closure();
|
closure();
|
||||||
|
|
|
@ -14,34 +14,33 @@
|
||||||
|
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn test1() { let val = box(GC) 0i; { } *val; }
|
fn test1() { let val = &0i; { } *val; }
|
||||||
|
|
||||||
fn test2() -> int { let val = box(GC) 0i; { } *val }
|
fn test2() -> int { let val = &0i; { } *val }
|
||||||
|
|
||||||
struct S { eax: int }
|
struct S { eax: int }
|
||||||
|
|
||||||
fn test3() {
|
fn test3() {
|
||||||
let regs = box(GC) Cell::new(S {eax: 0});
|
let regs = &Cell::new(S {eax: 0});
|
||||||
match true { true => { } _ => { } }
|
match true { true => { } _ => { } }
|
||||||
regs.set(S {eax: 1});
|
regs.set(S {eax: 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test4() -> bool { let regs = box(GC) true; if true { } *regs || false }
|
fn test4() -> bool { let regs = &true; if true { } *regs || false }
|
||||||
|
|
||||||
fn test5() -> (int, int) { { } (0, 1) }
|
fn test5() -> (int, int) { { } (0, 1) }
|
||||||
|
|
||||||
fn test6() -> bool { { } (true || false) && true }
|
fn test6() -> bool { { } (true || false) && true }
|
||||||
|
|
||||||
fn test7() -> uint {
|
fn test7() -> uint {
|
||||||
let regs = box(GC) 0i;
|
let regs = &0i;
|
||||||
match true { true => { } _ => { } }
|
match true { true => { } _ => { } }
|
||||||
(*regs < 2) as uint
|
(*regs < 2) as uint
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test8() -> int {
|
fn test8() -> int {
|
||||||
let val = box(GC) 0i;
|
let val = &0i;
|
||||||
match true {
|
match true {
|
||||||
true => { }
|
true => { }
|
||||||
_ => { }
|
_ => { }
|
||||||
|
@ -54,12 +53,12 @@ fn test8() -> int {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test9() {
|
fn test9() {
|
||||||
let regs = box(GC) Cell::new(0i);
|
let regs = &Cell::new(0i);
|
||||||
match true { true => { } _ => { } } regs.set(regs.get() + 1);
|
match true { true => { } _ => { } } regs.set(regs.get() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test10() -> int {
|
fn test10() -> int {
|
||||||
let regs = box(GC) vec!(0i);
|
let regs = vec!(0i);
|
||||||
match true { true => { } _ => { } }
|
match true { true => { } _ => { } }
|
||||||
*(*regs).get(0)
|
*(*regs).get(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
// error-pattern:meep
|
// error-pattern:meep
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
fn f(_a: int, _b: int, _c: Box<int>) { fail!("moop"); }
|
||||||
|
|
||||||
fn f(_a: int, _b: int, _c: Gc<int>) { fail!("moop"); }
|
fn main() { f(1, fail!("meep"), box 42); }
|
||||||
|
|
||||||
fn main() { f(1, fail!("meep"), box(GC) 42); }
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
// error-pattern:explicit failure
|
|
||||||
// Issue #2272 - unwind this without leaking the unique pointer
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct X { y: Y, a: Box<int> }
|
|
||||||
|
|
||||||
struct Y { z: Gc<int> }
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _x = X {
|
|
||||||
y: Y {
|
|
||||||
z: box(GC) 0
|
|
||||||
},
|
|
||||||
a: box 0
|
|
||||||
};
|
|
||||||
fail!();
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _a = box(GC) 0i;
|
|
||||||
assert!(false);
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::gc::{GC, Gc};
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let y = box 0i;
|
|
||||||
let x: Gc<proc():Send> = box(GC) (proc() {
|
|
||||||
println!("{:?}", y.clone());
|
|
||||||
});
|
|
||||||
failfn();
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::mem;
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct r {
|
|
||||||
v: *const int,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for r {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
let _v2: Box<int> = mem::transmute(self.v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn r(v: *const int) -> r {
|
|
||||||
r {
|
|
||||||
v: v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
unsafe {
|
|
||||||
let i1 = box 0i;
|
|
||||||
let i1p = mem::transmute_copy(&i1);
|
|
||||||
mem::forget(i1);
|
|
||||||
let x = box(GC) r(i1p);
|
|
||||||
failfn();
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = box(GC) "hi".to_string();
|
|
||||||
failfn();
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = box(GC) box box 0i;
|
|
||||||
failfn();
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = box(GC) box 0i;
|
|
||||||
failfn();
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
extern crate debug;
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = box(GC) vec!(0i, 1, 2, 3, 4, 5);
|
|
||||||
failfn();
|
|
||||||
println!("{:?}", x);
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn failfn() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
box(GC) 0i;
|
|
||||||
failfn();
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
box(GC) 0i;
|
|
||||||
fail!();
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
fn f() -> Gc<int> { fail!(); }
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _a: Gc<int> = f();
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _a: Gc<int> = {
|
|
||||||
fail!();
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
#![allow(unreachable_code)]
|
|
||||||
#![allow(unused_variable)]
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn x(it: |int|) {
|
|
||||||
fail!();
|
|
||||||
it(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let a = box(GC) 0i;
|
|
||||||
x(|_i| { } );
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{GC};
|
|
||||||
|
|
||||||
fn x(it: |int|) {
|
|
||||||
let _a = box(GC) 0i;
|
|
||||||
it(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
x(|_x| fail!() );
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let cheese = "roquefort".to_string();
|
|
||||||
let carrots = box(GC) "crunchy".to_string();
|
|
||||||
|
|
||||||
let result: |Gc<String>, |String||: 'static = (|tasties, macerate| {
|
|
||||||
macerate((*tasties).clone());
|
|
||||||
});
|
|
||||||
result(carrots, |food| {
|
|
||||||
let mush = format!("{}{}", food, cheese);
|
|
||||||
let cheese = cheese.clone();
|
|
||||||
let f: || = || {
|
|
||||||
let _chew = format!("{}{}", mush, cheese);
|
|
||||||
fail!("so yummy")
|
|
||||||
};
|
|
||||||
f();
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Issue #945
|
|
||||||
// error-pattern:non-exhaustive match failure
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn test_box() {
|
|
||||||
box(GC) 0i;
|
|
||||||
}
|
|
||||||
fn test_str() {
|
|
||||||
let res = match false { true => { "happy".to_string() },
|
|
||||||
_ => fail!("non-exhaustive match failure") };
|
|
||||||
assert_eq!(res, "happy".to_string());
|
|
||||||
}
|
|
||||||
fn main() {
|
|
||||||
test_box();
|
|
||||||
test_str();
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_NEWRT=1
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::vec;
|
|
||||||
use std::collections;
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _count = box(GC) 0u;
|
|
||||||
let mut map = collections::HashMap::new();
|
|
||||||
let mut arr = Vec::new();
|
|
||||||
for _i in range(0u, 10u) {
|
|
||||||
arr.push(box(GC) "key stuff".to_string());
|
|
||||||
map.insert(arr.clone(),
|
|
||||||
arr.clone().append([box(GC) "value stuff".to_string()]));
|
|
||||||
if arr.len() == 5 {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn f(_a: Gc<int>) {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let a = box(GC) 0;
|
|
||||||
f(a);
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _a = box(GC) 0i;
|
|
||||||
{
|
|
||||||
let _b = box(GC) 0i;
|
|
||||||
{
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn f() -> Vec<int> { fail!(); }
|
|
||||||
|
|
||||||
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might
|
|
||||||
// have been to do with memory allocation patterns.
|
|
||||||
fn prime() {
|
|
||||||
box(GC) 0i;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn partial() {
|
|
||||||
let _x = box(GC) f();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
prime();
|
|
||||||
partial();
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn f() -> Vec<int> { fail!(); }
|
|
||||||
|
|
||||||
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might
|
|
||||||
// have been to do with memory allocation patterns.
|
|
||||||
fn prime() {
|
|
||||||
box(GC) 0i;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn partial() {
|
|
||||||
let _x = box f();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
prime();
|
|
||||||
partial();
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn f() -> Vec<int> { fail!(); }
|
|
||||||
|
|
||||||
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might
|
|
||||||
// have been to do with memory allocation patterns.
|
|
||||||
fn prime() {
|
|
||||||
box(GC) 0i;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn partial() {
|
|
||||||
let _x = vec!(vec!(0i), f(), vec!(0i));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
prime();
|
|
||||||
partial();
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
// error-pattern:squirrel
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct r {
|
|
||||||
i: int,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for r {
|
|
||||||
fn drop(&mut self) { fail!("squirrel") }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn r(i: int) -> r { r { i: i } }
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
box(GC) 0i;
|
|
||||||
let _r = r(0);
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// ignore-test leaks
|
|
||||||
// error-pattern:wombat
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
struct r {
|
|
||||||
i: int,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for r {
|
|
||||||
fn drop(&mut self) { fail!("wombat") }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn r(i: int) -> r { r { i: i } }
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
box(GC) 0;
|
|
||||||
let r = r(0);
|
|
||||||
fail!();
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
#![feature(unsafe_destructor)]
|
|
||||||
|
|
||||||
// error-pattern:quux
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
struct faily_box {
|
|
||||||
i: Gc<int>
|
|
||||||
}
|
|
||||||
// What happens to the box pointer owned by this class?
|
|
||||||
|
|
||||||
fn faily_box(i: Gc<int>) -> faily_box { faily_box { i: i } }
|
|
||||||
|
|
||||||
#[unsafe_destructor]
|
|
||||||
impl Drop for faily_box {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
fail!("quux");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
faily_box(box(GC) 10);
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn f() {
|
|
||||||
let _a = box(GC) 0i;
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn g() {
|
|
||||||
let _b = box(GC) 0i;
|
|
||||||
f();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _a = box(GC) 0i;
|
|
||||||
g();
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::Gc;
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
fn fold_local() -> Gc<Vec<int>> {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _lss = (fold_local(), 0i);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
fn fold_local() -> Gc<Vec<int>> {
|
|
||||||
box(GC) vec!(0,0,0,0,0,0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fold_remote() -> Gc<Vec<int>> {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _lss = (fold_local(), fold_remote());
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// error-pattern:fail
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn f() {
|
|
||||||
fail!();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
f();
|
|
||||||
let _a = box(GC) 0i;
|
|
||||||
}
|
|
|
@ -9,8 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
#[deriving(PartialEq, Show)]
|
#[deriving(PartialEq, Show)]
|
||||||
struct Point { x : int }
|
struct Point { x : int }
|
||||||
|
|
||||||
|
@ -19,5 +17,4 @@ pub fn main() {
|
||||||
assert_eq!("abc".to_string(),"abc".to_string());
|
assert_eq!("abc".to_string(),"abc".to_string());
|
||||||
assert_eq!(box Point{x:34},box Point{x:34});
|
assert_eq!(box Point{x:34},box Point{x:34});
|
||||||
assert_eq!(&Point{x:34},&Point{x:34});
|
assert_eq!(&Point{x:34},&Point{x:34});
|
||||||
assert_eq!(box(GC) Point{x:34},box(GC) Point{x:34});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{GC, Gc};
|
|
||||||
|
|
||||||
trait double {
|
trait double {
|
||||||
fn double(self) -> uint;
|
fn double(self) -> uint;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +17,11 @@ impl double for uint {
|
||||||
fn double(self) -> uint { self }
|
fn double(self) -> uint { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl double for Gc<uint> {
|
impl double for Box<uint> {
|
||||||
fn double(self) -> uint { *self * 2u }
|
fn double(self) -> uint { *self * 2u }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = box(GC) 3u;
|
let x = box 3u;
|
||||||
assert_eq!(x.double(), 6u);
|
assert_eq!(x.double(), 6u);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,13 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
fn foo(&self) -> String;
|
fn foo(&self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Foo> Foo for Gc<T> {
|
impl<T:Foo> Foo for Box<T> {
|
||||||
fn foo(&self) -> String {
|
fn foo(&self) -> String {
|
||||||
format!("box(GC) {}", (**self).foo())
|
format!("box {}", (**self).foo())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +26,6 @@ impl Foo for uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = box(GC) 3u;
|
let x = box 3u;
|
||||||
assert_eq!(x.foo(), "box(GC) 3".to_string());
|
assert_eq!(x.foo(), "box 3".to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
|
|
||||||
// Binop corner cases
|
// Binop corner cases
|
||||||
|
|
||||||
|
|
||||||
use std::gc::GC;
|
|
||||||
|
|
||||||
fn test_nil() {
|
fn test_nil() {
|
||||||
assert_eq!((), ());
|
assert_eq!((), ());
|
||||||
assert!((!(() != ())));
|
assert!((!(() != ())));
|
||||||
|
@ -45,10 +42,6 @@ fn test_bool() {
|
||||||
assert_eq!(true ^ true, false);
|
assert_eq!(true ^ true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_box() {
|
|
||||||
assert_eq!(box(GC) 10i, box(GC) 10i);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_ptr() {
|
fn test_ptr() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let p1: *const u8 = ::std::mem::transmute(0u);
|
let p1: *const u8 = ::std::mem::transmute(0u);
|
||||||
|
@ -98,7 +91,6 @@ fn test_class() {
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
test_nil();
|
test_nil();
|
||||||
test_bool();
|
test_bool();
|
||||||
test_box();
|
|
||||||
test_ptr();
|
test_ptr();
|
||||||
test_class();
|
test_class();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn borrow(x: &int, f: |x: &int|) {
|
fn borrow(x: &int, f: |x: &int|) {
|
||||||
f(x)
|
f(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test1(x: Gc<Box<int>>) {
|
fn test1(x: &Box<int>) {
|
||||||
borrow(&*(*x).clone(), |p| {
|
borrow(&*(*x).clone(), |p| {
|
||||||
let x_a = &**x as *const int;
|
let x_a = &**x as *const int;
|
||||||
assert!((x_a as uint) != (p as *const int as uint));
|
assert!((x_a as uint) != (p as *const int as uint));
|
||||||
|
@ -24,5 +22,5 @@ fn test1(x: Gc<Box<int>>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
test1(box(GC) box 22);
|
test1(&box 22);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// exec-env:RUST_POISON_ON_FREE=1
|
|
||||||
|
|
||||||
// Test that we root `x` even though it is found in immutable memory,
|
|
||||||
// because it is moved.
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{Gc, GC};
|
|
||||||
|
|
||||||
fn free<T>(x: Gc<T>) {}
|
|
||||||
|
|
||||||
struct Foo {
|
|
||||||
f: Gc<Bar>
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Bar {
|
|
||||||
g: int
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lend(x: Gc<Foo>) -> int {
|
|
||||||
let y = &x.f.g;
|
|
||||||
free(x); // specifically here, if x is not rooted, it will be freed
|
|
||||||
*y
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
assert_eq!(lend(box(GC) Foo {f: box(GC) Bar {g: 22}}), 22);
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
|
|
||||||
use std::gc::{GC, Gc};
|
|
||||||
|
|
||||||
struct F { f: Gc<G> }
|
|
||||||
struct G { g: Vec<int> }
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let rec = box(GC) F {f: box(GC) G {g: vec!(1, 2, 3)}};
|
|
||||||
while rec.f.g.len() == 23 {}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue