syntax: Fold macros in default methods. Closes #3911

This commit is contained in:
Brian Anderson 2012-11-02 23:11:36 -07:00
parent b90d7d4c81
commit 762101b72a
2 changed files with 24 additions and 1 deletions

View File

@ -258,9 +258,15 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
*methods, |x| fld.fold_method(*x))))
}
item_trait(tps, traits, methods) => {
let methods = do methods.map |method| {
match *method {
required(*) => copy *method,
provided(method) => provided(fld.fold_method(method))
}
};
item_trait(fold_ty_params(tps, fld),
vec::map(traits, |p| fold_trait_ref(*p, fld)),
/* FIXME (#2543) */ copy methods)
move methods)
}
item_mac(m) => {
// FIXME #2888: we might actually want to do something here.

View File

@ -0,0 +1,17 @@
trait Foo {
fn bar() -> ~str {
fmt!("test")
}
}
enum Baz {
Quux
}
impl Baz: Foo {
}
fn main() {
let q = Quux;
assert q.bar() == ~"test";
}