Merge commit 'a911652360' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2024-01-21 16:53:06 +02:00
parent 0661390ad4
commit e4866b6ddb
315 changed files with 7088 additions and 4415 deletions

View file

@ -53,6 +53,12 @@ fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> {
}
}
impl ast::Abi {
pub fn abi_string(&self) -> Option<ast::String> {
support::token(&self.syntax, SyntaxKind::STRING).and_then(ast::String::cast)
}
}
impl ast::HasModuleItem for ast::StmtList {}
impl ast::BlockExpr {
@ -327,6 +333,14 @@ impl ast::UseTree {
pub fn parent_use_tree_list(&self) -> Option<ast::UseTreeList> {
self.syntax().parent().and_then(ast::UseTreeList::cast)
}
pub fn top_use_tree(&self) -> ast::UseTree {
let mut this = self.clone();
while let Some(use_tree_list) = this.parent_use_tree_list() {
this = use_tree_list.parent_use_tree();
}
this
}
}
impl ast::UseTreeList {
@ -356,8 +370,12 @@ impl ast::UseTreeList {
let remove_brace_in_use_tree_list = |u: &ast::UseTreeList| {
let use_tree_count = u.use_trees().count();
if use_tree_count == 1 {
u.l_curly_token().map(ted::remove);
u.r_curly_token().map(ted::remove);
if let Some(a) = u.l_curly_token() {
ted::remove(a)
}
if let Some(a) = u.r_curly_token() {
ted::remove(a)
}
u.comma().for_each(ted::remove);
}
};
@ -440,6 +458,12 @@ impl ast::Struct {
}
}
impl ast::Union {
pub fn kind(&self) -> StructKind {
StructKind::from_node(self)
}
}
impl ast::RecordExprField {
pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> {
let candidate = Self::for_name_ref(field_name)?;