@@ -139,14 +139,20 @@ fn add_assist(
139
139
let trait_path = make:: ty_path ( replace_trait_path. clone ( ) ) ;
140
140
141
141
match ( ctx. config . snippet_cap , impl_def_with_items) {
142
- ( None , _ ) => {
142
+ ( None , None ) => {
143
143
let impl_def = generate_trait_impl ( adt, trait_path) ;
144
144
145
145
ted:: insert_all (
146
146
insert_after,
147
147
vec ! [ make:: tokens:: blank_line( ) . into( ) , impl_def. syntax( ) . clone( ) . into( ) ] ,
148
148
) ;
149
149
}
150
+ ( None , Some ( ( impl_def, _) ) ) => {
151
+ ted:: insert_all (
152
+ insert_after,
153
+ vec ! [ make:: tokens:: blank_line( ) . into( ) , impl_def. syntax( ) . clone( ) . into( ) ] ,
154
+ ) ;
155
+ }
150
156
( Some ( cap) , None ) => {
151
157
let impl_def = generate_trait_impl ( adt, trait_path) ;
152
158
@@ -272,7 +278,7 @@ fn update_attribute(
272
278
273
279
#[ cfg( test) ]
274
280
mod tests {
275
- use crate :: tests:: { check_assist, check_assist_not_applicable} ;
281
+ use crate :: tests:: { check_assist, check_assist_no_snippet_cap , check_assist_not_applicable} ;
276
282
277
283
use super :: * ;
278
284
@@ -297,6 +303,30 @@ impl core::fmt::Debug for Foo {
297
303
f.debug_struct("Foo").field("bar", &self.bar).finish()
298
304
}
299
305
}
306
+ "# ,
307
+ )
308
+ }
309
+ #[ test]
310
+ fn add_custom_impl_without_snippet ( ) {
311
+ check_assist_no_snippet_cap (
312
+ replace_derive_with_manual_impl,
313
+ r#"
314
+ //- minicore: fmt, derive
315
+ #[derive(Debu$0g)]
316
+ struct Foo {
317
+ bar: String,
318
+ }
319
+ "# ,
320
+ r#"
321
+ struct Foo {
322
+ bar: String,
323
+ }
324
+
325
+ impl core::fmt::Debug for Foo {
326
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
327
+ f.debug_struct("Foo").field("bar", &self.bar).finish()
328
+ }
329
+ }
300
330
"# ,
301
331
)
302
332
}
0 commit comments