mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
rustc: Obsolete the @
syntax entirely
This removes all remnants of `@` pointers from rustc. Additionally, this removes the `GC` structure from the prelude as it seems odd exporting an experimental type in the prelude by default. Closes #14193 [breaking-change]
This commit is contained in:
parent
f20b1293fc
commit
ade807c6dc
@ -419,6 +419,7 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
|
||||
mod tests {
|
||||
use std::fmt::Show;
|
||||
use std::prelude::*;
|
||||
use std::gc::{GC, Gc};
|
||||
use test::Bencher;
|
||||
use test;
|
||||
|
||||
@ -473,10 +474,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_boxes() {
|
||||
let a: @int = @5;
|
||||
let b: @int = @72;
|
||||
let c: @int = @64;
|
||||
let d: @int = @175;
|
||||
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);
|
||||
@ -621,7 +622,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_param_at_int() {
|
||||
test_parameterized::<@int>(@5, @72, @64, @175);
|
||||
test_parameterized::<Gc<int>>(box(GC) 5, box(GC) 72,
|
||||
box(GC) 64, box(GC) 175);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2345,6 +2345,7 @@ mod tests {
|
||||
use num;
|
||||
use realstd::vec::Vec;
|
||||
use realstd::slice::Vector;
|
||||
use realstd::gc::GC;
|
||||
|
||||
use cmp;
|
||||
use realstd::owned::Box;
|
||||
@ -2835,7 +2836,8 @@ mod tests {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_rposition_fail() {
|
||||
let v = [(box 0, @0), (box 0, @0), (box 0, @0), (box 0, @0)];
|
||||
let v = [(box 0, box(GC) 0), (box 0, box(GC) 0),
|
||||
(box 0, box(GC) 0), (box 0, box(GC) 0)];
|
||||
let mut i = 0;
|
||||
v.iter().rposition(|_elt| {
|
||||
if i == 2 {
|
||||
|
@ -18,6 +18,7 @@ Runtime type reflection
|
||||
|
||||
use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
|
||||
use std::mem;
|
||||
use std::gc::Gc;
|
||||
|
||||
/**
|
||||
* Trait for visitor that wishes to reflect on data.
|
||||
@ -219,9 +220,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
||||
}
|
||||
|
||||
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
|
||||
self.align_to::<@u8>();
|
||||
self.align_to::<Gc<u8>>();
|
||||
if ! self.inner.visit_box(mtbl, inner) { return false; }
|
||||
self.bump_past::<@u8>();
|
||||
self.bump_past::<Gc<u8>>();
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
|
||||
_align: uint) -> bool { fail!(); }
|
||||
|
||||
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
|
||||
try!(self, self.writer.write(['@' as u8]));
|
||||
try!(self, self.writer.write("box(GC) ".as_bytes()));
|
||||
self.write_mut_qualifier(mtbl);
|
||||
self.get::<&raw::Box<()>>(|this, b| {
|
||||
let p = &b.data as *() as *u8;
|
||||
@ -591,6 +591,7 @@ fn test_repr() {
|
||||
use std::io::stdio::println;
|
||||
use std::char::is_alphabetic;
|
||||
use std::mem::swap;
|
||||
use std::gc::GC;
|
||||
|
||||
fn exact_test<T>(t: &T, e:&str) {
|
||||
let mut m = io::MemWriter::new();
|
||||
@ -605,7 +606,7 @@ fn test_repr() {
|
||||
exact_test(&1.234, "1.234f64");
|
||||
exact_test(&("hello"), "\"hello\"");
|
||||
|
||||
exact_test(&(@10), "@10");
|
||||
exact_test(&(box(GC) 10), "box(GC) 10");
|
||||
exact_test(&(box 10), "box 10");
|
||||
exact_test(&(&10), "&10");
|
||||
let mut x = 10;
|
||||
@ -619,8 +620,8 @@ fn test_repr() {
|
||||
"&[\"hi\", \"there\"]");
|
||||
exact_test(&(P{a:10, b:1.234}),
|
||||
"repr::P{a: 10, b: 1.234f64}");
|
||||
exact_test(&(@P{a:10, b:1.234}),
|
||||
"@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}),
|
||||
"box repr::P{a: 10, b: 1.234f64}");
|
||||
|
||||
|
@ -63,6 +63,8 @@ use syntax::parse::token;
|
||||
use syntax::parse::token::InternedString;
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.register_macro("fourcc", expand_syntax_ext);
|
||||
@ -130,7 +132,8 @@ struct Ident {
|
||||
span: Span
|
||||
}
|
||||
|
||||
fn parse_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> (@ast::Expr, Option<Ident>) {
|
||||
fn parse_tts(cx: &ExtCtxt,
|
||||
tts: &[ast::TokenTree]) -> (Gc<ast::Expr>, Option<Ident>) {
|
||||
let p = &mut parse::new_parser_from_tts(cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
tts.iter()
|
||||
|
@ -57,6 +57,8 @@ use syntax::parse;
|
||||
use syntax::parse::token;
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.register_macro("hexfloat", expand_syntax_ext);
|
||||
@ -163,7 +165,8 @@ struct Ident {
|
||||
span: Span
|
||||
}
|
||||
|
||||
fn parse_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> (@ast::Expr, Option<Ident>) {
|
||||
fn parse_tts(cx: &ExtCtxt,
|
||||
tts: &[ast::TokenTree]) -> (Gc<ast::Expr>, Option<Ident>) {
|
||||
let p = &mut parse::new_parser_from_tts(cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
tts.iter()
|
||||
|
@ -26,6 +26,7 @@ extern crate syntax;
|
||||
extern crate rustc;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
@ -110,7 +111,7 @@ struct NfaGen<'a> {
|
||||
}
|
||||
|
||||
impl<'a> NfaGen<'a> {
|
||||
fn code(&mut self) -> @ast::Expr {
|
||||
fn code(&mut self) -> Gc<ast::Expr> {
|
||||
// Most or all of the following things are used in the quasiquoted
|
||||
// expression returned.
|
||||
let num_cap_locs = 2 * self.prog.num_captures();
|
||||
@ -331,7 +332,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
|
||||
// Generates code for the `add` method, which is responsible for adding
|
||||
// zero-width states to the next queue of states to visit.
|
||||
fn add_insts(&self) -> @ast::Expr {
|
||||
fn add_insts(&self) -> Gc<ast::Expr> {
|
||||
let arms = self.prog.insts.iter().enumerate().map(|(pc, inst)| {
|
||||
let nextpc = pc + 1;
|
||||
let body = match *inst {
|
||||
@ -432,7 +433,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
|
||||
// Generates the code for the `step` method, which processes all states
|
||||
// in the current queue that consume a single character.
|
||||
fn step_insts(&self) -> @ast::Expr {
|
||||
fn step_insts(&self) -> Gc<ast::Expr> {
|
||||
let arms = self.prog.insts.iter().enumerate().map(|(pc, inst)| {
|
||||
let nextpc = pc + 1;
|
||||
let body = match *inst {
|
||||
@ -523,7 +524,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
// Translates a character class into a match expression.
|
||||
// This avoids a binary search (and is hopefully replaced by a jump
|
||||
// table).
|
||||
fn match_class(&self, casei: bool, ranges: &[(char, char)]) -> @ast::Expr {
|
||||
fn match_class(&self, casei: bool, ranges: &[(char, char)]) -> Gc<ast::Expr> {
|
||||
let expr_true = quote_expr!(self.cx, true);
|
||||
|
||||
let mut arms = ranges.iter().map(|&(mut start, mut end)| {
|
||||
@ -545,7 +546,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
// Generates code for checking a literal prefix of the search string.
|
||||
// The code is only generated if the regex *has* a literal prefix.
|
||||
// Otherwise, a no-op is returned.
|
||||
fn check_prefix(&self) -> @ast::Expr {
|
||||
fn check_prefix(&self) -> Gc<ast::Expr> {
|
||||
if self.prog.prefix.len() == 0 {
|
||||
self.empty_block()
|
||||
} else {
|
||||
@ -569,28 +570,28 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
// A wild-card arm is automatically added that executes a no-op. It will
|
||||
// never be used, but is added to satisfy the compiler complaining about
|
||||
// non-exhaustive patterns.
|
||||
fn match_insts(&self, mut arms: Vec<ast::Arm>) -> @ast::Expr {
|
||||
fn match_insts(&self, mut arms: Vec<ast::Arm>) -> Gc<ast::Expr> {
|
||||
arms.push(self.wild_arm_expr(self.empty_block()));
|
||||
self.cx.expr_match(self.sp, quote_expr!(self.cx, pc), arms)
|
||||
}
|
||||
|
||||
fn empty_block(&self) -> @ast::Expr {
|
||||
fn empty_block(&self) -> Gc<ast::Expr> {
|
||||
quote_expr!(self.cx, {})
|
||||
}
|
||||
|
||||
// Creates a match arm for the instruction at `pc` with the expression
|
||||
// `body`.
|
||||
fn arm_inst(&self, pc: uint, body: @ast::Expr) -> ast::Arm {
|
||||
fn arm_inst(&self, pc: uint, body: Gc<ast::Expr>) -> ast::Arm {
|
||||
let pc_pat = self.cx.pat_lit(self.sp, quote_expr!(self.cx, $pc));
|
||||
|
||||
self.cx.arm(self.sp, vec!(pc_pat), body)
|
||||
}
|
||||
|
||||
// Creates a wild-card match arm with the expression `body`.
|
||||
fn wild_arm_expr(&self, body: @ast::Expr) -> ast::Arm {
|
||||
fn wild_arm_expr(&self, body: Gc<ast::Expr>) -> ast::Arm {
|
||||
ast::Arm {
|
||||
attrs: vec!(),
|
||||
pats: vec!(@ast::Pat{
|
||||
pats: vec!(box(GC) ast::Pat{
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: self.sp,
|
||||
node: ast::PatWild,
|
||||
@ -603,8 +604,9 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
|
||||
// Converts `xs` to a `[x1, x2, .., xN]` expression by calling `to_expr`
|
||||
// on each element in `xs`.
|
||||
fn vec_expr<T, It: Iterator<T>>(&self, xs: It, to_expr: |&ExtCtxt, T| -> @ast::Expr)
|
||||
-> @ast::Expr {
|
||||
fn vec_expr<T, It: Iterator<T>>(&self, xs: It,
|
||||
to_expr: |&ExtCtxt, T| -> Gc<ast::Expr>)
|
||||
-> Gc<ast::Expr> {
|
||||
let exprs = xs.map(|x| to_expr(self.cx, x)).collect();
|
||||
self.cx.expr_vec(self.sp, exprs)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use syntax::fold::Folder;
|
||||
use syntax::{ast, fold, attr};
|
||||
use syntax::codemap;
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Context<'a> {
|
||||
in_cfg: |attrs: &[ast::Attribute]|: 'a -> bool,
|
||||
|
@ -23,7 +23,7 @@ use syntax::parse::token;
|
||||
use syntax::util::small_vector::SmallVector;
|
||||
|
||||
use std::mem;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub static VERSION: &'static str = "0.11.0-pre";
|
||||
|
||||
|
@ -18,7 +18,7 @@ use front::config;
|
||||
use front::std_inject::with_version;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::slice;
|
||||
use std::vec;
|
||||
use syntax::ast_util::*;
|
||||
|
@ -40,7 +40,7 @@ use libc;
|
||||
use std::io::Seek;
|
||||
use std::io::MemWriter;
|
||||
use std::mem;
|
||||
use std::string::String;
|
||||
use std::gc::GC;
|
||||
|
||||
use serialize::ebml::reader;
|
||||
use serialize::ebml;
|
||||
|
@ -23,6 +23,7 @@ use util::ppaux::{note_and_explain_region, Repr, UserString};
|
||||
use std::cell::{Cell};
|
||||
use std::ops::{BitOr, BitAnd};
|
||||
use std::rc::Rc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::string::String;
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
@ -70,7 +71,7 @@ pub fn check_crate(tcx: &ty::ctxt,
|
||||
krate: &ast::Crate) {
|
||||
let mut bccx = BorrowckCtxt {
|
||||
tcx: tcx,
|
||||
stats: @BorrowStats {
|
||||
stats: box(GC) BorrowStats {
|
||||
loaned_paths_same: Cell::new(0),
|
||||
loaned_paths_imm: Cell::new(0),
|
||||
stable_paths: Cell::new(0),
|
||||
@ -155,7 +156,7 @@ pub struct BorrowckCtxt<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
|
||||
// Statistics:
|
||||
stats: @BorrowStats
|
||||
stats: Gc<BorrowStats>,
|
||||
}
|
||||
|
||||
pub struct BorrowStats {
|
||||
|
@ -19,7 +19,7 @@ use middle::ty;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use std::cmp;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::iter;
|
||||
use syntax::ast::*;
|
||||
use syntax::ast_util::{is_unguarded, walk_pat};
|
||||
|
@ -123,7 +123,7 @@ impl<'a> Visitor<bool> for CheckStaticVisitor<'a> {
|
||||
ast::ExprUnary(ast::UnUniq, _) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
|
||||
self.tcx.sess.span_err(e.span,
|
||||
"static items are not allowed to have owned pointers");
|
||||
"static items are not allowed to have custom pointers");
|
||||
}
|
||||
_ => {
|
||||
let node_ty = ty::node_id_to_type(self.tcx, e.id);
|
||||
|
@ -245,10 +245,13 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
|
||||
check_bounds_on_type_parameters(cx, e);
|
||||
|
||||
match e.node {
|
||||
ExprUnary(UnBox, ref interior) => {
|
||||
ExprBox(ref loc, ref interior) => {
|
||||
let def = ty::resolve_expr(cx.tcx, &**loc);
|
||||
if Some(def.def_id()) == cx.tcx.lang_items.managed_heap() {
|
||||
let interior_type = ty::expr_ty(cx.tcx, &**interior);
|
||||
let _ = check_static(cx.tcx, interior_type, interior.span);
|
||||
}
|
||||
}
|
||||
ExprCast(ref source, _) => {
|
||||
let source_ty = ty::expr_ty(cx.tcx, &**source);
|
||||
let target_ty = ty::expr_ty(cx.tcx, e);
|
||||
|
@ -35,7 +35,7 @@ use syntax::visit::Visitor;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::mem::replace;
|
||||
use std::rc::{Rc, Weak};
|
||||
use std::uint;
|
||||
|
@ -226,7 +226,7 @@ use util::ppaux::{Repr, vec_map_to_str};
|
||||
use std::collections::HashMap;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use syntax::ast;
|
||||
use syntax::ast::Ident;
|
||||
use syntax::ast_util::path_to_ident;
|
||||
|
@ -60,6 +60,7 @@ time of error detection.
|
||||
*/
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::gc::GC;
|
||||
use middle::def;
|
||||
use middle::subst;
|
||||
use middle::ty;
|
||||
|
@ -32,7 +32,7 @@ use rustc::middle::ty;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::u32;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
use core;
|
||||
use doctree;
|
||||
|
@ -18,6 +18,7 @@ use syntax::parse::token;
|
||||
use syntax;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::GC;
|
||||
use std::os;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
|
@ -10,12 +10,13 @@
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::char;
|
||||
use std::io;
|
||||
use std::dynamic_lib::DynamicLibrary;
|
||||
use std::gc::GC;
|
||||
use std::io::{Command, TempDir};
|
||||
use std::io;
|
||||
use std::os;
|
||||
use std::str;
|
||||
use std::string::String;
|
||||
use std::dynamic_lib::DynamicLibrary;
|
||||
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use testing;
|
||||
|
@ -18,7 +18,7 @@ use syntax::ast_map;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::Span;
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
use core;
|
||||
use doctree::*;
|
||||
|
@ -274,6 +274,7 @@ impl<T: 'static> Drop for Ref<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::gc::{Gc, GC};
|
||||
use super::*;
|
||||
use std::task;
|
||||
|
||||
@ -329,11 +330,11 @@ mod tests {
|
||||
#[test]
|
||||
fn test_tls_multiple_types() {
|
||||
static str_key: Key<String> = &Key;
|
||||
static box_key: Key<@()> = &Key;
|
||||
static box_key: Key<Gc<()>> = &Key;
|
||||
static int_key: Key<int> = &Key;
|
||||
task::spawn(proc() {
|
||||
str_key.replace(Some("string data".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
int_key.replace(Some(42));
|
||||
});
|
||||
}
|
||||
@ -341,13 +342,13 @@ mod tests {
|
||||
#[test]
|
||||
fn test_tls_overwrite_multiple_types() {
|
||||
static str_key: Key<String> = &Key;
|
||||
static box_key: Key<@()> = &Key;
|
||||
static box_key: Key<Gc<()>> = &Key;
|
||||
static int_key: Key<int> = &Key;
|
||||
task::spawn(proc() {
|
||||
str_key.replace(Some("string data".to_string()));
|
||||
str_key.replace(Some("string data 2".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
int_key.replace(Some(42));
|
||||
// This could cause a segfault if overwriting-destruction is done
|
||||
// with the crazy polymorphic transmute rather than the provided
|
||||
@ -360,13 +361,13 @@ mod tests {
|
||||
#[should_fail]
|
||||
fn test_tls_cleanup_on_failure() {
|
||||
static str_key: Key<String> = &Key;
|
||||
static box_key: Key<@()> = &Key;
|
||||
static box_key: Key<Gc<()>> = &Key;
|
||||
static int_key: Key<int> = &Key;
|
||||
str_key.replace(Some("parent data".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
task::spawn(proc() {
|
||||
str_key.replace(Some("string data".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
int_key.replace(Some(42));
|
||||
fail!();
|
||||
});
|
||||
|
@ -317,14 +317,15 @@ pub unsafe fn local_free(ptr: *u8) {
|
||||
mod bench {
|
||||
extern crate test;
|
||||
use self::test::Bencher;
|
||||
use std::gc::GC;
|
||||
|
||||
#[bench]
|
||||
fn alloc_managed_small(b: &mut Bencher) {
|
||||
b.iter(|| { @10; });
|
||||
b.iter(|| { box(GC) 10 });
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn alloc_managed_big(b: &mut Bencher) {
|
||||
b.iter(|| { @([10, ..1000]); });
|
||||
b.iter(|| { box(GC) ([10, ..1000]) });
|
||||
}
|
||||
}
|
||||
|
@ -397,10 +397,11 @@ mod test {
|
||||
use super::*;
|
||||
use std::prelude::*;
|
||||
use std::task;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[test]
|
||||
fn local_heap() {
|
||||
let a = @5;
|
||||
let a = box(GC) 5;
|
||||
let b = a;
|
||||
assert!(*a == 5);
|
||||
assert!(*b == 5);
|
||||
@ -408,11 +409,11 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn tls() {
|
||||
local_data_key!(key: @String)
|
||||
key.replace(Some(@"data".to_string()));
|
||||
local_data_key!(key: Gc<String>)
|
||||
key.replace(Some(box(GC) "data".to_string()));
|
||||
assert_eq!(key.get().unwrap().as_slice(), "data");
|
||||
local_data_key!(key2: @String)
|
||||
key2.replace(Some(@"data".to_string()));
|
||||
local_data_key!(key2: Gc<String>)
|
||||
key2.replace(Some(box(GC) "data".to_string()));
|
||||
assert_eq!(key2.get().unwrap().as_slice(), "data");
|
||||
}
|
||||
|
||||
@ -452,11 +453,11 @@ mod test {
|
||||
use std::cell::RefCell;
|
||||
|
||||
struct List {
|
||||
next: Option<@RefCell<List>>,
|
||||
next: Option<Gc<RefCell<List>>>,
|
||||
}
|
||||
|
||||
let a = @RefCell::new(List { next: None });
|
||||
let b = @RefCell::new(List { next: Some(a) });
|
||||
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();
|
||||
|
@ -16,7 +16,7 @@ Core encoding and decoding interfaces.
|
||||
|
||||
use std::path;
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub trait Encoder<E> {
|
||||
// Primitive types:
|
||||
|
@ -92,7 +92,3 @@
|
||||
#[doc(no_inline)] pub use comm::{sync_channel, channel};
|
||||
#[doc(no_inline)] pub use comm::{SyncSender, Sender, Receiver};
|
||||
#[doc(no_inline)] pub use task::spawn;
|
||||
|
||||
// Reexported statics
|
||||
#[cfg(not(test))]
|
||||
#[doc(no_inline)] pub use gc::GC;
|
||||
|
@ -21,7 +21,7 @@ use std::fmt;
|
||||
use std::fmt::Show;
|
||||
use std::option::Option;
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
|
||||
/// A pointer abstraction. FIXME(eddyb) #10676 use Rc<T> in the future.
|
||||
|
@ -20,7 +20,7 @@ use util::small_vector::SmallVector;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::iter;
|
||||
use std::slice;
|
||||
|
||||
|
@ -21,7 +21,7 @@ use visit;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::cmp;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::u32;
|
||||
|
||||
pub fn path_name_i(idents: &[Ident]) -> String {
|
||||
|
@ -22,7 +22,7 @@ use crateid::CrateId;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::BitvSet;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
local_data_key!(used_attrs: BitvSet)
|
||||
|
||||
|
@ -20,6 +20,8 @@ use parse;
|
||||
use parse::token::InternedString;
|
||||
use parse::token;
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
enum State {
|
||||
Asm,
|
||||
Outputs,
|
||||
|
@ -20,7 +20,7 @@ use parse::token::{InternedString, intern, str_to_ident};
|
||||
use util::small_vector::SmallVector;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// new-style macro! tt code:
|
||||
//
|
||||
|
@ -21,7 +21,7 @@ use parse::token::special_idents;
|
||||
use parse::token::InternedString;
|
||||
use parse::token;
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// Transitional reexports so qquote can find the paths it is looking for
|
||||
mod syntax {
|
||||
|
@ -16,7 +16,7 @@ use owned_slice::OwnedSlice;
|
||||
use parse::token;
|
||||
use parse::token::{str_to_ident};
|
||||
|
||||
use std::string::String;
|
||||
use std::gc::GC;
|
||||
|
||||
pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
-> Box<base::MacResult> {
|
||||
|
@ -178,7 +178,7 @@ StaticEnum(<ast::EnumDef of C>, ~[(<ident of C0>, <span of C0>, Unnamed(~[<span
|
||||
*/
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
use ast;
|
||||
use ast::{P, EnumDef, Expr, Ident, Generics, StructDef};
|
||||
|
@ -29,7 +29,7 @@ use visit;
|
||||
use visit::Visitor;
|
||||
use util::small_vector::SmallVector;
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
|
||||
match e.node {
|
||||
@ -1030,6 +1030,8 @@ mod test {
|
||||
use visit;
|
||||
use visit::Visitor;
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
// a visitor that extracts the paths
|
||||
// from a given thingy and puts them in a mutable
|
||||
// array (passed in to the traversal)
|
||||
|
@ -20,7 +20,7 @@ use rsparse = parse;
|
||||
|
||||
use parse = fmt_macros;
|
||||
use std::collections::HashMap;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
enum ArgumentType {
|
||||
|
@ -22,6 +22,7 @@ use parse::token::{Token, EOF, Nonterminal};
|
||||
use parse::token;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::gc::GC;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/* This is an Earley-like parser, without support for in-grammar nonterminals,
|
||||
|
@ -17,7 +17,7 @@ use owned_slice::OwnedSlice;
|
||||
use util::small_vector::SmallVector;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// We may eventually want to be able to fold over type parameters, too.
|
||||
pub trait Folder {
|
||||
|
@ -16,7 +16,7 @@ use parse::token;
|
||||
use parse::parser::Parser;
|
||||
use parse::token::INTERPOLATED;
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// a parser that can parse attributes.
|
||||
pub trait ParserAttr {
|
||||
|
@ -282,6 +282,7 @@ mod test {
|
||||
use std::io;
|
||||
use std::io::MemWriter;
|
||||
use std::str;
|
||||
use std::gc::GC;
|
||||
use codemap::{Span, BytePos, Spanned};
|
||||
use owned_slice::OwnedSlice;
|
||||
use ast;
|
||||
|
@ -22,7 +22,7 @@ use codemap::{Span, respan};
|
||||
use parse::parser;
|
||||
use parse::token;
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
/// The specific types of unsupported syntax
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
@ -31,6 +31,8 @@ pub enum ObsoleteSyntax {
|
||||
ObsoleteOwnedExpr,
|
||||
ObsoleteOwnedPattern,
|
||||
ObsoleteOwnedVector,
|
||||
ObsoleteManagedType,
|
||||
ObsoleteManagedExpr,
|
||||
}
|
||||
|
||||
pub trait ParserObsoleteMethods {
|
||||
@ -68,6 +70,14 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
||||
"`~[T]` is no longer a type",
|
||||
"use the `Vec` type instead"
|
||||
),
|
||||
ObsoleteManagedType => (
|
||||
"`@` notation for managed pointers",
|
||||
"use `Gc<T>` in `std::gc` instead"
|
||||
),
|
||||
ObsoleteManagedExpr => (
|
||||
"`@` notation for a managed pointer allocation",
|
||||
"use the `box(GC)` oeprator instead of `@`"
|
||||
),
|
||||
};
|
||||
|
||||
self.report(sp, kind, kind_str, desc);
|
||||
|
@ -79,7 +79,7 @@ use owned_slice::OwnedSlice;
|
||||
use std::collections::HashSet;
|
||||
use std::mem::replace;
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(PartialEq)]
|
||||
@ -1342,6 +1342,8 @@ impl<'a> Parser<'a> {
|
||||
} else if self.token == token::AT {
|
||||
// MANAGED POINTER
|
||||
self.bump();
|
||||
let span = self.last_span;
|
||||
self.obsolete(span, ObsoleteManagedType);
|
||||
TyBox(self.parse_ty(plus_allowed))
|
||||
} else if self.token == token::TILDE {
|
||||
// OWNED POINTER
|
||||
@ -2375,9 +2377,10 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
token::AT => {
|
||||
self.bump();
|
||||
let span = self.last_span;
|
||||
self.obsolete(span, ObsoleteManagedExpr);
|
||||
let e = self.parse_prefix_expr();
|
||||
hi = e.span.hi;
|
||||
// HACK: pretending @[] is a (removed) @-vec
|
||||
ex = self.mk_unary(UnBox, e);
|
||||
}
|
||||
token::TILDE => {
|
||||
|
@ -15,6 +15,8 @@ use parse::{new_parser_from_source_str};
|
||||
use parse::parser::Parser;
|
||||
use parse::token;
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
// map a string to tts, using a made-up filename:
|
||||
pub fn string_to_tts(source_str: String) -> Vec<ast::TokenTree> {
|
||||
let ps = new_parse_sess();
|
||||
@ -46,21 +48,21 @@ pub fn string_to_crate (source_str : String) -> ast::Crate {
|
||||
}
|
||||
|
||||
// parse a string, return an expr
|
||||
pub fn string_to_expr (source_str : String) -> @ast::Expr {
|
||||
pub fn string_to_expr (source_str : String) -> Gc<ast::Expr> {
|
||||
with_error_checking_parse(source_str, |p| {
|
||||
p.parse_expr()
|
||||
})
|
||||
}
|
||||
|
||||
// parse a string, return an item
|
||||
pub fn string_to_item (source_str : String) -> Option<@ast::Item> {
|
||||
pub fn string_to_item (source_str : String) -> Option<Gc<ast::Item>> {
|
||||
with_error_checking_parse(source_str, |p| {
|
||||
p.parse_item(Vec::new())
|
||||
})
|
||||
}
|
||||
|
||||
// parse a string, return a stmt
|
||||
pub fn string_to_stmt(source_str : String) -> @ast::Stmt {
|
||||
pub fn string_to_stmt(source_str : String) -> Gc<ast::Stmt> {
|
||||
with_error_checking_parse(source_str, |p| {
|
||||
p.parse_stmt(Vec::new())
|
||||
})
|
||||
@ -68,7 +70,7 @@ pub fn string_to_stmt(source_str : String) -> @ast::Stmt {
|
||||
|
||||
// parse a string, return a pat. Uses "irrefutable"... which doesn't
|
||||
// (currently) affect parsing.
|
||||
pub fn string_to_pat(source_str: String) -> @ast::Pat {
|
||||
pub fn string_to_pat(source_str: String) -> Gc<ast::Pat> {
|
||||
string_to_parser(&new_parse_sess(), source_str).parse_pat()
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub struct Entry<A,B> {
|
||||
key: A,
|
||||
@ -19,7 +20,7 @@ pub struct Entry<A,B> {
|
||||
|
||||
pub struct alist<A,B> {
|
||||
eq_fn: extern "Rust" fn(A,A) -> bool,
|
||||
data: @RefCell<Vec<Entry<A,B>> >,
|
||||
data: Gc<RefCell<Vec<Entry<A,B>>>>,
|
||||
}
|
||||
|
||||
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
|
||||
@ -47,7 +48,7 @@ pub fn new_int_alist<B:'static>() -> alist<int, B> {
|
||||
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||
return alist {
|
||||
eq_fn: eq_int,
|
||||
data: @RefCell::new(Vec::new()),
|
||||
data: box(GC) RefCell::new(Vec::new()),
|
||||
};
|
||||
}
|
||||
|
||||
@ -57,6 +58,6 @@ pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
|
||||
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||
return alist {
|
||||
eq_fn: eq_int,
|
||||
data: @RefCell::new(Vec::new()),
|
||||
data: box(GC) RefCell::new(Vec::new()),
|
||||
};
|
||||
}
|
||||
|
@ -28,8 +28,9 @@ pub mod name_pool {
|
||||
|
||||
pub mod rust {
|
||||
pub use name_pool::add;
|
||||
use std::gc::Gc;
|
||||
|
||||
pub type rt = @();
|
||||
pub type rt = Gc<()>;
|
||||
|
||||
pub trait cx {
|
||||
fn cx(&self);
|
||||
|
@ -14,8 +14,9 @@
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::gc::Gc;
|
||||
|
||||
pub type header_map = HashMap<String, @RefCell<Vec<@String>>>;
|
||||
pub type header_map = HashMap<String, Gc<RefCell<Vec<Gc<String>>>>>;
|
||||
|
||||
// the unused ty param is necessary so this gets monomorphized
|
||||
pub fn request<T>(req: &header_map) {
|
||||
|
@ -11,5 +11,7 @@
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::gc::Gc;
|
||||
|
||||
pub type map = Gc<HashMap<uint, uint>>;
|
||||
|
||||
pub type map = @HashMap<uint, uint>;
|
||||
|
@ -21,6 +21,8 @@ use syntax::ext::base::*;
|
||||
use syntax::parse::token;
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exported_macro (() => (2))
|
||||
|
||||
@ -42,9 +44,9 @@ fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
|
||||
MacExpr::new(quote_expr!(cx, 1i))
|
||||
}
|
||||
|
||||
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: @MetaItem, it: @Item)
|
||||
-> @Item {
|
||||
@Item {
|
||||
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>)
|
||||
-> Gc<Item> {
|
||||
box(GC) Item {
|
||||
attrs: it.attrs.clone(),
|
||||
..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone()
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use time::precise_time_s;
|
||||
use std::os;
|
||||
use std::task;
|
||||
use std::vec;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[deriving(Clone)]
|
||||
enum List<T> {
|
||||
@ -53,10 +53,10 @@ type nillist = List<()>;
|
||||
// Filled with things that have to be unwound
|
||||
|
||||
struct State {
|
||||
managed: @nillist,
|
||||
managed: Gc<nillist>,
|
||||
unique: Box<nillist>,
|
||||
tuple: (@nillist, Box<nillist>),
|
||||
vec: Vec<@nillist>,
|
||||
tuple: (Gc<nillist>, Box<nillist>),
|
||||
vec: Vec<Gc<nillist>>,
|
||||
res: r
|
||||
}
|
||||
|
||||
|
@ -12,23 +12,25 @@
|
||||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct clam {
|
||||
x: @int,
|
||||
y: @int,
|
||||
x: Gc<int>,
|
||||
y: Gc<int>,
|
||||
}
|
||||
|
||||
struct fish {
|
||||
a: @int,
|
||||
a: Gc<int>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a: clam = clam{x: @1, y: @2};
|
||||
let b: clam = clam{x: @10, y: @20};
|
||||
let a: clam = clam{x: box(GC) 1, y: box(GC) 2};
|
||||
let b: clam = clam{x: box(GC) 10, y: box(GC) 20};
|
||||
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `@int`
|
||||
println!("{:?}", z);
|
||||
assert_eq!(z, 21);
|
||||
let forty: fish = fish{a: @40};
|
||||
let two: fish = fish{a: @2};
|
||||
let forty: fish = fish{a: box(GC) 40};
|
||||
let two: fish = fish{a: box(GC) 2};
|
||||
let answer: int = forty.a + two.a;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `@int`
|
||||
println!("{:?}", answer);
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn foo<'a>(x: &'a @int) -> &'a int {
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
fn foo<'a>(x: &'a Gc<int>) -> &'a int {
|
||||
match x {
|
||||
&ref y => {
|
||||
&**y // Do not expect an error here
|
||||
@ -25,7 +27,7 @@ fn bar() {
|
||||
let a = 3;
|
||||
let mut y = &a;
|
||||
if true {
|
||||
let x = @3;
|
||||
let x = box(GC) 3;
|
||||
y = &*x; //~ ERROR `*x` does not live long enough
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
@ -23,13 +24,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
||||
struct F { f: Box<int> }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = @F {f: box 3};
|
||||
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 *int, &(*b_x) as *int);
|
||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
||||
x = @F {f: box 4};
|
||||
x = box(GC) F {f: box 4};
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
@ -23,13 +24,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
||||
struct F { f: Box<int> }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = box @F{f: box 3};
|
||||
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 *int, &(*b_x) as *int);
|
||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
||||
*x = @F{f: box 4};
|
||||
*x = box(GC) F{f: box 4};
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
f(x);
|
||||
@ -20,13 +22,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut x = @3;
|
||||
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 *int, &(*b_x) as *int);
|
||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
||||
x = @22;
|
||||
x = box(GC) 22;
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
@ -12,9 +12,11 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn testfn(cond: bool) {
|
||||
let mut x = @3;
|
||||
let mut y = @4;
|
||||
let mut x = box(GC) 3;
|
||||
let mut y = box(GC) 4;
|
||||
|
||||
// borrow x and y
|
||||
let r_x = &*x;
|
||||
@ -30,13 +32,13 @@ fn testfn(cond: bool) {
|
||||
println!("*r = {}, exp = {}", *r, exp);
|
||||
assert_eq!(*r, exp);
|
||||
|
||||
x = @5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = @6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
x = box(GC) 5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = box(GC) 6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
|
||||
println!("*r = {}, exp = {}", *r, exp);
|
||||
assert_eq!(*r, exp);
|
||||
assert_eq!(x, @5);
|
||||
assert_eq!(y, @6);
|
||||
assert_eq!(x, box(GC) 5);
|
||||
assert_eq!(y, box(GC) 6);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
@ -23,13 +24,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
||||
struct F { f: Box<int> }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = @F {f: box 3};
|
||||
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 *int, &(*b_x) as *int);
|
||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
||||
x = @F {f: box 4};
|
||||
x = box(GC) F {f: box 4};
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
@ -10,12 +10,14 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn f<T>(x: T) -> @T {
|
||||
@x //~ ERROR value may contain references
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn f<T>(x: T) -> Gc<T> {
|
||||
box(GC) x //~ ERROR value may contain references
|
||||
}
|
||||
|
||||
fn g<T:'static>(x: T) -> @T {
|
||||
@x // ok
|
||||
fn g<T:'static>(x: T) -> Gc<T> {
|
||||
box(GC) x // ok
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -12,6 +12,7 @@
|
||||
// Verifies all possible restrictions for static items values.
|
||||
|
||||
use std::kinds::marker;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct WithDtor;
|
||||
|
||||
@ -95,7 +96,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct;
|
||||
struct MyOwned;
|
||||
|
||||
static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
// The following examples test that mutable structs are just forbidden
|
||||
// to have types with destructors
|
||||
@ -113,24 +114,24 @@ static mut STATIC14: SafeStruct = SafeStruct {
|
||||
};
|
||||
|
||||
static STATIC15: &'static [Box<MyOwned>] = &'static [box MyOwned, box MyOwned];
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
//~^^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) =
|
||||
(&'static box MyOwned, &'static box MyOwned);
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
//~^^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
static mut STATIC17: SafeEnum = Variant1;
|
||||
//~^ ERROR mutable static items are not allowed to have destructors
|
||||
|
||||
static STATIC18: @SafeStruct = @SafeStruct{field1: Variant1, field2: Variant2(0)};
|
||||
//~^ ERROR static items are not allowed to have managed pointers
|
||||
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;
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
pub fn main() {
|
||||
let y = { static x: Box<int> = box 3; x };
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
}
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
// Testing that we can't store a reference it task-local storage
|
||||
|
||||
local_data_key!(key: @&int)
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
local_data_key!(key: Gc<&int>)
|
||||
//~^ ERROR missing lifetime specifier
|
||||
|
||||
fn main() {}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
// test that autoderef of a type like this does not
|
||||
// cause compiler to loop. Note that no instances
|
||||
// of such a type could ever be constructed.
|
||||
@ -18,7 +20,7 @@ struct t { //~ ERROR this type cannot be instantiated
|
||||
to_str: (),
|
||||
}
|
||||
|
||||
struct x(@t); //~ ERROR this type cannot be instantiated
|
||||
struct x(Gc<t>); //~ ERROR this type cannot be instantiated
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -10,14 +10,16 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
struct P { child: Option<@P> }
|
||||
use std::gc::Gc;
|
||||
|
||||
struct P { child: Option<Gc<P>> }
|
||||
trait PTrait {
|
||||
fn getChildOption(&self) -> Option<@P>;
|
||||
fn getChildOption(&self) -> Option<Gc<P>>;
|
||||
}
|
||||
|
||||
impl PTrait for P {
|
||||
fn getChildOption(&self) -> Option<@P> {
|
||||
static childVal: @P = self.child.get();
|
||||
fn getChildOption(&self) -> Option<Gc<P>> {
|
||||
static childVal: Gc<P> = self.child.get();
|
||||
//~^ ERROR attempt to use a non-constant value in a constant
|
||||
fail!();
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
mod my_mod {
|
||||
pub struct MyStruct {
|
||||
priv_field: int
|
||||
@ -28,11 +30,11 @@ fn main() {
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
let _woohoo = (box my_struct).priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
let _woohoo = (@my_struct).priv_field;
|
||||
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
|
||||
(box my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
||||
(@my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
||||
(box(GC) my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
||||
let nope = my_struct.priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
}
|
||||
|
@ -10,10 +10,12 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct BarStruct;
|
||||
|
||||
impl<'a> BarStruct {
|
||||
fn foo(&'a mut self) -> @BarStruct { self }
|
||||
fn foo(&'a mut self) -> Gc<BarStruct> { self }
|
||||
//~^ ERROR: error: mismatched types: expected `@BarStruct` but found `&'a mut BarStruct
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,10 @@
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// Regresion test for issue 7364
|
||||
static managed: @RefCell<int> = @RefCell::new(0);
|
||||
//~^ ERROR static items are not allowed to have managed pointers
|
||||
static managed: Gc<RefCell<int>> = box(GC) RefCell::new(0);
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
fn main() { }
|
||||
|
@ -13,6 +13,7 @@
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
|
||||
fn assert_copy<T:Copy>() { }
|
||||
trait Dummy { }
|
||||
@ -77,7 +78,7 @@ fn test<'a,T,U:Copy>(_: &'a int) {
|
||||
assert_copy::<MyNoncopyStruct>(); //~ ERROR does not fulfill
|
||||
|
||||
// managed or ref counted types are not ok
|
||||
assert_copy::<@int>(); //~ ERROR does not fulfill
|
||||
assert_copy::<Gc<int>>(); //~ ERROR does not fulfill
|
||||
assert_copy::<Rc<int>>(); //~ ERROR does not fulfill
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,10 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct Foo {
|
||||
f: @int,
|
||||
f: Gc<int>,
|
||||
}
|
||||
|
||||
impl Drop for Foo {
|
||||
|
@ -10,10 +10,12 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn foo(_x: @uint) {}
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn foo(_x: Gc<uint>) {}
|
||||
|
||||
fn main() {
|
||||
let x = @3u;
|
||||
let x = box(GC) 3u;
|
||||
let _: proc():Send = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||
let _: proc():Send = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||
let _: proc():Send = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||
|
@ -12,9 +12,10 @@
|
||||
#![forbid(heap_memory)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Foo {
|
||||
x: @int //~ ERROR type uses managed
|
||||
x: Gc<int>, //~ ERROR type uses managed
|
||||
}
|
||||
|
||||
struct Bar { x: Box<int> } //~ ERROR type uses owned
|
||||
@ -22,7 +23,7 @@ struct Bar { x: Box<int> } //~ ERROR type uses owned
|
||||
fn main() {
|
||||
let _x : Bar = Bar {x : box 10}; //~ ERROR type uses owned
|
||||
|
||||
@2; //~ ERROR type uses managed
|
||||
box(GC) 2; //~ ERROR type uses managed
|
||||
|
||||
box 2; //~ ERROR type uses owned
|
||||
fn g(_: Box<Clone>) {} //~ ERROR type uses owned
|
||||
|
@ -12,11 +12,13 @@
|
||||
#![feature(managed_boxes)]
|
||||
#![forbid(managed_heap_memory)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Foo {
|
||||
x: @int //~ ERROR type uses managed
|
||||
x: Gc<int> //~ ERROR type uses managed
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _x : Foo = Foo {x : @10};
|
||||
let _x : Foo = Foo {x : box(GC) 10};
|
||||
//~^ ERROR type uses managed
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
// Tests that the new `box` syntax works with unique pointers and GC pointers.
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::owned::{Box, HEAP};
|
||||
|
||||
pub fn main() {
|
||||
|
@ -13,8 +13,9 @@
|
||||
extern crate debug;
|
||||
|
||||
use std::task;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Port<T>(@T);
|
||||
struct Port<T>(Gc<T>);
|
||||
|
||||
fn main() {
|
||||
struct foo {
|
||||
@ -32,7 +33,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let x = foo(Port(@()));
|
||||
let x = foo(Port(box(GC) ()));
|
||||
|
||||
task::spawn(proc() {
|
||||
let y = x; //~ ERROR does not fulfill `Send`
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let f; //~ ERROR cyclic type of infinite size
|
||||
f = @f;
|
||||
f = box(GC) f;
|
||||
}
|
||||
|
@ -13,9 +13,10 @@
|
||||
extern crate debug;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct r {
|
||||
i: @Cell<int>,
|
||||
i: Gc<Cell<int>>,
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
@ -27,7 +28,7 @@ impl Drop for r {
|
||||
}
|
||||
}
|
||||
|
||||
fn r(i: @Cell<int>) -> r {
|
||||
fn r(i: Gc<Cell<int>>) -> r {
|
||||
r {
|
||||
i: i
|
||||
}
|
||||
@ -38,7 +39,7 @@ struct A {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = @Cell::new(0);
|
||||
let i = box(GC) Cell::new(0);
|
||||
{
|
||||
// Can't do this copy
|
||||
let x = box box box A {y: r(i)};
|
||||
|
@ -12,9 +12,11 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn testfn(cond: bool) {
|
||||
let mut x = @3;
|
||||
let mut y = @4;
|
||||
let mut x = box(GC) 3;
|
||||
let mut y = box(GC) 4;
|
||||
|
||||
let mut a = &*x;
|
||||
|
||||
@ -25,11 +27,11 @@ fn testfn(cond: bool) {
|
||||
exp = 4;
|
||||
}
|
||||
|
||||
x = @5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = @6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
x = box(GC) 5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = box(GC) 6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
assert_eq!(*a, exp);
|
||||
assert_eq!(x, @5);
|
||||
assert_eq!(y, @6);
|
||||
assert_eq!(x, box(GC) 5);
|
||||
assert_eq!(y, box(GC) 6);
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct point {
|
||||
x: int,
|
||||
y: int,
|
||||
@ -19,7 +21,7 @@ fn x_coord<'r>(p: &'r point) -> &'r int {
|
||||
return &p.x;
|
||||
}
|
||||
|
||||
fn foo(p: @point) -> &int {
|
||||
fn foo(p: Gc<point>) -> &int {
|
||||
let xc = x_coord(p); //~ ERROR `*p` does not live long enough
|
||||
assert_eq!(*xc, 3);
|
||||
return xc;
|
||||
|
@ -10,9 +10,11 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
fn borrow<'r, T>(x: &'r T) -> &'r T {x}
|
||||
|
||||
fn foo(cond: || -> bool, make_box: || -> @int) {
|
||||
fn foo(cond: || -> bool, make_box: || -> Gc<int>) {
|
||||
let mut y: ∫
|
||||
loop {
|
||||
let x = make_box();
|
||||
|
@ -13,24 +13,26 @@
|
||||
// Check that we correctly infer that b and c must be region
|
||||
// parameterized because they reference a which requires a region.
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
type a<'a> = &'a int;
|
||||
type b<'a> = @a<'a>;
|
||||
type b<'a> = Gc<a<'a>>;
|
||||
|
||||
struct c<'a> {
|
||||
f: @b<'a>
|
||||
f: Gc<b<'a>>
|
||||
}
|
||||
|
||||
trait set_f<'a> {
|
||||
fn set_f_ok(&self, b: @b<'a>);
|
||||
fn set_f_bad(&self, b: @b);
|
||||
fn set_f_ok(&self, b: Gc<b<'a>>);
|
||||
fn set_f_bad(&self, b: Gc<b>);
|
||||
}
|
||||
|
||||
impl<'a> set_f<'a> for c<'a> {
|
||||
fn set_f_ok(&self, b: @b<'a>) {
|
||||
fn set_f_ok(&self, b: Gc<b<'a>>) {
|
||||
self.f = b;
|
||||
}
|
||||
|
||||
fn set_f_bad(&self, b: @b) {
|
||||
fn set_f_bad(&self, b: Gc<b>) {
|
||||
self.f = b; //~ ERROR mismatched types: expected `@@&'a int` but found `@@&int`
|
||||
//~^ ERROR cannot infer
|
||||
}
|
||||
|
@ -10,10 +10,12 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f<T:'static>(_: T) {}
|
||||
|
||||
fn main() {
|
||||
let x = @3;
|
||||
let x = box(GC) 3;
|
||||
f(x);
|
||||
let x = &3;
|
||||
f(x); //~ ERROR instantiating a type parameter with an incompatible type
|
||||
|
@ -10,11 +10,13 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Foo<'a> {
|
||||
x: &'a int
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let f = Foo { x: @3 }; //~ ERROR borrowed value does not live long enough
|
||||
let f = Foo { x: box(GC) 3 }; //~ ERROR borrowed value does not live long enough
|
||||
assert_eq!(*f.x, 3);
|
||||
}
|
||||
|
@ -10,12 +10,14 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct foo {
|
||||
a: int,
|
||||
b: int,
|
||||
}
|
||||
|
||||
type bar = @foo;
|
||||
type bar = Gc<foo>;
|
||||
|
||||
fn want_foo(f: foo) {}
|
||||
fn have_bar(b: bar) {
|
||||
|
@ -10,13 +10,15 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
trait Mumbo {
|
||||
fn jumbo(&self, x: @uint) -> uint;
|
||||
fn jumbo(&self, x: Gc<uint>) -> uint;
|
||||
}
|
||||
|
||||
impl Mumbo for uint {
|
||||
// Cannot have a larger effect than the trait:
|
||||
unsafe fn jumbo(&self, x: @uint) { *self + *x; }
|
||||
unsafe fn jumbo(&self, x: Gc<uint>) { *self + *x; }
|
||||
//~^ ERROR expected normal fn but found unsafe fn
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,12 @@
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f<T:Send>(_i: T) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = box @100;
|
||||
let i = box box(GC) 100;
|
||||
f(i); //~ ERROR does not fulfill `Send`
|
||||
}
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
extern crate debug;
|
||||
use std::cell::Cell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct r {
|
||||
i: @Cell<int>,
|
||||
i: Gc<Cell<int>>,
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
@ -30,8 +31,8 @@ fn f<T>(_i: Vec<T> , _j: Vec<T> ) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i1 = @Cell::new(0);
|
||||
let i2 = @Cell::new(1);
|
||||
let i1 = box(GC) Cell::new(0);
|
||||
let i2 = box(GC) Cell::new(1);
|
||||
let r1 = vec!(box r { i: i1 });
|
||||
let r2 = vec!(box r { i: i2 });
|
||||
f(r1.clone(), r2.clone());
|
||||
|
@ -13,12 +13,14 @@
|
||||
// Test that a class with an unsendable field can't be
|
||||
// sent
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct foo {
|
||||
i: int,
|
||||
j: @String,
|
||||
j: Gc<String>,
|
||||
}
|
||||
|
||||
fn foo(i:int, j: @String) -> foo {
|
||||
fn foo(i:int, j: Gc<String>) -> foo {
|
||||
foo {
|
||||
i: i,
|
||||
j: j
|
||||
@ -28,5 +30,5 @@ fn foo(i:int, j: @String) -> foo {
|
||||
fn main() {
|
||||
let cat = "kitty".to_string();
|
||||
let (tx, _) = channel(); //~ ERROR does not fulfill `Send`
|
||||
tx.send(foo(42, @(cat))); //~ ERROR does not fulfill `Send`
|
||||
tx.send(foo(42, box(GC) (cat))); //~ ERROR does not fulfill `Send`
|
||||
}
|
||||
|
@ -63,47 +63,49 @@
|
||||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
let bool_box: @bool = @true;
|
||||
let bool_box: Gc<bool> = box(GC) true;
|
||||
let bool_ref: &bool = bool_box;
|
||||
|
||||
let int_box: @int = @-1;
|
||||
let int_box: Gc<int> = box(GC) -1;
|
||||
let int_ref: &int = int_box;
|
||||
|
||||
let char_box: @char = @'a';
|
||||
let char_box: Gc<char> = box(GC) 'a';
|
||||
let char_ref: &char = char_box;
|
||||
|
||||
let i8_box: @i8 = @68;
|
||||
let i8_box: Gc<i8> = box(GC) 68;
|
||||
let i8_ref: &i8 = i8_box;
|
||||
|
||||
let i16_box: @i16 = @-16;
|
||||
let i16_box: Gc<i16> = box(GC) -16;
|
||||
let i16_ref: &i16 = i16_box;
|
||||
|
||||
let i32_box: @i32 = @-32;
|
||||
let i32_box: Gc<i32> = box(GC) -32;
|
||||
let i32_ref: &i32 = i32_box;
|
||||
|
||||
let i64_box: @i64 = @-64;
|
||||
let i64_box: Gc<i64> = box(GC) -64;
|
||||
let i64_ref: &i64 = i64_box;
|
||||
|
||||
let uint_box: @uint = @1;
|
||||
let uint_box: Gc<uint> = box(GC) 1;
|
||||
let uint_ref: &uint = uint_box;
|
||||
|
||||
let u8_box: @u8 = @100;
|
||||
let u8_box: Gc<u8> = box(GC) 100;
|
||||
let u8_ref: &u8 = u8_box;
|
||||
|
||||
let u16_box: @u16 = @16;
|
||||
let u16_box: Gc<u16> = box(GC) 16;
|
||||
let u16_ref: &u16 = u16_box;
|
||||
|
||||
let u32_box: @u32 = @32;
|
||||
let u32_box: Gc<u32> = box(GC) 32;
|
||||
let u32_ref: &u32 = u32_box;
|
||||
|
||||
let u64_box: @u64 = @64;
|
||||
let u64_box: Gc<u64> = box(GC) 64;
|
||||
let u64_ref: &u64 = u64_box;
|
||||
|
||||
let f32_box: @f32 = @2.5;
|
||||
let f32_box: Gc<f32> = box(GC) 2.5;
|
||||
let f32_ref: &f32 = f32_box;
|
||||
|
||||
let f64_box: @f64 = @3.5;
|
||||
let f64_box: Gc<f64> = box(GC) 3.5;
|
||||
let f64_ref: &f64 = f64_box;
|
||||
zzz();
|
||||
}
|
||||
|
@ -48,6 +48,8 @@
|
||||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct SomeStruct {
|
||||
x: int,
|
||||
y: f64
|
||||
@ -60,7 +62,7 @@ fn main() {
|
||||
let stack_val_interior_ref_2: &f64 = &stack_val.y;
|
||||
let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };
|
||||
|
||||
let managed_val = @SomeStruct { x: 12, y: 25.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;
|
||||
|
@ -31,13 +31,14 @@
|
||||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
let stack_val: (i16, f32) = (-14, -19f32);
|
||||
let stack_val_ref: &(i16, f32) = &stack_val;
|
||||
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
|
||||
|
||||
let managed_val: @(i16, f32) = @(-16, -21f32);
|
||||
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);
|
||||
|
@ -27,11 +27,13 @@
|
||||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let a = box 1;
|
||||
let b = box() (2, 3.5);
|
||||
let c = @4;
|
||||
let d = @false;
|
||||
let c = box(GC) 4;
|
||||
let d = box(GC) false;
|
||||
_zzz();
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct StructWithSomePadding {
|
||||
x: i16,
|
||||
@ -52,10 +53,10 @@ impl Drop for StructWithDestructor {
|
||||
fn main() {
|
||||
|
||||
let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 };
|
||||
let managed = @StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 };
|
||||
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 managed_dtor = @StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 };
|
||||
let managed_dtor = box(GC) StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 };
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
@ -36,6 +36,8 @@
|
||||
// gdb-check:$4 = 8888
|
||||
// gdb-command:continue
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
trait Trait {
|
||||
fn method(self) -> Self;
|
||||
}
|
||||
@ -66,8 +68,8 @@ impl Trait for (f64, int, int, f64) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Trait for @int {
|
||||
fn method(self) -> @int {
|
||||
impl Trait for Gc<int> {
|
||||
fn method(self) -> Gc<int> {
|
||||
zzz();
|
||||
self
|
||||
}
|
||||
@ -77,7 +79,7 @@ fn main() {
|
||||
let _ = (1111 as int).method();
|
||||
let _ = Struct { x: 2222, y: 3333 }.method();
|
||||
let _ = (4444.5, 5555, 6666, 7777.5).method();
|
||||
let _ = (@8888).method();
|
||||
let _ = (box(GC) 8888).method();
|
||||
}
|
||||
|
||||
fn zzz() {()}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#![allow(unused_variable)]
|
||||
#![feature(struct_variant, managed_boxes)]
|
||||
|
||||
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.
|
||||
@ -50,15 +52,15 @@ fn main() {
|
||||
// 0b01111100011111000111110001111100 = 2088533116
|
||||
// 0b0111110001111100 = 31868
|
||||
// 0b01111100 = 124
|
||||
let the_a = @TheA { x: 0, y: 8970181431921507452 };
|
||||
let the_a = box(GC) TheA { x: 0, y: 8970181431921507452 };
|
||||
|
||||
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
|
||||
// 0b00010001000100010001000100010001 = 286331153
|
||||
// 0b0001000100010001 = 4369
|
||||
// 0b00010001 = 17
|
||||
let the_b = @TheB (0, 286331153, 286331153);
|
||||
let the_b = box(GC) TheB (0, 286331153, 286331153);
|
||||
|
||||
let univariant = @TheOnlyCase(-9747455);
|
||||
let univariant = box(GC) TheOnlyCase(-9747455);
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
@ -31,9 +31,11 @@
|
||||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
|
||||
let unique: Vec<@i64> = vec!(@10, @11, @12, @13);
|
||||
let unique: Vec<Gc<i64>> = vec!(box(GC) 10, box(GC) 11, box(GC) 12, box(GC) 13);
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
@ -29,15 +29,17 @@
|
||||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
struct ContainsManaged {
|
||||
x: int,
|
||||
y: @int
|
||||
y: Gc<int>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let ordinary_unique = box() (-1, -2);
|
||||
|
||||
let managed_within_unique = box ContainsManaged { x: -3, y: @-4 };
|
||||
let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4 };
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
@ -106,6 +106,7 @@
|
||||
#![allow(unused_variable)]
|
||||
#![feature(struct_variant)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
enum Opt<T> {
|
||||
Empty,
|
||||
@ -118,7 +119,7 @@ struct UniqueNode<T> {
|
||||
}
|
||||
|
||||
struct ManagedNode<T> {
|
||||
next: Opt<@ManagedNode<T>>,
|
||||
next: Opt<Gc<ManagedNode<T>>>,
|
||||
value: T
|
||||
}
|
||||
|
||||
@ -183,7 +184,7 @@ fn main() {
|
||||
value: 2,
|
||||
};
|
||||
|
||||
let box_unique: @UniqueNode<u64> = @UniqueNode {
|
||||
let box_unique: Gc<UniqueNode<u64>> = box(GC) UniqueNode {
|
||||
next: Val {
|
||||
val: box UniqueNode {
|
||||
next: Empty,
|
||||
@ -215,7 +216,7 @@ fn main() {
|
||||
|
||||
let stack_managed: ManagedNode<u16> = ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 11,
|
||||
}
|
||||
@ -225,7 +226,7 @@ fn main() {
|
||||
|
||||
let unique_managed: Box<ManagedNode<u32>> = box ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 13,
|
||||
}
|
||||
@ -233,9 +234,9 @@ fn main() {
|
||||
value: 12,
|
||||
};
|
||||
|
||||
let box_managed: @ManagedNode<u64> = @ManagedNode {
|
||||
let box_managed: Gc<ManagedNode<u64>> = box(GC) ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 15,
|
||||
}
|
||||
@ -245,7 +246,7 @@ fn main() {
|
||||
|
||||
let vec_managed: [ManagedNode<f32>, ..1] = [ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 17.5,
|
||||
}
|
||||
@ -255,7 +256,7 @@ fn main() {
|
||||
|
||||
let borrowed_managed: &ManagedNode<f64> = &ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 19.5,
|
||||
}
|
||||
|
@ -51,6 +51,8 @@
|
||||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct Struct {
|
||||
a: int,
|
||||
b: f64,
|
||||
@ -69,7 +71,7 @@ fn main() {
|
||||
|
||||
let struct_ref = &a_struct;
|
||||
let owned = box 6;
|
||||
let managed = @7;
|
||||
let managed = box(GC) 7;
|
||||
|
||||
let closure = || {
|
||||
let closure_local = 8;
|
||||
|
@ -31,6 +31,8 @@
|
||||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct Struct {
|
||||
a: int,
|
||||
b: f64,
|
||||
@ -49,7 +51,7 @@ fn main() {
|
||||
|
||||
let struct_ref = &a_struct;
|
||||
let owned = box 6;
|
||||
let managed = @7;
|
||||
let managed = box(GC) 7;
|
||||
|
||||
let closure = || {
|
||||
zzz();
|
||||
|
@ -15,33 +15,34 @@
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::gc::GC;
|
||||
|
||||
fn test1() { let val = @0; { } *val; }
|
||||
fn test1() { let val = box(GC) 0; { } *val; }
|
||||
|
||||
fn test2() -> int { let val = @0; { } *val }
|
||||
fn test2() -> int { let val = box(GC) 0; { } *val }
|
||||
|
||||
struct S { eax: int }
|
||||
|
||||
fn test3() {
|
||||
let regs = @Cell::new(S {eax: 0});
|
||||
let regs = box(GC) Cell::new(S {eax: 0});
|
||||
match true { true => { } _ => { } }
|
||||
regs.set(S {eax: 1});
|
||||
}
|
||||
|
||||
fn test4() -> bool { let regs = @true; if true { } *regs || false }
|
||||
fn test4() -> bool { let regs = box(GC) true; if true { } *regs || false }
|
||||
|
||||
fn test5() -> (int, int) { { } (0, 1) }
|
||||
|
||||
fn test6() -> bool { { } (true || false) && true }
|
||||
|
||||
fn test7() -> uint {
|
||||
let regs = @0;
|
||||
let regs = box(GC) 0;
|
||||
match true { true => { } _ => { } }
|
||||
(*regs < 2) as uint
|
||||
}
|
||||
|
||||
fn test8() -> int {
|
||||
let val = @0;
|
||||
let val = box(GC) 0;
|
||||
match true {
|
||||
true => { }
|
||||
_ => { }
|
||||
@ -54,12 +55,12 @@ fn test8() -> int {
|
||||
}
|
||||
|
||||
fn test9() {
|
||||
let regs = @Cell::new(0);
|
||||
let regs = box(GC) Cell::new(0);
|
||||
match true { true => { } _ => { } } regs.set(regs.get() + 1);
|
||||
}
|
||||
|
||||
fn test10() -> int {
|
||||
let regs = @vec!(0);
|
||||
let regs = box(GC) vec!(0);
|
||||
match true { true => { } _ => { } }
|
||||
*(*regs).get(0)
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
// error-pattern:meep
|
||||
fn f(_a: int, _b: int, _c: @int) { fail!("moop"); }
|
||||
|
||||
fn main() { f(1, fail!("meep"), @42); }
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn f(_a: int, _b: int, _c: Gc<int>) { fail!("moop"); }
|
||||
|
||||
fn main() { f(1, fail!("meep"), box(GC) 42); }
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user