Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove @ syntax for Gc'd pointers #14835

Merged
merged 2 commits into from
Jun 14, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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]
  • Loading branch information
alexcrichton committed Jun 14, 2014
commit ade807c6dcf6dc4454732c5e914ca06ebb429773
12 changes: 7 additions & 5 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/libdebug/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 5 additions & 4 deletions src/libdebug/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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}");

Expand Down
5 changes: 4 additions & 1 deletion src/libfourcc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion src/libhexfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
26 changes: 14 additions & 12 deletions src/libregex_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)| {
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -155,7 +156,7 @@ pub struct BorrowckCtxt<'a> {
tcx: &'a ty::ctxt,

// Statistics:
stats: @BorrowStats
stats: Gc<BorrowStats>,
}

pub struct BorrowStats {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/typeck/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading