Skip to content

Commit 4710e9a

Browse files
committed
---
yaml --- r: 145378 b: refs/heads/try2 c: 3399353 h: refs/heads/master v: v3
1 parent cda7413 commit 4710e9a

File tree

5 files changed

+60
-63
lines changed

5 files changed

+60
-63
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: 3e5de06135fa9a857931191101d61a4abe149c96
8+
refs/heads/try2: 33993535efb490ddb0e3afb6e08e4f945ec28a04
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
// except according to those terms.
1010

1111

12-
use std::option;
1312
use syntax::fold::ast_fold;
1413
use syntax::{ast, fold, attr};
1514

16-
type in_cfg_pred = @fn(attrs: &[ast::Attribute]) -> bool;
17-
18-
struct Context {
19-
in_cfg: in_cfg_pred
15+
struct Context<'self> {
16+
in_cfg: &'self fn(attrs: &[ast::Attribute]) -> bool,
2017
}
2118

2219
// Support conditional compilation by transforming the AST, stripping out
@@ -27,56 +24,55 @@ pub fn strip_unconfigured_items(crate: @ast::Crate) -> @ast::Crate {
2724
}
2825
}
2926

30-
struct ItemRemover {
31-
ctxt: @Context,
32-
}
33-
34-
impl fold::ast_fold for ItemRemover {
27+
impl<'self> fold::ast_fold for Context<'self> {
3528
fn fold_mod(&self, module: &ast::_mod) -> ast::_mod {
36-
fold_mod(self.ctxt, module, self)
29+
fold_mod(self, module)
3730
}
3831
fn fold_block(&self, block: &ast::Block) -> ast::Block {
39-
fold_block(self.ctxt, block, self)
32+
fold_block(self, block)
4033
}
4134
fn fold_foreign_mod(&self, foreign_module: &ast::foreign_mod)
4235
-> ast::foreign_mod {
43-
fold_foreign_mod(self.ctxt, foreign_module, self)
36+
fold_foreign_mod(self, foreign_module)
4437
}
4538
fn fold_item_underscore(&self, item: &ast::item_) -> ast::item_ {
46-
fold_item_underscore(self.ctxt, item, self)
39+
fold_item_underscore(self, item)
4740
}
4841
}
4942

50-
pub fn strip_items(crate: &ast::Crate, in_cfg: in_cfg_pred) -> @ast::Crate {
51-
let ctxt = @Context {
43+
pub fn strip_items(crate: &ast::Crate,
44+
in_cfg: &fn(attrs: &[ast::Attribute]) -> bool)
45+
-> @ast::Crate {
46+
let ctxt = Context {
5247
in_cfg: in_cfg,
5348
};
54-
let precursor = ItemRemover {
55-
ctxt: ctxt,
56-
};
57-
@precursor.fold_crate(crate)
49+
@ctxt.fold_crate(crate)
5850
}
5951

60-
fn filter_item(cx: @Context, item: @ast::item) ->
61-
Option<@ast::item> {
62-
if item_in_cfg(cx, item) { option::Some(item) } else { option::None }
52+
fn filter_item(cx: &Context, item: @ast::item) -> Option<@ast::item> {
53+
if item_in_cfg(cx, item) {
54+
Some(item)
55+
} else {
56+
None
57+
}
6358
}
6459

65-
fn filter_view_item<'r>(cx: @Context, view_item: &'r ast::view_item)-> Option<&'r ast::view_item> {
60+
fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item)
61+
-> Option<&'r ast::view_item> {
6662
if view_item_in_cfg(cx, view_item) {
67-
option::Some(view_item)
63+
Some(view_item)
6864
} else {
69-
option::None
65+
None
7066
}
7167
}
7268

73-
fn fold_mod(cx: @Context, m: &ast::_mod, fld: &ItemRemover) -> ast::_mod {
74-
let filtered_items = do m.items.iter().filter_map |a| {
75-
filter_item(cx, *a).and_then(|x| fld.fold_item(x))
69+
fn fold_mod(cx: &Context, m: &ast::_mod) -> ast::_mod {
70+
let filtered_items = do m.items.iter().filter_map |a| {
71+
filter_item(cx, *a).and_then(|x| cx.fold_item(x))
7672
}.collect();
7773
let filtered_view_items = do m.view_items.iter().filter_map |a| {
7874
do filter_view_item(cx, a).map_move |x| {
79-
fld.fold_view_item(x)
75+
cx.fold_view_item(x)
8076
}
8177
}.collect();
8278
ast::_mod {
@@ -85,22 +81,23 @@ fn fold_mod(cx: @Context, m: &ast::_mod, fld: &ItemRemover) -> ast::_mod {
8581
}
8682
}
8783

88-
fn filter_foreign_item(cx: @Context, item: @ast::foreign_item) ->
89-
Option<@ast::foreign_item> {
84+
fn filter_foreign_item(cx: &Context, item: @ast::foreign_item)
85+
-> Option<@ast::foreign_item> {
9086
if foreign_item_in_cfg(cx, item) {
91-
option::Some(item)
92-
} else { option::None }
87+
Some(item)
88+
} else {
89+
None
90+
}
9391
}
9492

95-
fn fold_foreign_mod(cx: @Context, nm: &ast::foreign_mod, fld: &ItemRemover)
96-
-> ast::foreign_mod {
93+
fn fold_foreign_mod(cx: &Context, nm: &ast::foreign_mod) -> ast::foreign_mod {
9794
let filtered_items = nm.items
9895
.iter()
9996
.filter_map(|a| filter_foreign_item(cx, *a))
10097
.collect();
10198
let filtered_view_items = do nm.view_items.iter().filter_map |a| {
10299
do filter_view_item(cx, a).map_move |x| {
103-
fld.fold_view_item(x)
100+
cx.fold_view_item(x)
104101
}
105102
}.collect();
106103
ast::foreign_mod {
@@ -111,76 +108,78 @@ fn fold_foreign_mod(cx: @Context, nm: &ast::foreign_mod, fld: &ItemRemover)
111108
}
112109
}
113110

114-
fn fold_item_underscore(cx: @Context, item: &ast::item_, fld: &ItemRemover)
115-
-> ast::item_ {
111+
fn fold_item_underscore(cx: &Context, item: &ast::item_) -> ast::item_ {
116112
let item = match *item {
117113
ast::item_impl(ref a, ref b, ref c, ref methods) => {
118114
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
119115
.map(|x| *x).collect();
120116
ast::item_impl((*a).clone(), (*b).clone(), (*c).clone(), methods)
121117
}
122118
ast::item_trait(ref a, ref b, ref methods) => {
123-
let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) )
124-
.map(|x| (*x).clone()).collect();
119+
let methods = methods.iter()
120+
.filter(|m| trait_method_in_cfg(cx, *m) )
121+
.map(|x| (*x).clone())
122+
.collect();
125123
ast::item_trait((*a).clone(), (*b).clone(), methods)
126124
}
127125
ref item => (*item).clone(),
128126
};
129127

130-
fold::noop_fold_item_underscore(&item, fld)
128+
fold::noop_fold_item_underscore(&item, cx)
131129
}
132130

133-
fn filter_stmt(cx: @Context, stmt: @ast::Stmt) ->
134-
Option<@ast::Stmt> {
131+
fn filter_stmt(cx: &Context, stmt: @ast::Stmt) -> Option<@ast::Stmt> {
135132
match stmt.node {
136133
ast::StmtDecl(decl, _) => {
137134
match decl.node {
138135
ast::DeclItem(item) => {
139136
if item_in_cfg(cx, item) {
140-
option::Some(stmt)
141-
} else { option::None }
137+
Some(stmt)
138+
} else {
139+
None
140+
}
142141
}
143-
_ => option::Some(stmt)
142+
_ => Some(stmt)
144143
}
145144
}
146-
_ => option::Some(stmt)
145+
_ => Some(stmt),
147146
}
148147
}
149148

150-
fn fold_block(cx: @Context, b: &ast::Block, fld: &ItemRemover) -> ast::Block {
149+
fn fold_block(cx: &Context, b: &ast::Block) -> ast::Block {
151150
let resulting_stmts = do b.stmts.iter().filter_map |a| {
152-
filter_stmt(cx, *a).and_then(|stmt| fld.fold_stmt(stmt))
151+
filter_stmt(cx, *a).and_then(|stmt| cx.fold_stmt(stmt))
153152
}.collect();
154153
let filtered_view_items = do b.view_items.iter().filter_map |a| {
155-
filter_view_item(cx, a).map(|x| fld.fold_view_item(*x))
154+
filter_view_item(cx, a).map(|x| cx.fold_view_item(*x))
156155
}.collect();
157156
ast::Block {
158157
view_items: filtered_view_items,
159158
stmts: resulting_stmts,
160-
expr: b.expr.map(|x| fld.fold_expr(*x)),
159+
expr: b.expr.map(|x| cx.fold_expr(*x)),
161160
id: b.id,
162161
rules: b.rules,
163162
span: b.span,
164163
}
165164
}
166165

167-
fn item_in_cfg(cx: @Context, item: @ast::item) -> bool {
166+
fn item_in_cfg(cx: &Context, item: @ast::item) -> bool {
168167
return (cx.in_cfg)(item.attrs);
169168
}
170169

171-
fn foreign_item_in_cfg(cx: @Context, item: @ast::foreign_item) -> bool {
170+
fn foreign_item_in_cfg(cx: &Context, item: @ast::foreign_item) -> bool {
172171
return (cx.in_cfg)(item.attrs);
173172
}
174173

175-
fn view_item_in_cfg(cx: @Context, item: &ast::view_item) -> bool {
174+
fn view_item_in_cfg(cx: &Context, item: &ast::view_item) -> bool {
176175
return (cx.in_cfg)(item.attrs);
177176
}
178177

179-
fn method_in_cfg(cx: @Context, meth: @ast::method) -> bool {
178+
fn method_in_cfg(cx: &Context, meth: @ast::method) -> bool {
180179
return (cx.in_cfg)(meth.attrs);
181180
}
182181

183-
fn trait_method_in_cfg(cx: @Context, meth: &ast::trait_method) -> bool {
182+
fn trait_method_in_cfg(cx: &Context, meth: &ast::trait_method) -> bool {
184183
match *meth {
185184
ast::required(ref meth) => (cx.in_cfg)(meth.attrs),
186185
ast::provided(@ref meth) => (cx.in_cfg)(meth.attrs)
@@ -192,3 +191,4 @@ fn trait_method_in_cfg(cx: @Context, meth: &ast::trait_method) -> bool {
192191
fn in_cfg(cfg: &[@ast::MetaItem], attrs: &[ast::Attribute]) -> bool {
193192
attr::test_cfg(cfg, attrs.iter().map(|x| *x))
194193
}
194+

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ use syntax::opt_vec;
2727
use syntax::print::pprust;
2828
use syntax::{ast, ast_util};
2929

30-
type node_id_gen = @fn() -> ast::NodeId;
31-
3230
struct Test {
3331
span: Span,
3432
path: ~[ast::Ident],

branches/try2/src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
9595
return parse_ident_(st, |a| is_last(last, a) );
9696
}
9797

98-
fn parse_ident_(st: &mut PState, is_last: @fn(char) -> bool) ->
99-
ast::Ident {
98+
fn parse_ident_(st: &mut PState, is_last: &fn(char) -> bool) -> ast::Ident {
10099
let rslt = scan(st, is_last, str::from_utf8);
101100
return st.tcx.sess.ident_of(rslt);
102101
}

branches/try2/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use syntax::print::pprust::*;
2626
pub struct ctxt {
2727
diag: @mut span_handler,
2828
// Def -> str Callback:
29-
ds: @fn(DefId) -> ~str,
29+
ds: extern "Rust" fn(DefId) -> ~str,
3030
// The type context.
3131
tcx: ty::ctxt,
3232
abbrevs: abbrev_ctxt

0 commit comments

Comments
 (0)