push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "clone", "Clone"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "clone", "DeepClone"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "cmp", "Eq"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "cmp", "Ord"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "cmp", "TotalEq"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "cmp", "TotalOrd"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new_(~["serialize", "Decodable"], None,
~[~Literal(Path::new_local("__D"))], true),
additional_bounds: ~[],
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "default", "Default"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new_(~["serialize", "Encodable"], None,
~[~Literal(Path::new_local("__E"))], true),
additional_bounds: ~[],
/// The span for the current #[deriving(Foo)] header.
span: Span,
+ attributes: ~[ast::Attribute],
+
/// Path of the trait, including any type parameters
path: Path<'a>,
*/
fn create_derived_impl(&self,
cx: &mut ExtCtxt,
- type_ident: Ident, generics: &Generics,
+ type_ident: Ident,
+ generics: &Generics,
methods: ~[@ast::Method]) -> @ast::Item {
let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
cx.item(
self.span,
ident,
- ~[doc_attr],
+ vec::append(~[doc_attr], self.attributes),
ast::ItemImpl(trait_generics, opt_trait_ref,
self_type, methods.map(|x| *x)))
}
- fn expand_struct_def(&self,
- cx: &mut ExtCtxt,
- struct_def: &StructDef,
- type_ident: Ident,
- generics: &Generics) -> @ast::Item {
+ pub fn expand_struct_def(&self,
+ cx: &mut ExtCtxt,
+ struct_def: &StructDef,
+ type_ident: Ident,
+ generics: &Generics) -> @ast::Item {
let methods = self.methods.map(|method_def| {
let (explicit_self, self_args, nonself_args, tys) =
method_def.split_self_nonself_args(
self.create_derived_impl(cx, type_ident, generics, methods)
}
- fn expand_enum_def(&self,
+ pub fn expand_enum_def(&self,
cx: &mut ExtCtxt,
enum_def: &EnumDef,
type_ident: Ident,
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "to_bytes", "IterBytes"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "num", "FromPrimitive"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "rand", "Rand"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "fmt", "Show"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "to_str", "ToStr"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
push: |@Item|) {
let trait_def = TraitDef {
span: span,
+ attributes: ~[],
path: Path::new(~["std", "num", "Zero"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),