@@ -137,20 +137,18 @@ impl Field {
137
137
138
138
if let Some ( tp) = type_param {
139
139
for tb in tp. trait_bounds ( db) {
140
- impls. push ( Delegee :: Bound ( BoundCase { 0 : tb } ) ) ;
140
+ impls. push ( Delegee :: Bound ( BoundCase ( tb ) ) ) ;
141
141
}
142
142
} ;
143
143
144
144
for imp in type_impls {
145
145
match imp. trait_ ( db) {
146
146
Some ( tr) => {
147
147
if tr. is_visible_from ( db, module) {
148
- impls. push ( Delegee :: Impls ( ImplCase { 0 : tr, 1 : imp } ) )
148
+ impls. push ( Delegee :: Impls ( ImplCase ( tr, imp) ) )
149
149
}
150
150
}
151
- None => {
152
- continue ;
153
- }
151
+ None => ( ) ,
154
152
}
155
153
}
156
154
@@ -171,32 +169,19 @@ enum Delegee {
171
169
struct BoundCase ( hir:: Trait ) ;
172
170
struct ImplCase ( hir:: Trait , hir:: Impl ) ;
173
171
174
- /// When we list traits we can implement for the enclosing struct
175
- /// we use the absolute path of a trait. This trait consists of a single
176
- /// method that produces this path.
177
- trait Signatured {
178
- fn signature ( & self , db : & dyn HirDatabase ) -> String ;
179
- }
180
-
181
- impl Signatured for Delegee {
172
+ impl Delegee {
182
173
fn signature ( & self , db : & dyn HirDatabase ) -> String {
183
174
let mut s = String :: new ( ) ;
184
- let trait_: hir:: Trait ;
185
175
186
- match self {
187
- Delegee :: Bound ( b) => trait_ = b. 0 ,
188
- Delegee :: Impls ( i) => trait_ = i. 0 ,
189
- } ;
176
+ let ( Delegee :: Bound ( BoundCase ( it) ) | Delegee :: Impls ( ImplCase ( it, _) ) ) = self ;
190
177
191
- for m in trait_ . module ( db) . path_to_root ( db) . iter ( ) . rev ( ) {
178
+ for m in it . module ( db) . path_to_root ( db) . iter ( ) . rev ( ) {
192
179
if let Some ( name) = m. name ( db) {
193
180
s. push_str ( & format ! ( "{}::" , name. to_smol_str( ) ) ) ;
194
- } else {
195
- continue ;
196
181
}
197
182
}
198
183
199
- s. push_str ( & trait_ . name ( db) . to_smol_str ( ) ) ;
184
+ s. push_str ( & it . name ( db) . to_smol_str ( ) ) ;
200
185
s
201
186
}
202
187
}
@@ -231,7 +216,7 @@ impl Struct {
231
216
let delegate = generate_impl ( ctx, self , & field. ty , & field. name , delegee) ;
232
217
233
218
acc. add_group (
234
- & GroupLabel ( "Generate delegate traits ..." . to_owned ( ) ) ,
219
+ & GroupLabel ( "Delegate trait impl for field ..." . to_owned ( ) ) ,
235
220
AssistId ( "generate_delegate_trait" , ide_db:: assists:: AssistKind :: Generate ) ,
236
221
format ! ( "Generate delegate impl `{}` for `{}`" , signature, field. name) ,
237
222
field. range ,
0 commit comments