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 d6aaf53f10..f185e61e59 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( .map(|it| ast_transform::apply(&*ast_transform, it)) .map(|it| match it { ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), + ast::AssocItem::TypeAliasDef(def) => { + ast::AssocItem::TypeAliasDef(def.remove_bounds()) + } _ => it, }) .map(|it| edit::remove_attrs_and_docs(&it)); @@ -681,6 +684,28 @@ impl Foo for S { fn bar(&self, this: &T, that: &Self) { ${0:todo!()} } +}"#, + ) + } + + #[test] + fn test_assoc_type_bounds_are_removed() { + check_assist( + add_missing_impl_members, + r#" +trait Tr { + type Ty: Copy + 'static; +} + +impl Tr for ()<|> { +}"#, + r#" +trait Tr { + type Ty: Copy + 'static; +} + +impl Tr for () { + $0type Ty; }"#, ) } diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 940c30c7fb..abc7a646c2 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -189,6 +189,21 @@ impl ast::RecordFieldList { } } +impl ast::TypeAliasDef { + #[must_use] + pub fn remove_bounds(&self) -> ast::TypeAliasDef { + let colon = match self.colon_token() { + Some(it) => it, + None => return self.clone(), + }; + let end = match self.type_bound_list() { + Some(it) => it.syntax().clone().into(), + None => colon.clone().into(), + }; + self.replace_children(colon.into()..=end, iter::empty()) + } +} + impl ast::TypeParam { #[must_use] pub fn remove_bounds(&self) -> ast::TypeParam {