File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
src/tools/rust-analyzer/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 {
364364 Visibility :: Crate => Some ( make:: visibility_pub_crate ( ) ) ,
365365 Visibility :: Pub => Some ( make:: visibility_pub ( ) ) ,
366366 } ;
367+ let type_params =
368+ self . generic_param_list . filter ( |list| list. generic_params ( ) . next ( ) . is_some ( ) ) ;
367369 let fn_def = make:: fn_ (
368370 None ,
369371 visibility,
370372 self . fn_name ,
371- self . generic_param_list ,
373+ type_params ,
372374 self . where_clause ,
373375 self . params ,
374376 self . fn_body ,
@@ -2415,6 +2417,33 @@ impl Foo {
24152417 )
24162418 }
24172419
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+
24182447 #[ test]
24192448 fn create_function_with_async ( ) {
24202449 check_assist (
You can’t perform that action at this time.
0 commit comments