@@ -77,17 +77,17 @@ pub(crate) fn suggest_to_remove_or_use_generic(
7777 return ;
7878 } ;
7979
80- // Get the Struct/ ADT definition ID from the self type
81- let struct_def_id = if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = hir_impl. self_ty . kind
80+ // Get the ADT definition ID from the self type.
81+ let adt_def_id = if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = hir_impl. self_ty . kind
8282 && let Res :: Def ( DefKind :: Struct | DefKind :: Enum | DefKind :: Union , def_id) = path. res
8383 {
8484 def_id
8585 } else {
8686 return ;
8787 } ;
8888
89- // Count how many generic parameters are defined in the struct definition
90- let generics = tcx. generics_of ( struct_def_id ) ;
89+ // Count how many generic parameters are defined in the ADT definition.
90+ let generics = tcx. generics_of ( adt_def_id ) ;
9191 let total_params = generics
9292 . own_params
9393 . iter ( )
@@ -136,14 +136,15 @@ pub(crate) fn suggest_to_remove_or_use_generic(
136136 suggestions. push ( ( hir_impl. generics . span_for_param_removal ( index) , String :: new ( ) ) ) ;
137137 }
138138
139- // Option B: Suggest adding only if there's an available parameter in the struct definition
140- // or the parameter is already used somewhere, then we suggest adding to the impl struct and the struct definition
139+ // Option B: Suggest adding only if there's an available parameter in the ADT definition
140+ // or the parameter is already used somewhere, then we suggest adding to the impl self type
141+ // and the ADT definition.
141142 if provided_params < total_params || is_param_used {
142143 if let Some ( args) = last_segment_args {
143- // Struct already has <...>, append to it
144+ // Self type already has <...>, append to it.
144145 suggestions. push ( ( args. span ( ) . unwrap ( ) . shrink_to_hi ( ) , format ! ( ", {}" , param. name) ) ) ;
145146 } else if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = hir_impl. self_ty . kind {
146- // Struct has no <...> yet, add it
147+ // Self type has no <...> yet, add it.
147148 let seg = path. segments . last ( ) . unwrap ( ) ;
148149 suggestions. push ( ( seg. ident . span . shrink_to_hi ( ) , format ! ( "<{}>" , param. name) ) ) ;
149150 }
@@ -158,7 +159,7 @@ pub(crate) fn suggest_to_remove_or_use_generic(
158159 if let Some ( last_param_span) = last_param_span {
159160 suggestions. push ( ( last_param_span. shrink_to_hi ( ) , format ! ( ", {}" , param. name) ) ) ;
160161 } else {
161- suggestions. push ( ( struct_span . shrink_to_hi ( ) , format ! ( "<{}>" , param. name) ) ) ;
162+ suggestions. push ( ( adt_span . shrink_to_hi ( ) , format ! ( "<{}>" , param. name) ) ) ;
162163 }
163164 }
164165 }
@@ -173,7 +174,7 @@ pub(crate) fn suggest_to_remove_or_use_generic(
173174 "use the {} parameter `{}` in the `{}` type and use it in the type definition" ,
174175 parameter_type,
175176 param. name,
176- tcx. def_path_str( struct_def_id )
177+ tcx. def_path_str( adt_def_id )
177178 ) ;
178179 diag. multipart_suggestion (
179180 msg,
0 commit comments