From 9787bddac577a6aa24388fb91286474a7a8cf0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 25 Mar 2021 21:03:20 +0200 Subject: Use arrayvec 0.6 --- crates/syntax/Cargo.toml | 2 +- crates/syntax/src/ast/edit.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/syntax') 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" rowan = "0.13.0-pre.3" rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" } rustc-hash = "1.1.0" -arrayvec = "0.5.1" +arrayvec = "0.6" once_cell = "1.3.1" indexmap = "1.4.0" 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..2d1d08fba 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs @@ -32,7 +32,7 @@ impl ast::BinExpr { impl ast::Fn { #[must_use] pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn { - let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); + let mut to_insert: ArrayVec = ArrayVec::new(); let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { old_body.syntax().clone().into() } else if let Some(semi) = self.semicolon_token() { @@ -55,7 +55,7 @@ impl ast::Fn { let anchor = self.name().expect("The function must have a name").syntax().clone(); - let mut to_insert: ArrayVec<[SyntaxElement; 1]> = ArrayVec::new(); + let mut to_insert: ArrayVec = ArrayVec::new(); to_insert.push(generic_args.syntax().clone().into()); self.insert_children(InsertPosition::After(anchor.into()), to_insert) } @@ -96,7 +96,7 @@ where impl ast::Impl { #[must_use] pub fn with_assoc_item_list(&self, items: ast::AssocItemList) -> ast::Impl { - let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); + let mut to_insert: ArrayVec = ArrayVec::new(); if let Some(old_items) = self.assoc_item_list() { let to_replace: SyntaxElement = old_items.syntax().clone().into(); to_insert.push(items.syntax().clone().into()); @@ -141,7 +141,7 @@ impl ast::AssocItemList { }, }; let ws = tokens::WsBuilder::new(&format!("{}{}", whitespace, indent)); - let to_insert: ArrayVec<[SyntaxElement; 2]> = + let to_insert: ArrayVec = [ws.ws().into(), item.syntax().clone().into()].into(); self.insert_children(position, to_insert) } @@ -192,7 +192,7 @@ impl ast::RecordExprFieldList { tokens::single_space() }; - let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new(); + let mut to_insert: ArrayVec = ArrayVec::new(); to_insert.push(space.into()); to_insert.push(field.syntax().clone().into()); to_insert.push(make::token(T![,]).into()); @@ -305,7 +305,7 @@ impl ast::PathSegment { iter::once(type_args.syntax().clone().into()), ); } - let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); + let mut to_insert: ArrayVec = ArrayVec::new(); if turbo { to_insert.push(make::token(T![::]).into()); } @@ -444,7 +444,7 @@ impl ast::MatchArmList { let arm_ws = tokens::WsBuilder::new(" "); let match_indent = &leading_indent(self.syntax()).unwrap_or_default(); let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent)); - let to_insert: ArrayVec<[SyntaxElement; 3]> = + let to_insert: ArrayVec = [arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into(); self.insert_children(position, to_insert) } @@ -465,7 +465,7 @@ impl ast::GenericParamList { pub fn append_param(&self, item: ast::GenericParam) -> ast::GenericParamList { let space = tokens::single_space(); - let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new(); + let mut to_insert: ArrayVec = ArrayVec::new(); if self.generic_params().next().is_some() { to_insert.push(space.into()); } -- cgit v1.2.3 From bc5c86543b1bf384555471415dee770888a1781d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 25 Mar 2021 21:06:48 +0200 Subject: Use more std::array::IntoIter --- crates/syntax/src/ast/edit.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/syntax') diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs index 2d1d08fba..8c60927e4 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs @@ -2,7 +2,7 @@ //! immutable, all function here return a fresh copy of the tree, instead of //! doing an in-place modification. use std::{ - fmt, iter, + array, fmt, iter, ops::{self, RangeInclusive}, }; @@ -55,9 +55,8 @@ impl ast::Fn { let anchor = self.name().expect("The function must have a name").syntax().clone(); - let mut to_insert: ArrayVec = ArrayVec::new(); - to_insert.push(generic_args.syntax().clone().into()); - self.insert_children(InsertPosition::After(anchor.into()), to_insert) + let to_insert = [generic_args.syntax().clone().into()]; + self.insert_children(InsertPosition::After(anchor.into()), array::IntoIter::new(to_insert)) } } -- cgit v1.2.3