diff options
author | Jonas Schievink <[email protected]> | 2020-07-14 12:12:16 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-07-14 12:12:16 +0100 |
commit | 0f654b06ab093e7bb057cfd68b27925803b003d8 (patch) | |
tree | c3fe1dd48945a139ba59c2e48453d8037efc5fe6 /crates/ra_assists/src/handlers | |
parent | 510866b4a1a812414568bd96f1d197587ead78c0 (diff) |
missing impl members: remove assoc. type bounds
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index d6aaf53f1..124cead6c 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -158,6 +158,9 @@ fn add_missing_impl_members_inner( | |||
158 | .map(|it| ast_transform::apply(&*ast_transform, it)) | 158 | .map(|it| ast_transform::apply(&*ast_transform, it)) |
159 | .map(|it| match it { | 159 | .map(|it| match it { |
160 | ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), | 160 | ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), |
161 | ast::AssocItem::TypeAliasDef(def) => { | ||
162 | ast::AssocItem::TypeAliasDef(remove_bounds(def)) | ||
163 | } | ||
161 | _ => it, | 164 | _ => it, |
162 | }) | 165 | }) |
163 | .map(|it| edit::remove_attrs_and_docs(&it)); | 166 | .map(|it| edit::remove_attrs_and_docs(&it)); |
@@ -188,6 +191,14 @@ fn add_missing_impl_members_inner( | |||
188 | }) | 191 | }) |
189 | } | 192 | } |
190 | 193 | ||
194 | fn remove_bounds(ty_def: ast::TypeAliasDef) -> ast::TypeAliasDef { | ||
195 | if let Some(name) = ty_def.name() { | ||
196 | make::type_alias_def(name, None, ty_def.type_ref()) | ||
197 | } else { | ||
198 | ty_def | ||
199 | } | ||
200 | } | ||
201 | |||
191 | fn add_body(fn_def: ast::FnDef) -> ast::FnDef { | 202 | fn add_body(fn_def: ast::FnDef) -> ast::FnDef { |
192 | if fn_def.body().is_some() { | 203 | if fn_def.body().is_some() { |
193 | return fn_def; | 204 | return fn_def; |
@@ -684,4 +695,26 @@ impl Foo<T> for S<T> { | |||
684 | }"#, | 695 | }"#, |
685 | ) | 696 | ) |
686 | } | 697 | } |
698 | |||
699 | #[test] | ||
700 | fn test_assoc_type_bounds_are_removed() { | ||
701 | check_assist( | ||
702 | add_missing_impl_members, | ||
703 | r#" | ||
704 | trait Tr { | ||
705 | type Ty: Copy + 'static; | ||
706 | } | ||
707 | |||
708 | impl Tr for ()<|> { | ||
709 | }"#, | ||
710 | r#" | ||
711 | trait Tr { | ||
712 | type Ty: Copy + 'static; | ||
713 | } | ||
714 | |||
715 | impl Tr for () { | ||
716 | $0type Ty; | ||
717 | }"#, | ||
718 | ) | ||
719 | } | ||
687 | } | 720 | } |