diff --git a/crates/ide-assists/src/handlers/move_bounds.rs b/crates/ide-assists/src/handlers/move_bounds.rs index b510b2daba67..1415fbd8d285 100644 --- a/crates/ide-assists/src/handlers/move_bounds.rs +++ b/crates/ide-assists/src/handlers/move_bounds.rs @@ -149,6 +149,15 @@ mod tests { ); } + #[test] + fn move_bounds_to_where_clause_trait_with_supertraits() { + check_assist( + move_bounds_to_where_clause, + r#"trait T<'a: 'static, $0T: u32>: Super {}"#, + r#"trait T<'a, T>: Super where 'a: 'static, T: u32 {}"#, + ); + } + #[test] fn move_bounds_to_where_clause_type_alias() { check_assist( diff --git a/crates/syntax/src/syntax_editor/edits.rs b/crates/syntax/src/syntax_editor/edits.rs index 45ec56be43ae..307e13591c61 100644 --- a/crates/syntax/src/syntax_editor/edits.rs +++ b/crates/syntax/src/syntax_editor/edits.rs @@ -3,7 +3,7 @@ use crate::{ AstToken, Direction, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, T, algo::neighbor, - ast::{self, AstNode, HasGenericParams, HasName, edit::IndentLevel}, + ast::{self, AstNode, HasGenericParams, HasName, HasTypeBounds, edit::IndentLevel}, syntax_editor::{Position, SyntaxEditor}, }; @@ -56,7 +56,9 @@ impl GetOrCreateWhereClause for ast::Impl { impl GetOrCreateWhereClause for ast::Trait { fn where_clause_position(&self) -> Option { - if let Some(gpl) = self.generic_param_list() { + if let Some(tbl) = self.type_bound_list() { + Some(Position::after(tbl.syntax())) + } else if let Some(gpl) = self.generic_param_list() { Some(Position::after(gpl.syntax())) } else if let Some(name) = self.name() { Some(Position::after(name.syntax()))