@@ -45,6 +45,11 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Optio
45
45
let alias = get_type_alias ( & ctx, & alias_instance) ?;
46
46
let concrete_type = alias. ty ( ) ?;
47
47
48
+ enum Replacement {
49
+ Generic { lifetime_map : LifetimeMap , const_and_type_map : ConstAndTypeMap } ,
50
+ Plain ,
51
+ }
52
+
48
53
let replacement = if let Some ( alias_generics) = alias. generic_param_list ( ) {
49
54
if alias_generics. generic_params ( ) . next ( ) . is_none ( ) {
50
55
cov_mark:: hit!( no_generics_params) ;
@@ -54,13 +59,12 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Optio
54
59
let instance_args =
55
60
alias_instance. syntax ( ) . descendants ( ) . find_map ( ast:: GenericArgList :: cast) ;
56
61
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
+ }
62
66
} else {
63
- concrete_type . to_string ( )
67
+ Replacement :: Plain
64
68
} ;
65
69
66
70
let target = alias_instance. syntax ( ) . text_range ( ) ;
@@ -70,7 +74,14 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Optio
70
74
"Inline type alias" ,
71
75
target,
72
76
|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) ;
74
85
} ,
75
86
)
76
87
}
0 commit comments