Skip to content

Commit ade807c

Browse files
committed
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]
1 parent f20b129 commit ade807c

File tree

239 files changed

+919
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+919
-558
lines changed

src/libcollections/ringbuf.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
419419
mod tests {
420420
use std::fmt::Show;
421421
use std::prelude::*;
422+
use std::gc::{GC, Gc};
422423
use test::Bencher;
423424
use test;
424425

@@ -473,10 +474,10 @@ mod tests {
473474

474475
#[test]
475476
fn test_boxes() {
476-
let a: @int = @5;
477-
let b: @int = @72;
478-
let c: @int = @64;
479-
let d: @int = @175;
477+
let a: Gc<int> = box(GC) 5;
478+
let b: Gc<int> = box(GC) 72;
479+
let c: Gc<int> = box(GC) 64;
480+
let d: Gc<int> = box(GC) 175;
480481

481482
let mut deq = RingBuf::new();
482483
assert_eq!(deq.len(), 0);
@@ -621,7 +622,8 @@ mod tests {
621622

622623
#[test]
623624
fn test_param_at_int() {
624-
test_parameterized::<@int>(@5, @72, @64, @175);
625+
test_parameterized::<Gc<int>>(box(GC) 5, box(GC) 72,
626+
box(GC) 64, box(GC) 175);
625627
}
626628

627629
#[test]

src/libcore/iter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,7 @@ mod tests {
23452345
use num;
23462346
use realstd::vec::Vec;
23472347
use realstd::slice::Vector;
2348+
use realstd::gc::GC;
23482349

23492350
use cmp;
23502351
use realstd::owned::Box;
@@ -2835,7 +2836,8 @@ mod tests {
28352836
#[test]
28362837
#[should_fail]
28372838
fn test_rposition_fail() {
2838-
let v = [(box 0, @0), (box 0, @0), (box 0, @0), (box 0, @0)];
2839+
let v = [(box 0, box(GC) 0), (box 0, box(GC) 0),
2840+
(box 0, box(GC) 0), (box 0, box(GC) 0)];
28392841
let mut i = 0;
28402842
v.iter().rposition(|_elt| {
28412843
if i == 2 {

src/libdebug/reflect.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Runtime type reflection
1818

1919
use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
2020
use std::mem;
21+
use std::gc::Gc;
2122

2223
/**
2324
* Trait for visitor that wishes to reflect on data.
@@ -219,9 +220,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
219220
}
220221

221222
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
222-
self.align_to::<@u8>();
223+
self.align_to::<Gc<u8>>();
223224
if ! self.inner.visit_box(mtbl, inner) { return false; }
224-
self.bump_past::<@u8>();
225+
self.bump_past::<Gc<u8>>();
225226
true
226227
}
227228

src/libdebug/repr.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
288288
_align: uint) -> bool { fail!(); }
289289

290290
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
291-
try!(self, self.writer.write(['@' as u8]));
291+
try!(self, self.writer.write("box(GC) ".as_bytes()));
292292
self.write_mut_qualifier(mtbl);
293293
self.get::<&raw::Box<()>>(|this, b| {
294294
let p = &b.data as *() as *u8;
@@ -591,6 +591,7 @@ fn test_repr() {
591591
use std::io::stdio::println;
592592
use std::char::is_alphabetic;
593593
use std::mem::swap;
594+
use std::gc::GC;
594595

595596
fn exact_test<T>(t: &T, e:&str) {
596597
let mut m = io::MemWriter::new();
@@ -605,7 +606,7 @@ fn test_repr() {
605606
exact_test(&1.234, "1.234f64");
606607
exact_test(&("hello"), "\"hello\"");
607608

608-
exact_test(&(@10), "@10");
609+
exact_test(&(box(GC) 10), "box(GC) 10");
609610
exact_test(&(box 10), "box 10");
610611
exact_test(&(&10), "&10");
611612
let mut x = 10;
@@ -619,8 +620,8 @@ fn test_repr() {
619620
"&[\"hi\", \"there\"]");
620621
exact_test(&(P{a:10, b:1.234}),
621622
"repr::P{a: 10, b: 1.234f64}");
622-
exact_test(&(@P{a:10, b:1.234}),
623-
"@repr::P{a: 10, b: 1.234f64}");
623+
exact_test(&(box(GC) P{a:10, b:1.234}),
624+
"box(GC) repr::P{a: 10, b: 1.234f64}");
624625
exact_test(&(box P{a:10, b:1.234}),
625626
"box repr::P{a: 10, b: 1.234f64}");
626627

src/libfourcc/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ use syntax::parse::token;
6363
use syntax::parse::token::InternedString;
6464
use rustc::plugin::Registry;
6565

66+
use std::gc::Gc;
67+
6668
#[plugin_registrar]
6769
pub fn plugin_registrar(reg: &mut Registry) {
6870
reg.register_macro("fourcc", expand_syntax_ext);
@@ -130,7 +132,8 @@ struct Ident {
130132
span: Span
131133
}
132134

133-
fn parse_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> (@ast::Expr, Option<Ident>) {
135+
fn parse_tts(cx: &ExtCtxt,
136+
tts: &[ast::TokenTree]) -> (Gc<ast::Expr>, Option<Ident>) {
134137
let p = &mut parse::new_parser_from_tts(cx.parse_sess(),
135138
cx.cfg(),
136139
tts.iter()

src/libhexfloat/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ use syntax::parse;
5757
use syntax::parse::token;
5858
use rustc::plugin::Registry;
5959

60+
use std::gc::Gc;
61+
6062
#[plugin_registrar]
6163
pub fn plugin_registrar(reg: &mut Registry) {
6264
reg.register_macro("hexfloat", expand_syntax_ext);
@@ -163,7 +165,8 @@ struct Ident {
163165
span: Span
164166
}
165167

166-
fn parse_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> (@ast::Expr, Option<Ident>) {
168+
fn parse_tts(cx: &ExtCtxt,
169+
tts: &[ast::TokenTree]) -> (Gc<ast::Expr>, Option<Ident>) {
167170
let p = &mut parse::new_parser_from_tts(cx.parse_sess(),
168171
cx.cfg(),
169172
tts.iter()

src/libregex_macros/lib.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern crate syntax;
2626
extern crate rustc;
2727

2828
use std::rc::Rc;
29+
use std::gc::{Gc, GC};
2930

3031
use syntax::ast;
3132
use syntax::codemap;
@@ -110,7 +111,7 @@ struct NfaGen<'a> {
110111
}
111112

112113
impl<'a> NfaGen<'a> {
113-
fn code(&mut self) -> @ast::Expr {
114+
fn code(&mut self) -> Gc<ast::Expr> {
114115
// Most or all of the following things are used in the quasiquoted
115116
// expression returned.
116117
let num_cap_locs = 2 * self.prog.num_captures();
@@ -331,7 +332,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
331332

332333
// Generates code for the `add` method, which is responsible for adding
333334
// zero-width states to the next queue of states to visit.
334-
fn add_insts(&self) -> @ast::Expr {
335+
fn add_insts(&self) -> Gc<ast::Expr> {
335336
let arms = self.prog.insts.iter().enumerate().map(|(pc, inst)| {
336337
let nextpc = pc + 1;
337338
let body = match *inst {
@@ -432,7 +433,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
432433

433434
// Generates the code for the `step` method, which processes all states
434435
// in the current queue that consume a single character.
435-
fn step_insts(&self) -> @ast::Expr {
436+
fn step_insts(&self) -> Gc<ast::Expr> {
436437
let arms = self.prog.insts.iter().enumerate().map(|(pc, inst)| {
437438
let nextpc = pc + 1;
438439
let body = match *inst {
@@ -523,7 +524,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
523524
// Translates a character class into a match expression.
524525
// This avoids a binary search (and is hopefully replaced by a jump
525526
// table).
526-
fn match_class(&self, casei: bool, ranges: &[(char, char)]) -> @ast::Expr {
527+
fn match_class(&self, casei: bool, ranges: &[(char, char)]) -> Gc<ast::Expr> {
527528
let expr_true = quote_expr!(self.cx, true);
528529

529530
let mut arms = ranges.iter().map(|&(mut start, mut end)| {
@@ -545,7 +546,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
545546
// Generates code for checking a literal prefix of the search string.
546547
// The code is only generated if the regex *has* a literal prefix.
547548
// Otherwise, a no-op is returned.
548-
fn check_prefix(&self) -> @ast::Expr {
549+
fn check_prefix(&self) -> Gc<ast::Expr> {
549550
if self.prog.prefix.len() == 0 {
550551
self.empty_block()
551552
} else {
@@ -569,28 +570,28 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
569570
// A wild-card arm is automatically added that executes a no-op. It will
570571
// never be used, but is added to satisfy the compiler complaining about
571572
// non-exhaustive patterns.
572-
fn match_insts(&self, mut arms: Vec<ast::Arm>) -> @ast::Expr {
573+
fn match_insts(&self, mut arms: Vec<ast::Arm>) -> Gc<ast::Expr> {
573574
arms.push(self.wild_arm_expr(self.empty_block()));
574575
self.cx.expr_match(self.sp, quote_expr!(self.cx, pc), arms)
575576
}
576577

577-
fn empty_block(&self) -> @ast::Expr {
578+
fn empty_block(&self) -> Gc<ast::Expr> {
578579
quote_expr!(self.cx, {})
579580
}
580581

581582
// Creates a match arm for the instruction at `pc` with the expression
582583
// `body`.
583-
fn arm_inst(&self, pc: uint, body: @ast::Expr) -> ast::Arm {
584+
fn arm_inst(&self, pc: uint, body: Gc<ast::Expr>) -> ast::Arm {
584585
let pc_pat = self.cx.pat_lit(self.sp, quote_expr!(self.cx, $pc));
585586

586587
self.cx.arm(self.sp, vec!(pc_pat), body)
587588
}
588589

589590
// Creates a wild-card match arm with the expression `body`.
590-
fn wild_arm_expr(&self, body: @ast::Expr) -> ast::Arm {
591+
fn wild_arm_expr(&self, body: Gc<ast::Expr>) -> ast::Arm {
591592
ast::Arm {
592593
attrs: vec!(),
593-
pats: vec!(@ast::Pat{
594+
pats: vec!(box(GC) ast::Pat{
594595
id: ast::DUMMY_NODE_ID,
595596
span: self.sp,
596597
node: ast::PatWild,
@@ -603,8 +604,9 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
603604

604605
// Converts `xs` to a `[x1, x2, .., xN]` expression by calling `to_expr`
605606
// on each element in `xs`.
606-
fn vec_expr<T, It: Iterator<T>>(&self, xs: It, to_expr: |&ExtCtxt, T| -> @ast::Expr)
607-
-> @ast::Expr {
607+
fn vec_expr<T, It: Iterator<T>>(&self, xs: It,
608+
to_expr: |&ExtCtxt, T| -> Gc<ast::Expr>)
609+
-> Gc<ast::Expr> {
608610
let exprs = xs.map(|x| to_expr(self.cx, x)).collect();
609611
self.cx.expr_vec(self.sp, exprs)
610612
}

src/librustc/front/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use syntax::fold::Folder;
1212
use syntax::{ast, fold, attr};
1313
use syntax::codemap;
1414

15-
use std::gc::Gc;
15+
use std::gc::{Gc, GC};
1616

1717
struct Context<'a> {
1818
in_cfg: |attrs: &[ast::Attribute]|: 'a -> bool,

src/librustc/front/std_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use syntax::parse::token;
2323
use syntax::util::small_vector::SmallVector;
2424

2525
use std::mem;
26-
use std::gc::Gc;
26+
use std::gc::{Gc, GC};
2727

2828
pub static VERSION: &'static str = "0.11.0-pre";
2929

src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use front::config;
1818
use front::std_inject::with_version;
1919

2020
use std::cell::RefCell;
21-
use std::gc::Gc;
21+
use std::gc::{Gc, GC};
2222
use std::slice;
2323
use std::vec;
2424
use syntax::ast_util::*;

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use libc;
4040
use std::io::Seek;
4141
use std::io::MemWriter;
4242
use std::mem;
43-
use std::string::String;
43+
use std::gc::GC;
4444

4545
use serialize::ebml::reader;
4646
use serialize::ebml;

src/librustc/middle/borrowck/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use util::ppaux::{note_and_explain_region, Repr, UserString};
2323
use std::cell::{Cell};
2424
use std::ops::{BitOr, BitAnd};
2525
use std::rc::Rc;
26+
use std::gc::{Gc, GC};
2627
use std::string::String;
2728
use syntax::ast;
2829
use syntax::ast_map;
@@ -70,7 +71,7 @@ pub fn check_crate(tcx: &ty::ctxt,
7071
krate: &ast::Crate) {
7172
let mut bccx = BorrowckCtxt {
7273
tcx: tcx,
73-
stats: @BorrowStats {
74+
stats: box(GC) BorrowStats {
7475
loaned_paths_same: Cell::new(0),
7576
loaned_paths_imm: Cell::new(0),
7677
stable_paths: Cell::new(0),
@@ -155,7 +156,7 @@ pub struct BorrowckCtxt<'a> {
155156
tcx: &'a ty::ctxt,
156157

157158
// Statistics:
158-
stats: @BorrowStats
159+
stats: Gc<BorrowStats>,
159160
}
160161

161162
pub struct BorrowStats {

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use middle::ty;
1919
use util::ppaux::ty_to_str;
2020

2121
use std::cmp;
22-
use std::gc::Gc;
22+
use std::gc::{Gc, GC};
2323
use std::iter;
2424
use syntax::ast::*;
2525
use syntax::ast_util::{is_unguarded, walk_pat};

src/librustc/middle/check_static.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a> Visitor<bool> for CheckStaticVisitor<'a> {
123123
ast::ExprUnary(ast::UnUniq, _) |
124124
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
125125
self.tcx.sess.span_err(e.span,
126-
"static items are not allowed to have owned pointers");
126+
"static items are not allowed to have custom pointers");
127127
}
128128
_ => {
129129
let node_ty = ty::node_id_to_type(self.tcx, e.id);

src/librustc/middle/kind.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,12 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
245245
check_bounds_on_type_parameters(cx, e);
246246

247247
match e.node {
248-
ExprUnary(UnBox, ref interior) => {
249-
let interior_type = ty::expr_ty(cx.tcx, &**interior);
250-
let _ = check_static(cx.tcx, interior_type, interior.span);
248+
ExprBox(ref loc, ref interior) => {
249+
let def = ty::resolve_expr(cx.tcx, &**loc);
250+
if Some(def.def_id()) == cx.tcx.lang_items.managed_heap() {
251+
let interior_type = ty::expr_ty(cx.tcx, &**interior);
252+
let _ = check_static(cx.tcx, interior_type, interior.span);
253+
}
251254
}
252255
ExprCast(ref source, _) => {
253256
let source_ty = ty::expr_ty(cx.tcx, &**source);

src/librustc/middle/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use syntax::visit::Visitor;
3535

3636
use std::collections::{HashMap, HashSet};
3737
use std::cell::{Cell, RefCell};
38-
use std::gc::Gc;
38+
use std::gc::{Gc, GC};
3939
use std::mem::replace;
4040
use std::rc::{Rc, Weak};
4141
use std::uint;

src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ use util::ppaux::{Repr, vec_map_to_str};
226226
use std::collections::HashMap;
227227
use std::cell::Cell;
228228
use std::rc::Rc;
229-
use std::gc::Gc;
229+
use std::gc::{Gc, GC};
230230
use syntax::ast;
231231
use syntax::ast::Ident;
232232
use syntax::ast_util::path_to_ident;

src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ time of error detection.
6060
*/
6161

6262
use std::collections::HashSet;
63+
use std::gc::GC;
6364
use middle::def;
6465
use middle::subst;
6566
use middle::ty;

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc::middle::ty;
3232

3333
use std::rc::Rc;
3434
use std::u32;
35-
use std::gc::Gc;
35+
use std::gc::{Gc, GC};
3636

3737
use core;
3838
use doctree;

src/librustdoc/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use syntax::parse::token;
1818
use syntax;
1919

2020
use std::cell::RefCell;
21+
use std::gc::GC;
2122
use std::os;
2223
use std::collections::{HashMap, HashSet};
2324

src/librustdoc/test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
use std::cell::RefCell;
1212
use std::char;
13-
use std::io;
13+
use std::dynamic_lib::DynamicLibrary;
14+
use std::gc::GC;
1415
use std::io::{Command, TempDir};
16+
use std::io;
1517
use std::os;
1618
use std::str;
1719
use std::string::String;
18-
use std::dynamic_lib::DynamicLibrary;
1920

2021
use std::collections::{HashSet, HashMap};
2122
use testing;

0 commit comments

Comments
 (0)