diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-14 12:37:28 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-14 12:37:28 +0100 |
commit | 83271f9b9977267492a59c4264fbd7dff9f7ea02 (patch) | |
tree | 65ab2157e01a6d86861b60ab40bc8f12d46d80a5 /crates/ra_assists/src | |
parent | 395e1d7d48276281c69d77fcdf26013dc6ae152d (diff) | |
parent | 85f5cbc9dc7027f922198f6c2d06cf382aad6970 (diff) |
Merge #5367
5367: missing impl members: remove assoc. type bounds r=matklad a=jonas-schievink
Previously "Add missing impl members" would paste bounds on associated types into the impl, which is not allowed. This removes them before pasting the item.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 25 |
1 files changed, 25 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..f185e61e5 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(def.remove_bounds()) | ||
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)); |
@@ -684,4 +687,26 @@ impl Foo<T> for S<T> { | |||
684 | }"#, | 687 | }"#, |
685 | ) | 688 | ) |
686 | } | 689 | } |
690 | |||
691 | #[test] | ||
692 | fn test_assoc_type_bounds_are_removed() { | ||
693 | check_assist( | ||
694 | add_missing_impl_members, | ||
695 | r#" | ||
696 | trait Tr { | ||
697 | type Ty: Copy + 'static; | ||
698 | } | ||
699 | |||
700 | impl Tr for ()<|> { | ||
701 | }"#, | ||
702 | r#" | ||
703 | trait Tr { | ||
704 | type Ty: Copy + 'static; | ||
705 | } | ||
706 | |||
707 | impl Tr for () { | ||
708 | $0type Ty; | ||
709 | }"#, | ||
710 | ) | ||
711 | } | ||
687 | } | 712 | } |