@@ -228,6 +228,8 @@ pub struct TraitDef<'a> {
228228 pub generics : LifetimeBounds < ' a > ,
229229
230230 pub methods : Vec < MethodDef < ' a > > ,
231+
232+ pub associated_types : Vec < ( ast:: Ident , Ty < ' a > ) > ,
231233}
232234
233235
@@ -387,6 +389,22 @@ impl<'a> TraitDef<'a> {
387389 methods : Vec < P < ast:: Method > > ) -> P < ast:: Item > {
388390 let trait_path = self . path . to_path ( cx, self . span , type_ident, generics) ;
389391
392+ // Transform associated types from `deriving::ty::Ty` into `ast::Typedef`
393+ let associated_types = self . associated_types . iter ( ) . map ( |& ( ident, ref type_def) | {
394+ P ( ast:: Typedef {
395+ id : ast:: DUMMY_NODE_ID ,
396+ span : self . span ,
397+ ident : ident,
398+ vis : ast:: Inherited ,
399+ attrs : Vec :: new ( ) ,
400+ typ : type_def. to_ty ( cx,
401+ self . span ,
402+ type_ident,
403+ generics
404+ ) ,
405+ } )
406+ } ) ;
407+
390408 let Generics { mut lifetimes, ty_params, mut where_clause } =
391409 self . generics . to_generics ( cx, self . span , type_ident, generics) ;
392410 let mut ty_params = ty_params. into_vec ( ) ;
@@ -494,7 +512,11 @@ impl<'a> TraitDef<'a> {
494512 methods. into_iter ( )
495513 . map ( |method| {
496514 ast:: MethodImplItem ( method)
497- } ) . collect ( ) ) )
515+ } ) . chain (
516+ associated_types. map ( |type_| {
517+ ast:: TypeImplItem ( type_)
518+ } )
519+ ) . collect ( ) ) )
498520 }
499521
500522 fn expand_struct_def ( & self ,
0 commit comments