Skip to content

Commit 13879af

Browse files
bors[bot]matklad
andauthored
Merge #3492
3492: Simplify creation of `T[,]` r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 1cc6879 + 85e2346 commit 13879af

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

crates/ra_syntax/src/ast/edit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl ast::RecordFieldList {
139139
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
140140
to_insert.push(space.into());
141141
to_insert.push(field.syntax().clone().into());
142-
to_insert.push(tokens::comma().into());
142+
to_insert.push(make::token(T![,]).into());
143143

144144
macro_rules! after_l_curly {
145145
() => {{
@@ -160,7 +160,7 @@ impl ast::RecordFieldList {
160160
{
161161
InsertPosition::After(comma)
162162
} else {
163-
to_insert.insert(0, tokens::comma().into());
163+
to_insert.insert(0, make::token(T![,]).into());
164164
InsertPosition::After($anchor.syntax().clone().into())
165165
}
166166
};

crates/ra_syntax/src/ast/make.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,13 @@ fn unroot(n: SyntaxNode) -> SyntaxNode {
240240
}
241241

242242
pub mod tokens {
243-
use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T};
244243
use once_cell::sync::Lazy;
245244

245+
use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken};
246+
246247
pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
247248
Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;"));
248249

249-
pub fn comma() -> SyntaxToken {
250-
SOURCE_FILE
251-
.tree()
252-
.syntax()
253-
.descendants_with_tokens()
254-
.filter_map(|it| it.into_token())
255-
.find(|it| it.kind() == T![,])
256-
.unwrap()
257-
}
258-
259250
pub fn single_space() -> SyntaxToken {
260251
SOURCE_FILE
261252
.tree()

0 commit comments

Comments
 (0)