File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -364,11 +364,13 @@ impl FunctionBuilder {
364
364
Visibility :: Crate => Some ( make:: visibility_pub_crate ( ) ) ,
365
365
Visibility :: Pub => Some ( make:: visibility_pub ( ) ) ,
366
366
} ;
367
+ let type_params =
368
+ self . generic_param_list . filter ( |list| list. generic_params ( ) . next ( ) . is_some ( ) ) ;
367
369
let fn_def = make:: fn_ (
368
370
None ,
369
371
visibility,
370
372
self . fn_name ,
371
- self . generic_param_list ,
373
+ type_params ,
372
374
self . where_clause ,
373
375
self . params ,
374
376
self . fn_body ,
@@ -2415,6 +2417,33 @@ impl Foo {
2415
2417
)
2416
2418
}
2417
2419
2420
+ #[ test]
2421
+ fn create_method_with_unused_generics ( ) {
2422
+ check_assist (
2423
+ generate_function,
2424
+ r#"
2425
+ struct Foo<S>(S);
2426
+ impl<S> Foo<S> {
2427
+ fn foo(&self) {
2428
+ self.bar()$0;
2429
+ }
2430
+ }
2431
+ "# ,
2432
+ r#"
2433
+ struct Foo<S>(S);
2434
+ impl<S> Foo<S> {
2435
+ fn foo(&self) {
2436
+ self.bar();
2437
+ }
2438
+
2439
+ fn bar(&self) ${0:-> _} {
2440
+ todo!()
2441
+ }
2442
+ }
2443
+ "# ,
2444
+ )
2445
+ }
2446
+
2418
2447
#[ test]
2419
2448
fn create_function_with_async ( ) {
2420
2449
check_assist (
You can’t perform that action at this time.
0 commit comments