Skip to content

Commit 0738803

Browse files
committed
---
yaml --- r: 40268 b: refs/heads/dist-snap c: 3edccc3 h: refs/heads/master v: v3
1 parent 6340883 commit 0738803

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: 768247f393a18ec56d7a92cded2545e6f7d92649
10+
refs/heads/dist-snap: 3edccc311ef4f29c6bf8676f7a414f8b0ef9360d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libsyntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export noop_fold_pat;
1212
export noop_fold_mod;
1313
export noop_fold_ty;
1414
export noop_fold_block;
15+
export noop_fold_item_underscore;
1516
export wrap;
1617
export fold_ty_param;
1718
export fold_ty_params;

branches/dist-snap/src/rustc/front/config.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
2727
@{fold_mod: |a,b| fold_mod(ctxt, a, b),
2828
fold_block: fold::wrap(|a,b| fold_block(ctxt, a, b) ),
2929
fold_foreign_mod: |a,b| fold_foreign_mod(ctxt, a, b),
30+
fold_item_underscore: |a,b| fold_item_underscore(ctxt, a, b),
3031
.. *fold::default_ast_fold()};
3132

3233
let fold = fold::make_fold(precursor);
@@ -79,6 +80,22 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
7980
};
8081
}
8182

83+
fn fold_item_underscore(cx: ctxt, item: ast::item_, fld: fold::ast_fold) -> ast::item_ {
84+
let item = match item {
85+
ast::item_impl(a, b, c, Some(methods)) => {
86+
let methods = methods.filter(|m| method_in_cfg(cx, *m) );
87+
ast::item_impl(a, b, c, Some(methods))
88+
}
89+
ast::item_trait(a, b, ref methods) => {
90+
let methods = methods.filter(|m| trait_method_in_cfg(cx, m) );
91+
ast::item_trait(a, b, methods)
92+
}
93+
_ => item
94+
};
95+
96+
fold::noop_fold_item_underscore(item, fld)
97+
}
98+
8299
fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) ->
83100
Option<@ast::stmt> {
84101
match stmt.node {
@@ -118,6 +135,17 @@ fn view_item_in_cfg(cx: ctxt, item: @ast::view_item) -> bool {
118135
return cx.in_cfg(item.attrs);
119136
}
120137

138+
fn method_in_cfg(cx: ctxt, meth: @ast::method) -> bool {
139+
return cx.in_cfg(meth.attrs);
140+
}
141+
142+
fn trait_method_in_cfg(cx: ctxt, meth: &ast::trait_method) -> bool {
143+
match *meth {
144+
ast::required(ref meth) => cx.in_cfg(meth.attrs),
145+
ast::provided(@ref meth) => cx.in_cfg(meth.attrs)
146+
}
147+
}
148+
121149
// Determine if an item should be translated in the current crate
122150
// configuration based on the item's attributes
123151
fn in_cfg(cfg: ast::crate_cfg, attrs: ~[ast::attribute]) -> bool {

branches/dist-snap/src/test/run-pass/conditional-compile.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Crate use statements
2+
#[cfg(bogus)]
3+
use flippity;
4+
15
#[cfg(bogus)]
26
const b: bool = false;
37

@@ -115,4 +119,34 @@ mod test_use_statements {
115119
#[cfg(bogus)]
116120
use flippity_foo;
117121
}
118-
}
122+
}
123+
124+
mod test_methods {
125+
struct Foo {
126+
bar: uint
127+
}
128+
129+
impl Foo: Fooable {
130+
#[cfg(bogus)]
131+
static fn what() { }
132+
133+
static fn what() { }
134+
135+
#[cfg(bogus)]
136+
fn the() { }
137+
138+
fn the() { }
139+
}
140+
141+
trait Fooable {
142+
#[cfg(bogus)]
143+
static fn what();
144+
145+
static fn what();
146+
147+
#[cfg(bogus)]
148+
fn the();
149+
150+
fn the();
151+
}
152+
}

0 commit comments

Comments
 (0)