Skip to content

Commit 762101b

Browse files
committed
syntax: Fold macros in default methods. Closes #3911
1 parent b90d7d4 commit 762101b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: src/libsyntax/fold.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,15 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
258258
*methods, |x| fld.fold_method(*x))))
259259
}
260260
item_trait(tps, traits, methods) => {
261+
let methods = do methods.map |method| {
262+
match *method {
263+
required(*) => copy *method,
264+
provided(method) => provided(fld.fold_method(method))
265+
}
266+
};
261267
item_trait(fold_ty_params(tps, fld),
262268
vec::map(traits, |p| fold_trait_ref(*p, fld)),
263-
/* FIXME (#2543) */ copy methods)
269+
move methods)
264270
}
265271
item_mac(m) => {
266272
// FIXME #2888: we might actually want to do something here.

Diff for: src/test/run-pass/traits-default-method-macro.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trait Foo {
2+
fn bar() -> ~str {
3+
fmt!("test")
4+
}
5+
}
6+
7+
enum Baz {
8+
Quux
9+
}
10+
11+
impl Baz: Foo {
12+
}
13+
14+
fn main() {
15+
let q = Quux;
16+
assert q.bar() == ~"test";
17+
}

0 commit comments

Comments
 (0)