@@ -137,20 +137,18 @@ impl Field {
137137
138138 if let Some ( tp) = type_param {
139139 for tb in tp. trait_bounds ( db) {
140- impls. push ( Delegee :: Bound ( BoundCase { 0 : tb } ) ) ;
140+ impls. push ( Delegee :: Bound ( BoundCase ( tb ) ) ) ;
141141 }
142142 } ;
143143
144144 for imp in type_impls {
145145 match imp. trait_ ( db) {
146146 Some ( tr) => {
147147 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) ) )
149149 }
150150 }
151- None => {
152- continue ;
153- }
151+ None => ( ) ,
154152 }
155153 }
156154
@@ -171,32 +169,19 @@ enum Delegee {
171169struct BoundCase ( hir:: Trait ) ;
172170struct ImplCase ( hir:: Trait , hir:: Impl ) ;
173171
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 {
182173 fn signature ( & self , db : & dyn HirDatabase ) -> String {
183174 let mut s = String :: new ( ) ;
184- let trait_: hir:: Trait ;
185175
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 ;
190177
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 ( ) {
192179 if let Some ( name) = m. name ( db) {
193180 s. push_str ( & format ! ( "{}::" , name. to_smol_str( ) ) ) ;
194- } else {
195- continue ;
196181 }
197182 }
198183
199- s. push_str ( & trait_ . name ( db) . to_smol_str ( ) ) ;
184+ s. push_str ( & it . name ( db) . to_smol_str ( ) ) ;
200185 s
201186 }
202187}
@@ -231,7 +216,7 @@ impl Struct {
231216 let delegate = generate_impl ( ctx, self , & field. ty , & field. name , delegee) ;
232217
233218 acc. add_group (
234- & GroupLabel ( "Generate delegate traits ..." . to_owned ( ) ) ,
219+ & GroupLabel ( "Delegate trait impl for field ..." . to_owned ( ) ) ,
235220 AssistId ( "generate_delegate_trait" , ide_db:: assists:: AssistKind :: Generate ) ,
236221 format ! ( "Generate delegate impl `{}` for `{}`" , signature, field. name) ,
237222 field. range ,
0 commit comments