@@ -190,11 +190,12 @@ impl<'a> FragmentCtx<'a> {
190190 self . emit_method_call ( & call) ;
191191 return ;
192192 }
193- if let Some ( generic) = ast :: CallExpr :: cast ( node . clone ( ) )
194- . and_then ( |call| self . generic_default ( & call) )
193+ if let Some ( generic) =
194+ ast :: CallExpr :: cast ( node . clone ( ) ) . and_then ( |call| self . generic_default ( & call) )
195195 {
196196 self . flush_text ( ) ;
197- self . fragments . push ( BodyFragment :: Default { default : generic } ) ;
197+ self . fragments
198+ . push ( BodyFragment :: Default { default : generic } ) ;
198199 return ;
199200 }
200201 for child in node. children_with_tokens ( ) {
@@ -675,8 +676,24 @@ impl<'a> TypeIrBuilder<'a> {
675676 . find ( |name| name. text ( ) == ty_text)
676677 . map ( |name| name. text ( ) [ 1 ..] . parse ( ) . expect ( "generic name is T<n>" ) ) ;
677678
679+ let generic_names: Vec < String > = self
680+ . fn_item
681+ . generic_param_list ( )
682+ . into_iter ( )
683+ . flat_map ( |gpl| gpl. generic_params ( ) )
684+ . filter_map ( |param| match param {
685+ ast:: GenericParam :: TypeParam ( tp) => tp. name ( ) ,
686+ ast:: GenericParam :: ConstParam ( cp) => cp. name ( ) ,
687+ _ => None ,
688+ } )
689+ . map ( |name| name. text ( ) . to_string ( ) )
690+ . collect ( ) ;
691+ let builder = FnIrBuilder :: new ( self . fn_item ) ;
692+ let mut init_ctx = FragmentCtx :: new ( & builder, & [ ] , & generic_names) ;
693+ init_ctx. visit ( ra_ap_syntax:: NodeOrToken :: Node ( init. syntax ( ) . clone ( ) ) ) ;
694+
678695 TypeIr {
679- init : init . syntax ( ) . text ( ) . to_string ( ) ,
696+ init : init_ctx . finish ( ) ,
680697 generic,
681698 type_info : TypeInfo {
682699 ty : ty. syntax ( ) . text ( ) . to_string ( ) ,
0 commit comments