@@ -45,6 +45,11 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Optio
4545 let alias = get_type_alias ( & ctx, & alias_instance) ?;
4646 let concrete_type = alias. ty ( ) ?;
4747
48+ enum Replacement {
49+ Generic { lifetime_map : LifetimeMap , const_and_type_map : ConstAndTypeMap } ,
50+ Plain ,
51+ }
52+
4853 let replacement = if let Some ( alias_generics) = alias. generic_param_list ( ) {
4954 if alias_generics. generic_params ( ) . next ( ) . is_none ( ) {
5055 cov_mark:: hit!( no_generics_params) ;
@@ -54,13 +59,12 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Optio
5459 let instance_args =
5560 alias_instance. syntax ( ) . descendants ( ) . find_map ( ast:: GenericArgList :: cast) ;
5661
57- create_replacement (
58- & LifetimeMap :: new ( & instance_args, & alias_generics) ?,
59- & ConstAndTypeMap :: new ( & instance_args, & alias_generics) ?,
60- & concrete_type,
61- )
62+ Replacement :: Generic {
63+ lifetime_map : LifetimeMap :: new ( & instance_args, & alias_generics) ?,
64+ const_and_type_map : ConstAndTypeMap :: new ( & instance_args, & alias_generics) ?,
65+ }
6266 } else {
63- concrete_type . to_string ( )
67+ Replacement :: Plain
6468 } ;
6569
6670 let target = alias_instance. syntax ( ) . text_range ( ) ;
@@ -70,7 +74,14 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Optio
7074 "Inline type alias" ,
7175 target,
7276 |builder| {
73- builder. replace ( target, replacement) ;
77+ let replacement_text = match replacement {
78+ Replacement :: Generic { lifetime_map, const_and_type_map } => {
79+ create_replacement ( & lifetime_map, & const_and_type_map, & concrete_type)
80+ }
81+ Replacement :: Plain => concrete_type. to_string ( ) ,
82+ } ;
83+
84+ builder. replace ( target, replacement_text) ;
7485 } ,
7586 )
7687}
0 commit comments