auto merge of #14835 : alexcrichton/rust/no-more-at, r=brson

All functionality is now available through `Gc<T>` and `box(GC) expr`. This change also removes `GC` from the prelude (it's an experimental feature).
This commit is contained in:
bors 2014-06-14 17:51:49 +00:00
commit 6d8342f5e9
258 changed files with 949 additions and 680 deletions

View file

@ -20,14 +20,7 @@ extern crate test;
extern crate getopts;
extern crate green;
extern crate rustuv;
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate log;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate log;
#[phase(plugin, link)] extern crate log;
extern crate regex;

View file

@ -70,25 +70,16 @@
#![no_std]
#![feature(phase)]
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate core;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate core;
extern crate libc;
// Allow testing this library
#[cfg(test)] extern crate debug;
#[cfg(test)] extern crate native;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate std;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate std;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
// Heaps provided for low-level allocation strategies

View file

@ -23,24 +23,15 @@
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
#![no_std]
#[phase(plugin, link)] extern crate core;
extern crate alloc;
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate core;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate core;
#[cfg(test)] extern crate native;
#[cfg(test)] extern crate test;
#[cfg(test)] extern crate debug;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate std;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate std;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
use core::prelude::*;

View file

@ -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]

View file

@ -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 {

View file

@ -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
}

View file

@ -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}");

View file

@ -27,8 +27,7 @@ Simple [DEFLATE][def]-based compression. This is a wrapper around the
html_root_url = "http://doc.rust-lang.org/")]
#![feature(phase)]
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
extern crate libc;

View file

@ -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()

View file

@ -90,8 +90,7 @@
#![deny(missing_doc)]
#[cfg(test)] extern crate debug;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
use std::cmp::PartialEq;
use std::fmt;

View file

@ -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()

View file

@ -28,26 +28,11 @@
#![no_std]
#![experimental]
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate core;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate core;
#[cfg(test, stage0)]
#[phase(syntax, link)] extern crate std;
#[cfg(test, stage0)]
#[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))]
#[phase(plugin, link)] extern crate std;
#[cfg(test, not(stage0))]
#[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(test)] extern crate native;
#[cfg(test)] extern crate debug;

View file

@ -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)
}

View file

@ -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,

View file

@ -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";

View file

@ -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::*;

View file

@ -40,14 +40,7 @@ extern crate libc;
extern crate serialize;
extern crate syntax;
extern crate time;
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate log;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate log;
#[phase(plugin, link)] extern crate log;
pub mod middle {
pub mod def;

View file

@ -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;

View file

@ -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 {

View file

@ -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};

View file

@ -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);

View file

@ -245,9 +245,12 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
check_bounds_on_type_parameters(cx, e);
match e.node {
ExprUnary(UnBox, ref interior) => {
let interior_type = ty::expr_ty(cx.tcx, &**interior);
let _ = check_static(cx.tcx, interior_type, interior.span);
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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -24,14 +24,7 @@ extern crate serialize;
extern crate syntax;
extern crate testing = "test";
extern crate time;
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate log;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate log;
#[phase(plugin, link)] extern crate log;
use std::io;
use std::io::{File, MemWriter};

View file

@ -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;

View file

@ -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::*;

View file

@ -20,14 +20,7 @@
#![no_std]
#![experimental]
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate core;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate core;
#[phase(plugin, link)] extern crate core;
extern crate alloc;
extern crate libc;
extern crate collections;
@ -36,8 +29,7 @@ extern crate collections;
#[cfg(test)] extern crate test;
#[cfg(test)] extern crate native;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate std;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate std;
pub use self::util::{Stdio, Stdout, Stderr};
pub use self::unwind::{begin_unwind, begin_unwind_fmt};

View file

@ -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!();
});

View file

@ -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]) });
}
}

View file

@ -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();

View file

@ -28,11 +28,6 @@ Core encoding and decoding interfaces.
#[cfg(test)]
extern crate test;
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate log;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate log;

View file

@ -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:

View file

@ -33,9 +33,6 @@ use raw;
task annihilation. For now, cycles need to be broken manually by using `Rc<T>` \
with a non-owning `Weak<T>` pointer. A tracing garbage collector is planned."]
pub struct Gc<T> {
#[cfg(stage0)]
ptr: @T,
#[cfg(not(stage0))]
_ptr: *T,
marker: marker::NoSend,
}
@ -76,9 +73,6 @@ impl<T: Ord + 'static> Ord for Gc<T> {
impl<T: Eq + 'static> Eq for Gc<T> {}
impl<T: 'static> Deref<T> for Gc<T> {
#[cfg(stage0)]
fn deref<'a>(&'a self) -> &'a T { &*self.ptr }
#[cfg(not(stage0))]
fn deref<'a>(&'a self) -> &'a T { &**self }
}

View file

@ -119,8 +119,7 @@
#[cfg(test)] extern crate native;
#[cfg(test)] extern crate green;
#[cfg(test)] extern crate debug;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
extern crate alloc;
extern crate core;

View file

@ -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;

View file

@ -30,9 +30,6 @@
#![deny(missing_doc)]
#![no_std]
#[cfg(stage0)]
#[phase(syntax, link)] extern crate core;
#[cfg(not(stage0))]
#[phase(plugin, link)] extern crate core;
extern crate alloc;
extern crate collections;
@ -40,8 +37,7 @@ extern crate rustrt;
#[cfg(test)] extern crate test;
#[cfg(test)] extern crate native;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate std;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate std;
pub use alloc::arc::{Arc, Weak};
pub use lock::{Mutex, MutexGuard, Condvar, Barrier,

View file

@ -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.

View file

@ -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;

View file

@ -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 {

View file

@ -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)

View file

@ -20,6 +20,8 @@ use parse;
use parse::token::InternedString;
use parse::token;
use std::gc::GC;
enum State {
Asm,
Outputs,

View file

@ -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:
//

View file

@ -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 {

View file

@ -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> {

View file

@ -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};

View file

@ -79,7 +79,6 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
"Encodable" => expand!(encodable::expand_deriving_encodable),
"Decodable" => expand!(decodable::expand_deriving_decodable),
// NOTE: after a stage0 snap this needs treatment
"PartialEq" => expand!(eq::expand_deriving_eq),
"Eq" => expand!(totaleq::expand_deriving_totaleq),
"PartialOrd" => expand!(ord::expand_deriving_ord),

View file

@ -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)

View file

@ -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 {

View file

@ -37,17 +37,8 @@ pub mod rt {
use parse;
use print::pprust;
#[cfg(not(stage0))]
use ast::{TokenTree, Generics, Expr};
// NOTE remove this after snapshot
// (stage0 quasiquoter needs this)
#[cfg(stage0)]
pub use ast::{Generics, TokenTree, TTTok};
#[cfg(stage0)]
pub use parse::token::{IDENT, SEMI, LBRACE, RBRACE, LIFETIME, COLON, AND, BINOP, EQ,
LBRACKET, RBRACKET, LPAREN, RPAREN, POUND, NOT, MOD_SEP, DOT, COMMA};
pub use parse::new_parser_from_tts;
pub use codemap::{BytePos, Span, dummy_spanned};

View file

@ -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,

View file

@ -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 {

View file

@ -32,14 +32,7 @@ This API is completely unstable and subject to change.
extern crate serialize;
extern crate term;
#[cfg(stage0)]
#[phase(syntax, link)]
extern crate log;
#[cfg(not(stage0))]
#[phase(plugin, link)]
extern crate log;
#[phase(plugin, link)] extern crate log;
extern crate fmt_macros;
extern crate debug;

View file

@ -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 {

View file

@ -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;

View file

@ -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);

View file

@ -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 => {

View file

@ -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()
}

View file

@ -52,8 +52,7 @@
#![deny(missing_doc)]
#[cfg(stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(not(stage0))] #[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate log;
pub use terminfo::TerminfoTerminal;
#[cfg(windows)]

View file

@ -22,9 +22,7 @@
#![feature(phase)]
#[cfg(test)] extern crate debug;
#[cfg(test, stage0)] #[phase(syntax, link)] extern crate log;
#[cfg(test, not(stage0))] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
extern crate serialize;
extern crate libc;

View file

@ -1,3 +1,11 @@
S 2014-06-11 f9260d4
freebsd-x86_64 57f155da12e561a277506f999a616ff689a55dcc
linux-i386 df46b5dab3620375d6175c284ea0aeb3f9c6a11e
linux-x86_64 a760c8271ecb850bc802e151c2a321f212edf526
macos-i386 d6c831717aebd16694fb7e63dca98845e6583378
macos-x86_64 76932cacbdc2557e51565917a1bb6629b0b4ebc1
winnt-i386 6285faeac311a9a84db078ab93d299a65abeeea9
S 2014-05-30 60a43f9
freebsd-x86_64 59067eb9e89bde3e20a1078104f4b1105e4b56fc
linux-i386 c1a81811e8e104c91c35d94a140e3cf8463c7655

View file

@ -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()),
};
}

View file

@ -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);

View file

@ -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) {

View file

@ -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>;

View file

@ -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()
}

View file

@ -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
}

View file

@ -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);

View file

@ -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
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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() {

View file

@ -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);

View file

@ -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() {}

View file

@ -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
}

View file

@ -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() {}

View file

@ -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() {
}

View file

@ -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!();
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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() { }

View file

@ -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
}

View file

@ -10,8 +10,10 @@
#![feature(managed_boxes)]
use std::gc::Gc;
struct Foo {
f: @int,
f: Gc<int>,
}
impl Drop for Foo {

View file

@ -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`

View file

@ -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

View file

@ -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
}

View file

@ -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() {

View file

@ -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`

View file

@ -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;
}

View file

@ -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)};

View file

@ -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() {}

View file

@ -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;

View file

@ -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: &int;
loop {
let x = make_box();

View file

@ -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
}

View file

@ -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

View file

@ -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);
}

Some files were not shown because too many files have changed in this diff Show more