@@ -228,6 +228,8 @@ pub struct TraitDef<'a> {
228
228
pub generics : LifetimeBounds < ' a > ,
229
229
230
230
pub methods : Vec < MethodDef < ' a > > ,
231
+
232
+ pub associated_types : Vec < ( ast:: Ident , Ty < ' a > ) > ,
231
233
}
232
234
233
235
@@ -387,6 +389,22 @@ impl<'a> TraitDef<'a> {
387
389
methods : Vec < P < ast:: Method > > ) -> P < ast:: Item > {
388
390
let trait_path = self . path . to_path ( cx, self . span , type_ident, generics) ;
389
391
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
+
390
408
let Generics { mut lifetimes, ty_params, mut where_clause } =
391
409
self . generics . to_generics ( cx, self . span , type_ident, generics) ;
392
410
let mut ty_params = ty_params. into_vec ( ) ;
@@ -494,7 +512,11 @@ impl<'a> TraitDef<'a> {
494
512
methods. into_iter ( )
495
513
. map ( |method| {
496
514
ast:: MethodImplItem ( method)
497
- } ) . collect ( ) ) )
515
+ } ) . chain (
516
+ associated_types. map ( |type_| {
517
+ ast:: TypeImplItem ( type_)
518
+ } )
519
+ ) . collect ( ) ) )
498
520
}
499
521
500
522
fn expand_struct_def ( & self ,
0 commit comments