Default impls
diff --git a/src/item.rs b/src/item.rs
index 0066003..5df79bb 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -239,7 +239,7 @@
use mac::parsing::delimited;
use macro_input::{Body, MacroInput};
use macro_input::parsing::macro_input;
- use ty::parsing::{mutability, ty};
+ use ty::parsing::{mutability, path, ty};
named!(pub item -> Item, alt!(
item_extern_crate
@@ -260,7 +260,8 @@
item_union
|
item_trait
- // TODO: DefaultImpl
+ |
+ item_default_impl
// TODO: Impl
|
item_mac
@@ -493,6 +494,23 @@
})
));
+ named!(item_default_impl -> Item, do_parse!(
+ attrs: many0!(outer_attr) >>
+ unsafety: unsafety >>
+ keyword!("impl") >>
+ path: path >>
+ keyword!("for") >>
+ punct!("..") >>
+ punct!("{") >>
+ punct!("}") >>
+ (Item {
+ ident: "".into(),
+ vis: Visibility::Inherited,
+ attrs: attrs,
+ node: ItemKind::DefaultImpl(unsafety, path),
+ })
+ ));
+
named!(trait_item -> TraitItem, alt!(
trait_item_const
|
@@ -728,7 +746,15 @@
tokens.append_all(items);
tokens.append("}");
}
- ItemKind::DefaultImpl(_unsafety, ref _path) => unimplemented!(),
+ ItemKind::DefaultImpl(unsafety, ref path) => {
+ unsafety.to_tokens(tokens);
+ tokens.append("impl");
+ path.to_tokens(tokens);
+ tokens.append("for");
+ tokens.append("..");
+ tokens.append("{");
+ tokens.append("}");
+ }
ItemKind::Impl(_unsafety,
_polarity,
ref _generics,
diff --git a/tests/cases/traits.rs b/tests/cases/traits.rs
index 09ee72c..7f24463 100644
--- a/tests/cases/traits.rs
+++ b/tests/cases/traits.rs
@@ -32,3 +32,5 @@
mac!();
mac!{}
}
+
+impl T::U for .. {}