aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-09 16:55:42 +0100
committerGitHub <[email protected]>2021-05-09 16:55:42 +0100
commita3b034938ebe12b29ef37ff6e54bad3c574464be (patch)
tree1ed28e5499d4db6948c18f96e2136a2f61f5e222 /crates/syntax/src/ast
parent0900beeaa2ca4b9e91d51165545935d4e1db7bb6 (diff)
parent5342800147679a0ded5546322c94aa6339d58fbc (diff)
Merge #8781
8781: internal: rewrite **Repalce impl Trait** assist to mutable syntax trees r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r--crates/syntax/src/ast/edit_in_place.rs19
-rw-r--r--crates/syntax/src/ast/make.rs4
2 files changed, 9 insertions, 14 deletions
diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs
index 04f97f368..168355555 100644
--- a/crates/syntax/src/ast/edit_in_place.rs
+++ b/crates/syntax/src/ast/edit_in_place.rs
@@ -195,18 +195,13 @@ impl ast::GenericParamList {
195 pub fn add_generic_param(&self, generic_param: ast::GenericParam) { 195 pub fn add_generic_param(&self, generic_param: ast::GenericParam) {
196 match self.generic_params().last() { 196 match self.generic_params().last() {
197 Some(last_param) => { 197 Some(last_param) => {
198 let mut elems = Vec::new(); 198 let position = Position::after(last_param.syntax());
199 if !last_param 199 let elements = vec![
200 .syntax() 200 make::token(T![,]).into(),
201 .siblings_with_tokens(Direction::Next) 201 make::tokens::single_space().into(),
202 .any(|it| it.kind() == T![,]) 202 generic_param.syntax().clone().into(),
203 { 203 ];
204 elems.push(make::token(T![,]).into()); 204 ted::insert_all(position, elements);
205 elems.push(make::tokens::single_space().into());
206 };
207 elems.push(generic_param.syntax().clone().into());
208 let after_last_param = Position::after(last_param.syntax());
209 ted::insert_all(after_last_param, elems);
210 } 205 }
211 None => { 206 None => {
212 let after_l_angle = Position::after(self.l_angle_token().unwrap()); 207 let after_l_angle = Position::after(self.l_angle_token().unwrap());
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index 5a6687397..2289d8f3e 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -475,8 +475,8 @@ pub fn param_list(
475 }; 475 };
476 ast_from_text(&list) 476 ast_from_text(&list)
477} 477}
478 478// FIXME: s/&str/ast:Name
479pub fn generic_param(name: String, ty: Option<ast::TypeBoundList>) -> ast::GenericParam { 479pub fn generic_param(name: &str, ty: Option<ast::TypeBoundList>) -> ast::GenericParam {
480 let bound = match ty { 480 let bound = match ty {
481 Some(it) => format!(": {}", it), 481 Some(it) => format!(": {}", it),
482 None => String::new(), 482 None => String::new(),