Skip to content

Commit cfd4eb7

Browse files
committed
---
yaml --- r: 152451 b: refs/heads/try2 c: 54c2a1e h: refs/heads/master i: 152449: 610b6d8 152447: 0489d45 v: v3
1 parent f656a4c commit cfd4eb7

Some content is hidden

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

79 files changed

+1406
-1349
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 53ad426e92f8099a701f3f54c02dc8f069f5939a
8+
refs/heads/try2: 54c2a1e1ce7f32576f0692a1de3fe2763d13bac9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,14 +1710,14 @@ having ownership of the box. It allows the creation of cycles, and the individua
17101710
not have a destructor.
17111711

17121712
~~~
1713-
use std::gc::Gc;
1713+
use std::gc::GC;
17141714
17151715
// A fixed-size array allocated in a garbage-collected box
1716-
let x = Gc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1716+
let x = box(GC) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
17171717
let y = x; // does not perform a move, unlike with `Rc`
17181718
let z = x;
17191719
1720-
assert!(*z.borrow() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1720+
assert!(*z == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
17211721
~~~
17221722

17231723
With shared ownership, mutability cannot be inherited so the boxes are always immutable. However,

branches/try2/src/liballoc/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ mod tests {
320320
#[test]
321321
fn gc_inside() {
322322
// see issue #11532
323-
use realstd::gc::Gc;
323+
use std::gc::GC;
324324
let a = Rc::new(RefCell::new(box(GC) 1));
325325
assert!(a.try_borrow_mut().is_some());
326326
}

branches/try2/src/libcore/clone.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ extern_fn_clone!(A, B, C, D, E, F, G, H)
110110
mod test {
111111
use prelude::*;
112112
use realstd::owned::Box;
113+
use realstd::gc::{Gc, GC};
113114

114115
fn realclone<T: ::realstd::clone::Clone>(t: &T) -> T {
115116
use realstd::clone::Clone;
@@ -130,9 +131,9 @@ mod test {
130131

131132
#[test]
132133
fn test_managed_clone() {
133-
let a = @5i;
134-
let b: @int = a.clone();
135-
assert_eq!(a, b);
134+
let a = box(GC) 5i;
135+
let b: Gc<int> = realclone(&a);
136+
assert!(a == b);
136137
}
137138

138139
#[test]

branches/try2/src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fn print_flowgraph<W:io::Writer>(analysis: CrateAnalysis,
705705
block: ast::P<ast::Block>,
706706
mut out: W) -> io::IoResult<()> {
707707
let ty_cx = &analysis.ty_cx;
708-
let cfg = cfg::CFG::new(ty_cx, block);
708+
let cfg = cfg::CFG::new(ty_cx, &*block);
709709
let lcfg = LabelledCFG { ast_map: &ty_cx.map,
710710
cfg: &cfg,
711711
name: format!("block{}", block.id).to_string(), };

branches/try2/src/librustc/front/config.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use syntax::fold::Folder;
1212
use syntax::{ast, fold, attr};
1313
use syntax::codemap;
1414

15+
use std::gc::Gc;
16+
1517
struct Context<'a> {
1618
in_cfg: |attrs: &[ast::Attribute]|: 'a -> bool,
1719
}
@@ -36,7 +38,7 @@ impl<'a> fold::Folder for Context<'a> {
3638
fn fold_item_underscore(&mut self, item: &ast::Item_) -> ast::Item_ {
3739
fold_item_underscore(self, item)
3840
}
39-
fn fold_expr(&mut self, expr: @ast::Expr) -> @ast::Expr {
41+
fn fold_expr(&mut self, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
4042
fold_expr(self, expr)
4143
}
4244
}
@@ -60,8 +62,8 @@ fn filter_view_item<'r>(cx: &mut Context, view_item: &'r ast::ViewItem)
6062
}
6163

6264
fn fold_mod(cx: &mut Context, m: &ast::Mod) -> ast::Mod {
63-
let filtered_items: Vec<&@ast::Item> = m.items.iter()
64-
.filter(|&a| item_in_cfg(cx, *a))
65+
let filtered_items: Vec<&Gc<ast::Item>> = m.items.iter()
66+
.filter(|a| item_in_cfg(cx, &***a))
6567
.collect();
6668
let flattened_items = filtered_items.move_iter()
6769
.flat_map(|&x| cx.fold_item(x).move_iter())
@@ -76,9 +78,9 @@ fn fold_mod(cx: &mut Context, m: &ast::Mod) -> ast::Mod {
7678
}
7779
}
7880

79-
fn filter_foreign_item(cx: &mut Context, item: @ast::ForeignItem)
80-
-> Option<@ast::ForeignItem> {
81-
if foreign_item_in_cfg(cx, item) {
81+
fn filter_foreign_item(cx: &mut Context, item: Gc<ast::ForeignItem>)
82+
-> Option<Gc<ast::ForeignItem>> {
83+
if foreign_item_in_cfg(cx, &*item) {
8284
Some(item)
8385
} else {
8486
None
@@ -103,7 +105,7 @@ fn fold_foreign_mod(cx: &mut Context, nm: &ast::ForeignMod) -> ast::ForeignMod {
103105
fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
104106
let item = match *item {
105107
ast::ItemImpl(ref a, ref b, c, ref methods) => {
106-
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
108+
let methods = methods.iter().filter(|m| method_in_cfg(cx, &***m))
107109
.map(|x| *x).collect();
108110
ast::ItemImpl((*a).clone(), (*b).clone(), c, methods)
109111
}
@@ -114,8 +116,8 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
114116
.collect();
115117
ast::ItemTrait((*a).clone(), b, (*c).clone(), methods)
116118
}
117-
ast::ItemStruct(def, ref generics) => {
118-
ast::ItemStruct(fold_struct(cx, def), generics.clone())
119+
ast::ItemStruct(ref def, ref generics) => {
120+
ast::ItemStruct(fold_struct(cx, &**def), generics.clone())
119121
}
120122
ast::ItemEnum(ref def, ref generics) => {
121123
let mut variants = def.variants.iter().map(|c| c.clone()).
@@ -125,11 +127,11 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
125127
} else {
126128
Some(match v.node.kind {
127129
ast::TupleVariantKind(..) => v,
128-
ast::StructVariantKind(def) => {
129-
let def = fold_struct(cx, def);
130-
@codemap::Spanned {
130+
ast::StructVariantKind(ref def) => {
131+
let def = fold_struct(cx, &**def);
132+
box(GC) codemap::Spanned {
131133
node: ast::Variant_ {
132-
kind: ast::StructVariantKind(def),
134+
kind: ast::StructVariantKind(def.clone()),
133135
..v.node.clone()
134136
},
135137
..*v
@@ -148,24 +150,24 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
148150
fold::noop_fold_item_underscore(&item, cx)
149151
}
150152

151-
fn fold_struct(cx: &mut Context, def: &ast::StructDef) -> @ast::StructDef {
153+
fn fold_struct(cx: &mut Context, def: &ast::StructDef) -> Gc<ast::StructDef> {
152154
let mut fields = def.fields.iter().map(|c| c.clone()).filter(|m| {
153155
(cx.in_cfg)(m.node.attrs.as_slice())
154156
});
155-
@ast::StructDef {
157+
box(GC) ast::StructDef {
156158
fields: fields.collect(),
157159
ctor_id: def.ctor_id,
158160
super_struct: def.super_struct.clone(),
159161
is_virtual: def.is_virtual,
160162
}
161163
}
162164

163-
fn retain_stmt(cx: &mut Context, stmt: @ast::Stmt) -> bool {
165+
fn retain_stmt(cx: &mut Context, stmt: Gc<ast::Stmt>) -> bool {
164166
match stmt.node {
165167
ast::StmtDecl(decl, _) => {
166168
match decl.node {
167-
ast::DeclItem(item) => {
168-
item_in_cfg(cx, item)
169+
ast::DeclItem(ref item) => {
170+
item_in_cfg(cx, &**item)
169171
}
170172
_ => true
171173
}
@@ -175,10 +177,10 @@ fn retain_stmt(cx: &mut Context, stmt: @ast::Stmt) -> bool {
175177
}
176178

177179
fn fold_block(cx: &mut Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
178-
let resulting_stmts: Vec<&@ast::Stmt> =
180+
let resulting_stmts: Vec<&Gc<ast::Stmt>> =
179181
b.stmts.iter().filter(|&a| retain_stmt(cx, *a)).collect();
180182
let resulting_stmts = resulting_stmts.move_iter()
181-
.flat_map(|&stmt| cx.fold_stmt(stmt).move_iter())
183+
.flat_map(|stmt| cx.fold_stmt(&**stmt).move_iter())
182184
.collect();
183185
let filtered_view_items = b.view_items.iter().filter_map(|a| {
184186
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
@@ -193,14 +195,14 @@ fn fold_block(cx: &mut Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
193195
})
194196
}
195197

196-
fn fold_expr(cx: &mut Context, expr: @ast::Expr) -> @ast::Expr {
198+
fn fold_expr(cx: &mut Context, expr: Gc<ast::Expr>) -> Gc<ast::Expr> {
197199
let expr = match expr.node {
198200
ast::ExprMatch(ref m, ref arms) => {
199201
let arms = arms.iter()
200202
.filter(|a| (cx.in_cfg)(a.attrs.as_slice()))
201203
.map(|a| a.clone())
202204
.collect();
203-
@ast::Expr {
205+
box(GC) ast::Expr {
204206
id: expr.id,
205207
span: expr.span.clone(),
206208
node: ast::ExprMatch(m.clone(), arms),
@@ -236,7 +238,7 @@ fn trait_method_in_cfg(cx: &mut Context, meth: &ast::TraitMethod) -> bool {
236238

237239
// Determine if an item should be translated in the current crate
238240
// configuration based on the item's attributes
239-
fn in_cfg(cfg: &[@ast::MetaItem], attrs: &[ast::Attribute]) -> bool {
241+
fn in_cfg(cfg: &[Gc<ast::MetaItem>], attrs: &[ast::Attribute]) -> bool {
240242
attr::test_cfg(cfg, attrs.iter().map(|x| *x))
241243
}
242244

branches/try2/src/librustc/front/std_inject.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use syntax::parse::token;
2323
use syntax::util::small_vector::SmallVector;
2424

2525
use std::mem;
26+
use std::gc::Gc;
2627

2728
pub static VERSION: &'static str = "0.11.0-pre";
2829

@@ -165,12 +166,12 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
165166
krate
166167
}
167168

168-
fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> {
169+
fn fold_item(&mut self, item: Gc<ast::Item>) -> SmallVector<Gc<ast::Item>> {
169170
if !no_prelude(item.attrs.as_slice()) {
170171
// only recur if there wasn't `#![no_implicit_prelude]`
171172
// on this item, i.e. this means that the prelude is not
172173
// implicitly imported though the whole subtree
173-
fold::noop_fold_item(item, self)
174+
fold::noop_fold_item(&*item, self)
174175
} else {
175176
SmallVector::one(item)
176177
}
@@ -193,7 +194,8 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
193194
}),
194195
};
195196

196-
let vp = @codemap::dummy_spanned(ast::ViewPathGlob(prelude_path, ast::DUMMY_NODE_ID));
197+
let vp = box(GC) codemap::dummy_spanned(ast::ViewPathGlob(prelude_path,
198+
ast::DUMMY_NODE_ID));
197199
let vi2 = ast::ViewItem {
198200
node: ast::ViewItemUse(vp),
199201
attrs: Vec::new(),

0 commit comments

Comments
 (0)