@@ -109,7 +109,7 @@ impl<'a> Ctx<'a> {
109109 ast:: Item :: Static ( ast) => self . lower_static ( ast) ?. into ( ) ,
110110 ast:: Item :: Const ( ast) => self . lower_const ( ast) . into ( ) ,
111111 ast:: Item :: Module ( ast) => self . lower_module ( ast) ?. into ( ) ,
112- ast:: Item :: Trait ( ast) => self . lower_trait ( ast) ?. into ( ) ,
112+ ast:: Item :: Trait ( ast) => self . lower_trait ( ast) ?,
113113 ast:: Item :: Impl ( ast) => self . lower_impl ( ast) ?. into ( ) ,
114114 ast:: Item :: Use ( ast) => self . lower_use ( ast) ?. into ( ) ,
115115 ast:: Item :: ExternCrate ( ast) => self . lower_extern_crate ( ast) ?. into ( ) ,
@@ -439,26 +439,39 @@ impl<'a> Ctx<'a> {
439439 Some ( id ( self . data ( ) . mods . alloc ( res) ) )
440440 }
441441
442- fn lower_trait ( & mut self , trait_def : & ast:: Trait ) -> Option < FileItemTreeId < Trait > > {
442+ fn lower_trait ( & mut self , trait_def : & ast:: Trait ) -> Option < ModItem > {
443443 let name = trait_def. name ( ) ?. as_name ( ) ;
444444 let visibility = self . lower_visibility ( trait_def) ;
445445 let generic_params = self . lower_generic_params ( GenericsOwner :: Trait ( trait_def) , trait_def) ;
446446 let is_auto = trait_def. auto_token ( ) . is_some ( ) ;
447447 let is_unsafe = trait_def. unsafe_token ( ) . is_some ( ) ;
448- let items = trait_def. assoc_item_list ( ) . map ( |list| {
449- list. assoc_items ( )
448+ let ast_id = self . source_ast_id_map . ast_id ( trait_def) ;
449+
450+ let item = if trait_def. eq_token ( ) . is_some ( ) {
451+ // trait aliases
452+ let bounds = self . lower_type_bounds ( trait_def) . into_boxed_slice ( ) ;
453+ let alias = TraitAlias { name, visibility, generic_params, bounds, ast_id } ;
454+ id ( self . data ( ) . trait_aliases . alloc ( alias) ) . into ( )
455+ } else {
456+ // trait definition
457+ let items = trait_def
458+ . assoc_item_list ( )
459+ . into_iter ( )
460+ . flat_map ( |list| list. assoc_items ( ) )
450461 . filter_map ( |item| {
451462 let attrs = RawAttrs :: new ( self . db . upcast ( ) , & item, self . hygiene ( ) ) ;
452463 self . lower_assoc_item ( & item) . map ( |item| {
453464 self . add_attrs ( ModItem :: from ( item) . into ( ) , attrs) ;
454465 item
455466 } )
456467 } )
457- . collect ( )
458- } ) ;
459- let ast_id = self . source_ast_id_map . ast_id ( trait_def) ;
460- let res = Trait { name, visibility, generic_params, is_auto, is_unsafe, items, ast_id } ;
461- Some ( id ( self . data ( ) . traits . alloc ( res) ) )
468+ . collect ( ) ;
469+
470+ let def = Trait { name, visibility, generic_params, is_auto, is_unsafe, items, ast_id } ;
471+ id ( self . data ( ) . traits . alloc ( def) ) . into ( )
472+ } ;
473+
474+ Some ( item)
462475 }
463476
464477 fn lower_impl ( & mut self , impl_def : & ast:: Impl ) -> Option < FileItemTreeId < Impl > > {
0 commit comments