mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Merge #3492
3492: Simplify creation of `T[,]` r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
13879afdd5
@ -139,7 +139,7 @@ impl ast::RecordFieldList {
|
|||||||
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
|
||||||
to_insert.push(space.into());
|
to_insert.push(space.into());
|
||||||
to_insert.push(field.syntax().clone().into());
|
to_insert.push(field.syntax().clone().into());
|
||||||
to_insert.push(tokens::comma().into());
|
to_insert.push(make::token(T![,]).into());
|
||||||
|
|
||||||
macro_rules! after_l_curly {
|
macro_rules! after_l_curly {
|
||||||
() => {{
|
() => {{
|
||||||
@ -160,7 +160,7 @@ impl ast::RecordFieldList {
|
|||||||
{
|
{
|
||||||
InsertPosition::After(comma)
|
InsertPosition::After(comma)
|
||||||
} else {
|
} else {
|
||||||
to_insert.insert(0, tokens::comma().into());
|
to_insert.insert(0, make::token(T![,]).into());
|
||||||
InsertPosition::After($anchor.syntax().clone().into())
|
InsertPosition::After($anchor.syntax().clone().into())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -240,22 +240,13 @@ fn unroot(n: SyntaxNode) -> SyntaxNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod tokens {
|
pub mod tokens {
|
||||||
use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T};
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken};
|
||||||
|
|
||||||
pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
|
pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
|
||||||
Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;"));
|
Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;"));
|
||||||
|
|
||||||
pub fn comma() -> SyntaxToken {
|
|
||||||
SOURCE_FILE
|
|
||||||
.tree()
|
|
||||||
.syntax()
|
|
||||||
.descendants_with_tokens()
|
|
||||||
.filter_map(|it| it.into_token())
|
|
||||||
.find(|it| it.kind() == T![,])
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn single_space() -> SyntaxToken {
|
pub fn single_space() -> SyntaxToken {
|
||||||
SOURCE_FILE
|
SOURCE_FILE
|
||||||
.tree()
|
.tree()
|
||||||
|
Loading…
Reference in New Issue
Block a user