diff options
Diffstat (limited to 'crates/syntax')
-rw-r--r-- | crates/syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/syntax/src/ast/edit.rs | 21 |
2 files changed, 11 insertions, 12 deletions
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 0c3fec3c7..9f01acc26 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml | |||
@@ -16,7 +16,7 @@ itertools = "0.10.0" | |||
16 | rowan = "0.13.0-pre.3" | 16 | rowan = "0.13.0-pre.3" |
17 | rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" } | 17 | rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" } |
18 | rustc-hash = "1.1.0" | 18 | rustc-hash = "1.1.0" |
19 | arrayvec = "0.5.1" | 19 | arrayvec = "0.6" |
20 | once_cell = "1.3.1" | 20 | once_cell = "1.3.1" |
21 | indexmap = "1.4.0" | 21 | indexmap = "1.4.0" |
22 | smol_str = { version = "0.1.15", features = ["serde"] } | 22 | smol_str = { version = "0.1.15", features = ["serde"] } |
diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs index 18820786a..8c60927e4 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | //! immutable, all function here return a fresh copy of the tree, instead of | 2 | //! immutable, all function here return a fresh copy of the tree, instead of |
3 | //! doing an in-place modification. | 3 | //! doing an in-place modification. |
4 | use std::{ | 4 | use std::{ |
5 | fmt, iter, | 5 | array, fmt, iter, |
6 | ops::{self, RangeInclusive}, | 6 | ops::{self, RangeInclusive}, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -32,7 +32,7 @@ impl ast::BinExpr { | |||
32 | impl ast::Fn { | 32 | impl ast::Fn { |
33 | #[must_use] | 33 | #[must_use] |
34 | pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn { | 34 | pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn { |
35 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); | 35 | let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new(); |
36 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { | 36 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { |
37 | old_body.syntax().clone().into() | 37 | old_body.syntax().clone().into() |
38 | } else if let Some(semi) = self.semicolon_token() { | 38 | } else if let Some(semi) = self.semicolon_token() { |
@@ -55,9 +55,8 @@ impl ast::Fn { | |||
55 | 55 | ||
56 | let anchor = self.name().expect("The function must have a name").syntax().clone(); | 56 | let anchor = self.name().expect("The function must have a name").syntax().clone(); |
57 | 57 | ||
58 | let mut to_insert: ArrayVec<[SyntaxElement; 1]> = ArrayVec::new(); | 58 | let to_insert = [generic_args.syntax().clone().into()]; |
59 | to_insert.push(generic_args.syntax().clone().into()); | 59 | self.insert_children(InsertPosition::After(anchor.into()), array::IntoIter::new(to_insert)) |
60 | self.insert_children(InsertPosition::After(anchor.into()), to_insert) | ||
61 | } | 60 | } |
62 | } | 61 | } |
63 | 62 | ||
@@ -96,7 +95,7 @@ where | |||
96 | impl ast::Impl { | 95 | impl ast::Impl { |
97 | #[must_use] | 96 | #[must_use] |
98 | pub fn with_assoc_item_list(&self, items: ast::AssocItemList) -> ast::Impl { | 97 | pub fn with_assoc_item_list(&self, items: ast::AssocItemList) -> ast::Impl { |
99 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); | 98 | let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new(); |
100 | if let Some(old_items) = self.assoc_item_list() { | 99 | if let Some(old_items) = self.assoc_item_list() { |
101 | let to_replace: SyntaxElement = old_items.syntax().clone().into(); | 100 | let to_replace: SyntaxElement = old_items.syntax().clone().into(); |
102 | to_insert.push(items.syntax().clone().into()); | 101 | to_insert.push(items.syntax().clone().into()); |
@@ -141,7 +140,7 @@ impl ast::AssocItemList { | |||
141 | }, | 140 | }, |
142 | }; | 141 | }; |
143 | let ws = tokens::WsBuilder::new(&format!("{}{}", whitespace, indent)); | 142 | let ws = tokens::WsBuilder::new(&format!("{}{}", whitespace, indent)); |
144 | let to_insert: ArrayVec<[SyntaxElement; 2]> = | 143 | let to_insert: ArrayVec<SyntaxElement, 2> = |
145 | [ws.ws().into(), item.syntax().clone().into()].into(); | 144 | [ws.ws().into(), item.syntax().clone().into()].into(); |
146 | self.insert_children(position, to_insert) | 145 | self.insert_children(position, to_insert) |
147 | } | 146 | } |
@@ -192,7 +191,7 @@ impl ast::RecordExprFieldList { | |||
192 | tokens::single_space() | 191 | tokens::single_space() |
193 | }; | 192 | }; |
194 | 193 | ||
195 | let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new(); | 194 | let mut to_insert: ArrayVec<SyntaxElement, 4> = ArrayVec::new(); |
196 | to_insert.push(space.into()); | 195 | to_insert.push(space.into()); |
197 | to_insert.push(field.syntax().clone().into()); | 196 | to_insert.push(field.syntax().clone().into()); |
198 | to_insert.push(make::token(T![,]).into()); | 197 | to_insert.push(make::token(T![,]).into()); |
@@ -305,7 +304,7 @@ impl ast::PathSegment { | |||
305 | iter::once(type_args.syntax().clone().into()), | 304 | iter::once(type_args.syntax().clone().into()), |
306 | ); | 305 | ); |
307 | } | 306 | } |
308 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); | 307 | let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new(); |
309 | if turbo { | 308 | if turbo { |
310 | to_insert.push(make::token(T![::]).into()); | 309 | to_insert.push(make::token(T![::]).into()); |
311 | } | 310 | } |
@@ -444,7 +443,7 @@ impl ast::MatchArmList { | |||
444 | let arm_ws = tokens::WsBuilder::new(" "); | 443 | let arm_ws = tokens::WsBuilder::new(" "); |
445 | let match_indent = &leading_indent(self.syntax()).unwrap_or_default(); | 444 | let match_indent = &leading_indent(self.syntax()).unwrap_or_default(); |
446 | let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent)); | 445 | let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent)); |
447 | let to_insert: ArrayVec<[SyntaxElement; 3]> = | 446 | let to_insert: ArrayVec<SyntaxElement, 3> = |
448 | [arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into(); | 447 | [arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into(); |
449 | self.insert_children(position, to_insert) | 448 | self.insert_children(position, to_insert) |
450 | } | 449 | } |
@@ -465,7 +464,7 @@ impl ast::GenericParamList { | |||
465 | pub fn append_param(&self, item: ast::GenericParam) -> ast::GenericParamList { | 464 | pub fn append_param(&self, item: ast::GenericParam) -> ast::GenericParamList { |
466 | let space = tokens::single_space(); | 465 | let space = tokens::single_space(); |
467 | 466 | ||
468 | let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new(); | 467 | let mut to_insert: ArrayVec<SyntaxElement, 4> = ArrayVec::new(); |
469 | if self.generic_params().next().is_some() { | 468 | if self.generic_params().next().is_some() { |
470 | to_insert.push(space.into()); | 469 | to_insert.push(space.into()); |
471 | } | 470 | } |