diff options
Diffstat (limited to 'crates/assists')
4 files changed, 28 insertions, 3 deletions
diff --git a/crates/assists/src/ast_transform.rs b/crates/assists/src/ast_transform.rs index 66e4634b1..da94e9987 100644 --- a/crates/assists/src/ast_transform.rs +++ b/crates/assists/src/ast_transform.rs | |||
@@ -89,7 +89,7 @@ impl<'a> SubstituteTypeParams<'a> { | |||
89 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); | 89 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); |
90 | let generic_def: hir::GenericDef = trait_.into(); | 90 | let generic_def: hir::GenericDef = trait_.into(); |
91 | let substs_by_param: FxHashMap<_, _> = generic_def | 91 | let substs_by_param: FxHashMap<_, _> = generic_def |
92 | .params(source_scope.db) | 92 | .type_params(source_scope.db) |
93 | .into_iter() | 93 | .into_iter() |
94 | // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky | 94 | // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky |
95 | .skip(1) | 95 | .skip(1) |
diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs index bbb71e261..e413505d3 100644 --- a/crates/assists/src/handlers/add_missing_impl_members.rs +++ b/crates/assists/src/handlers/add_missing_impl_members.rs | |||
@@ -784,4 +784,29 @@ impl Test for () { | |||
784 | "#, | 784 | "#, |
785 | ) | 785 | ) |
786 | } | 786 | } |
787 | |||
788 | #[test] | ||
789 | fn missing_generic_type() { | ||
790 | check_assist( | ||
791 | add_missing_impl_members, | ||
792 | r#" | ||
793 | trait Foo<BAR> { | ||
794 | fn foo(&self, bar: BAR); | ||
795 | } | ||
796 | impl Foo for () { | ||
797 | <|> | ||
798 | } | ||
799 | "#, | ||
800 | r#" | ||
801 | trait Foo<BAR> { | ||
802 | fn foo(&self, bar: BAR); | ||
803 | } | ||
804 | impl Foo for () { | ||
805 | fn foo(&self, bar: BAR) { | ||
806 | ${0:todo!()} | ||
807 | } | ||
808 | } | ||
809 | "#, | ||
810 | ) | ||
811 | } | ||
787 | } | 812 | } |
diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index d85767b4e..2e56bd7ff 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -212,7 +212,7 @@ fn update_reference( | |||
212 | find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset) | 212 | find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset) |
213 | { | 213 | { |
214 | // tuple variant | 214 | // tuple variant |
215 | (path_expr.path()?.segment()?, path_expr.syntax().parent()?.clone()) | 215 | (path_expr.path()?.segment()?, path_expr.syntax().parent()?) |
216 | } else if let Some(record_expr) = | 216 | } else if let Some(record_expr) = |
217 | find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset) | 217 | find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset) |
218 | { | 218 | { |
diff --git a/crates/assists/src/handlers/qualify_path.rs b/crates/assists/src/handlers/qualify_path.rs index 6f9810fe8..98cb09214 100644 --- a/crates/assists/src/handlers/qualify_path.rs +++ b/crates/assists/src/handlers/qualify_path.rs | |||
@@ -150,7 +150,7 @@ impl QualifyCandidate<'_> { | |||
150 | import, | 150 | import, |
151 | trait_method_name, | 151 | trait_method_name, |
152 | generics, | 152 | generics, |
153 | match arg_list.clone() { | 153 | match arg_list { |
154 | Some(args) => make::arg_list(iter::once(receiver).chain(args)), | 154 | Some(args) => make::arg_list(iter::once(receiver).chain(args)), |
155 | None => make::arg_list(iter::once(receiver)), | 155 | None => make::arg_list(iter::once(receiver)), |
156 | } | 156 | } |