diff options
Diffstat (limited to 'crates/ra_assists/src/add_impl.rs')
-rw-r--r-- | crates/ra_assists/src/add_impl.rs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/crates/ra_assists/src/add_impl.rs b/crates/ra_assists/src/add_impl.rs index 699508f91..f2360bc89 100644 --- a/crates/ra_assists/src/add_impl.rs +++ b/crates/ra_assists/src/add_impl.rs | |||
@@ -21,17 +21,11 @@ pub(crate) fn add_impl(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | |||
21 | buf.push_str(" "); | 21 | buf.push_str(" "); |
22 | buf.push_str(name.text().as_str()); | 22 | buf.push_str(name.text().as_str()); |
23 | if let Some(type_params) = type_params { | 23 | if let Some(type_params) = type_params { |
24 | let lifetime_params = type_params | 24 | let lifetime_params = |
25 | .lifetime_params() | 25 | type_params.lifetime_params().filter_map(|it| it.lifetime()).map(|it| it.text()); |
26 | .filter_map(|it| it.lifetime()) | 26 | let type_params = |
27 | .map(|it| it.text()); | 27 | type_params.type_params().filter_map(|it| it.name()).map(|it| it.text()); |
28 | let type_params = type_params | 28 | join(lifetime_params.chain(type_params)).surround_with("<", ">").to_buf(&mut buf); |
29 | .type_params() | ||
30 | .filter_map(|it| it.name()) | ||
31 | .map(|it| it.text()); | ||
32 | join(lifetime_params.chain(type_params)) | ||
33 | .surround_with("<", ">") | ||
34 | .to_buf(&mut buf); | ||
35 | } | 29 | } |
36 | buf.push_str(" {\n"); | 30 | buf.push_str(" {\n"); |
37 | edit.set_cursor(start_offset + TextUnit::of_str(&buf)); | 31 | edit.set_cursor(start_offset + TextUnit::of_str(&buf)); |
@@ -47,11 +41,7 @@ mod tests { | |||
47 | 41 | ||
48 | #[test] | 42 | #[test] |
49 | fn test_add_impl() { | 43 | fn test_add_impl() { |
50 | check_assist( | 44 | check_assist(add_impl, "struct Foo {<|>}\n", "struct Foo {}\n\nimpl Foo {\n<|>\n}\n"); |
51 | add_impl, | ||
52 | "struct Foo {<|>}\n", | ||
53 | "struct Foo {}\n\nimpl Foo {\n<|>\n}\n", | ||
54 | ); | ||
55 | check_assist( | 45 | check_assist( |
56 | add_impl, | 46 | add_impl, |
57 | "struct Foo<T: Clone> {<|>}", | 47 | "struct Foo<T: Clone> {<|>}", |