5595: Rename RecordLit -> RecordExpr r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-07-30 14:24:20 +00:00 committed by GitHub
commit 282702c287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 145 additions and 139 deletions

View file

@ -240,7 +240,7 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> {
Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
Expr::RecordLit(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),

View file

@ -45,7 +45,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
target, target,
move |edit| { move |edit| {
let field_shorthand = let field_shorthand =
match to_extract.syntax().parent().and_then(ast::RecordField::cast) { match to_extract.syntax().parent().and_then(ast::RecordExprField::cast) {
Some(field) => field.name_ref(), Some(field) => field.name_ref(),
None => None, None => None,
}; };

View file

@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O
} }
fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
let record_field: ast::RecordField = ctx.find_node_at_offset()?; let record_field: ast::RecordExprField = ctx.find_node_at_offset()?;
let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?;
let current_module = ctx.sema.scope(record_field.syntax()).module()?; let current_module = ctx.sema.scope(record_field.syntax()).module()?;

View file

@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ``` // ```
// //
pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
reorder::<ast::RecordLit>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) reorder::<ast::RecordExpr>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx))
} }
fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
@ -56,7 +56,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
match node.kind() { match node.kind() {
RECORD_LIT => vec![RECORD_FIELD], RECORD_EXPR => vec![RECORD_EXPR_FIELD],
RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT],
_ => vec![], _ => vec![],
} }
@ -65,7 +65,7 @@ fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
fn get_field_name(node: &SyntaxNode) -> String { fn get_field_name(node: &SyntaxNode) -> String {
let res = match_ast! { let res = match_ast! {
match node { match node {
ast::RecordField(field) => field.field_name().map(|it| it.to_string()), ast::RecordExprField(field) => field.field_name().map(|it| it.to_string()),
ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()),
_ => None, _ => None,
} }

View file

@ -209,7 +209,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
self.imp.resolve_field(field) self.imp.resolve_field(field)
} }
pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { pub fn resolve_record_field(
&self,
field: &ast::RecordExprField,
) -> Option<(Field, Option<Local>)> {
self.imp.resolve_record_field(field) self.imp.resolve_record_field(field)
} }
@ -225,7 +228,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
self.imp.resolve_path(path) self.imp.resolve_path(path)
} }
pub fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantDef> { pub fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantDef> {
self.imp.resolve_variant(record_lit).map(VariantDef::from) self.imp.resolve_variant(record_lit).map(VariantDef::from)
} }
@ -240,7 +243,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
// FIXME: use this instead? // FIXME: use this instead?
// pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>;
pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { pub fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
self.imp.record_literal_missing_fields(literal) self.imp.record_literal_missing_fields(literal)
} }
@ -422,7 +425,7 @@ impl<'db> SemanticsImpl<'db> {
self.analyze(field.syntax()).resolve_field(self.db, field) self.analyze(field.syntax()).resolve_field(self.db, field)
} }
fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { fn resolve_record_field(&self, field: &ast::RecordExprField) -> Option<(Field, Option<Local>)> {
self.analyze(field.syntax()).resolve_record_field(self.db, field) self.analyze(field.syntax()).resolve_record_field(self.db, field)
} }
@ -440,7 +443,7 @@ impl<'db> SemanticsImpl<'db> {
self.analyze(path.syntax()).resolve_path(self.db, path) self.analyze(path.syntax()).resolve_path(self.db, path)
} }
fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantId> { fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantId> {
self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit)
} }
@ -453,7 +456,7 @@ impl<'db> SemanticsImpl<'db> {
self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat)
} }
fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
self.analyze(literal.syntax()) self.analyze(literal.syntax())
.record_literal_missing_fields(self.db, literal) .record_literal_missing_fields(self.db, literal)
.unwrap_or_default() .unwrap_or_default()

View file

@ -159,7 +159,7 @@ impl SourceAnalyzer {
pub(crate) fn resolve_record_field( pub(crate) fn resolve_record_field(
&self, &self,
db: &dyn HirDatabase, db: &dyn HirDatabase,
field: &ast::RecordField, field: &ast::RecordExprField,
) -> Option<(Field, Option<Local>)> { ) -> Option<(Field, Option<Local>)> {
let expr = field.expr()?; let expr = field.expr()?;
let expr_id = self.expr_id(db, &expr)?; let expr_id = self.expr_id(db, &expr)?;
@ -246,7 +246,7 @@ impl SourceAnalyzer {
} }
} }
if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordLit::cast) { if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordExpr::cast) {
let expr_id = self.expr_id(db, &rec_lit.into())?; let expr_id = self.expr_id(db, &rec_lit.into())?;
if let Some(VariantId::EnumVariantId(variant)) = if let Some(VariantId::EnumVariantId(variant)) =
self.infer.as_ref()?.variant_resolution_for_expr(expr_id) self.infer.as_ref()?.variant_resolution_for_expr(expr_id)
@ -284,7 +284,7 @@ impl SourceAnalyzer {
pub(crate) fn record_literal_missing_fields( pub(crate) fn record_literal_missing_fields(
&self, &self,
db: &dyn HirDatabase, db: &dyn HirDatabase,
literal: &ast::RecordLit, literal: &ast::RecordExpr,
) -> Option<Vec<(Field, Type)>> { ) -> Option<Vec<(Field, Type)>> {
let krate = self.resolver.krate()?; let krate = self.resolver.krate()?;
let body = self.body.as_ref()?; let body = self.body.as_ref()?;
@ -358,7 +358,7 @@ impl SourceAnalyzer {
pub(crate) fn resolve_variant( pub(crate) fn resolve_variant(
&self, &self,
db: &dyn HirDatabase, db: &dyn HirDatabase,
record_lit: ast::RecordLit, record_lit: ast::RecordExpr,
) -> Option<VariantId> { ) -> Option<VariantId> {
let infer = self.infer.as_ref()?; let infer = self.infer.as_ref()?;
let expr_id = self.expr_id(db, &record_lit.into())?; let expr_id = self.expr_id(db, &record_lit.into())?;

View file

@ -216,7 +216,7 @@ pub struct BodySourceMap {
expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>, expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>,
pat_map: FxHashMap<PatSource, PatId>, pat_map: FxHashMap<PatSource, PatId>,
pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>, pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>,
field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordField>>>, field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordExprField>>>,
expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>,
} }
@ -314,7 +314,7 @@ impl BodySourceMap {
self.pat_map.get(&src).cloned() self.pat_map.get(&src).cloned()
} }
pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordField>> { pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordExprField>> {
self.field_map[&(expr, field)].clone() self.field_map[&(expr, field)].clone()
} }
} }

View file

@ -379,10 +379,10 @@ impl ExprCollector<'_> {
let expr = e.expr().map(|e| self.collect_expr(e)); let expr = e.expr().map(|e| self.collect_expr(e));
self.alloc_expr(Expr::Return { expr }, syntax_ptr) self.alloc_expr(Expr::Return { expr }, syntax_ptr)
} }
ast::Expr::RecordLit(e) => { ast::Expr::RecordExpr(e) => {
let path = e.path().and_then(|path| self.expander.parse_path(path)); let path = e.path().and_then(|path| self.expander.parse_path(path));
let mut field_ptrs = Vec::new(); let mut field_ptrs = Vec::new();
let record_lit = if let Some(nfl) = e.record_field_list() { let record_lit = if let Some(nfl) = e.record_expr_field_list() {
let fields = nfl let fields = nfl
.fields() .fields()
.inspect(|field| field_ptrs.push(AstPtr::new(field))) .inspect(|field| field_ptrs.push(AstPtr::new(field)))

View file

@ -386,7 +386,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind {
MATCH_EXPR => FragmentKind::Expr, MATCH_EXPR => FragmentKind::Expr,
MATCH_ARM => FragmentKind::Expr, MATCH_ARM => FragmentKind::Expr,
MATCH_GUARD => FragmentKind::Expr, MATCH_GUARD => FragmentKind::Expr,
RECORD_FIELD => FragmentKind::Expr, RECORD_EXPR_FIELD => FragmentKind::Expr,
CALL_EXPR => FragmentKind::Expr, CALL_EXPR => FragmentKind::Expr,
INDEX_EXPR => FragmentKind::Expr, INDEX_EXPR => FragmentKind::Expr,
METHOD_CALL_EXPR => FragmentKind::Expr, METHOD_CALL_EXPR => FragmentKind::Expr,

View file

@ -29,7 +29,7 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag
#[derive(Debug)] #[derive(Debug)]
pub struct NoSuchField { pub struct NoSuchField {
pub file: HirFileId, pub file: HirFileId,
pub field: AstPtr<ast::RecordField>, pub field: AstPtr<ast::RecordExprField>,
} }
impl Diagnostic for NoSuchField { impl Diagnostic for NoSuchField {
@ -47,19 +47,19 @@ impl Diagnostic for NoSuchField {
} }
impl AstDiagnostic for NoSuchField { impl AstDiagnostic for NoSuchField {
type AST = ast::RecordField; type AST = ast::RecordExprField;
fn ast(&self, db: &dyn AstDatabase) -> Self::AST { fn ast(&self, db: &dyn AstDatabase) -> Self::AST {
let root = db.parse_or_expand(self.source().file_id).unwrap(); let root = db.parse_or_expand(self.source().file_id).unwrap();
let node = self.source().value.to_node(&root); let node = self.source().value.to_node(&root);
ast::RecordField::cast(node).unwrap() ast::RecordExprField::cast(node).unwrap()
} }
} }
#[derive(Debug)] #[derive(Debug)]
pub struct MissingFields { pub struct MissingFields {
pub file: HirFileId, pub file: HirFileId,
pub field_list: AstPtr<ast::RecordFieldList>, pub field_list: AstPtr<ast::RecordExprFieldList>,
pub missed_fields: Vec<Name>, pub missed_fields: Vec<Name>,
} }
@ -80,12 +80,12 @@ impl Diagnostic for MissingFields {
} }
impl AstDiagnostic for MissingFields { impl AstDiagnostic for MissingFields {
type AST = ast::RecordFieldList; type AST = ast::RecordExprFieldList;
fn ast(&self, db: &dyn AstDatabase) -> Self::AST { fn ast(&self, db: &dyn AstDatabase) -> Self::AST {
let root = db.parse_or_expand(self.source().file_id).unwrap(); let root = db.parse_or_expand(self.source().file_id).unwrap();
let node = self.source().value.to_node(&root); let node = self.source().value.to_node(&root);
ast::RecordFieldList::cast(node).unwrap() ast::RecordExprFieldList::cast(node).unwrap()
} }
} }

View file

@ -100,8 +100,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
if let Ok(source_ptr) = source_map.expr_syntax(id) { if let Ok(source_ptr) = source_map.expr_syntax(id) {
let root = source_ptr.file_syntax(db.upcast()); let root = source_ptr.file_syntax(db.upcast());
if let ast::Expr::RecordLit(record_lit) = &source_ptr.value.to_node(&root) { if let ast::Expr::RecordExpr(record_lit) = &source_ptr.value.to_node(&root) {
if let Some(field_list) = record_lit.record_field_list() { if let Some(field_list) = record_lit.record_expr_field_list() {
let variant_data = variant_data(db.upcast(), variant_def); let variant_data = variant_data(db.upcast(), variant_def);
let missed_fields = missed_fields let missed_fields = missed_fields
.into_iter() .into_iter()

View file

@ -37,9 +37,9 @@ pub(crate) struct CompletionContext<'a> {
pub(super) name_ref_syntax: Option<ast::NameRef>, pub(super) name_ref_syntax: Option<ast::NameRef>,
pub(super) function_syntax: Option<ast::Fn>, pub(super) function_syntax: Option<ast::Fn>,
pub(super) use_item_syntax: Option<ast::Use>, pub(super) use_item_syntax: Option<ast::Use>,
pub(super) record_lit_syntax: Option<ast::RecordLit>, pub(super) record_lit_syntax: Option<ast::RecordExpr>,
pub(super) record_pat_syntax: Option<ast::RecordPat>, pub(super) record_pat_syntax: Option<ast::RecordPat>,
pub(super) record_field_syntax: Option<ast::RecordField>, pub(super) record_field_syntax: Option<ast::RecordExprField>,
pub(super) impl_def: Option<ast::ImplDef>, pub(super) impl_def: Option<ast::ImplDef>,
/// FIXME: `ActiveParameter` is string-based, which is very very wrong /// FIXME: `ActiveParameter` is string-based, which is very very wrong
pub(super) active_parameter: Option<ActiveParameter>, pub(super) active_parameter: Option<ActiveParameter>,
@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> {
self.name_ref_syntax = self.name_ref_syntax =
find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); find_node_at_offset(&original_file, name_ref.syntax().text_range().start());
let name_range = name_ref.syntax().text_range(); let name_range = name_ref.syntax().text_range();
if ast::RecordField::for_field_name(&name_ref).is_some() { if ast::RecordExprField::for_field_name(&name_ref).is_some() {
self.record_lit_syntax = self.record_lit_syntax =
self.sema.find_node_at_offset_with_macros(&original_file, offset); self.sema.find_node_at_offset_with_macros(&original_file, offset);
} }
@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> {
.take_while(|it| { .take_while(|it| {
it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR
}) })
.find_map(ast::RecordField::cast); .find_map(ast::RecordExprField::cast);
let parent = match name_ref.syntax().parent() { let parent = match name_ref.syntax().parent() {
Some(it) => it, Some(it) => it,

View file

@ -146,7 +146,7 @@ fn missing_struct_field_fix(
) -> Option<Fix> { ) -> Option<Fix> {
let record_expr = sema.ast(d); let record_expr = sema.ast(d);
let record_lit = ast::RecordLit::cast(record_expr.syntax().parent()?.parent()?)?; let record_lit = ast::RecordExpr::cast(record_expr.syntax().parent()?.parent()?)?;
let def_id = sema.resolve_variant(record_lit)?; let def_id = sema.resolve_variant(record_lit)?;
let module; let module;
let def_file_id; let def_file_id;
@ -263,8 +263,8 @@ fn check_struct_shorthand_initialization(
file_id: FileId, file_id: FileId,
node: &SyntaxNode, node: &SyntaxNode,
) -> Option<()> { ) -> Option<()> {
let record_lit = ast::RecordLit::cast(node.clone())?; let record_lit = ast::RecordExpr::cast(node.clone())?;
let record_field_list = record_lit.record_field_list()?; let record_field_list = record_lit.record_expr_field_list()?;
for record_field in record_field_list.fields() { for record_field in record_field_list.fields() {
if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) { if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
let field_name = name_ref.syntax().text().to_string(); let field_name = name_ref.syntax().text().to_string();

View file

@ -41,7 +41,7 @@ fn try_extend_selection(
MATCH_ARM_LIST, MATCH_ARM_LIST,
RECORD_FIELD_DEF_LIST, RECORD_FIELD_DEF_LIST,
TUPLE_FIELD_DEF_LIST, TUPLE_FIELD_DEF_LIST,
RECORD_FIELD_LIST, RECORD_EXPR_FIELD_LIST,
ENUM_VARIANT_LIST, ENUM_VARIANT_LIST,
USE_TREE_LIST, USE_TREE_LIST,
GENERIC_PARAM_LIST, GENERIC_PARAM_LIST,

View file

@ -87,7 +87,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
RECORD_FIELD_DEF_LIST RECORD_FIELD_DEF_LIST
| RECORD_FIELD_PAT_LIST | RECORD_FIELD_PAT_LIST
| RECORD_FIELD_LIST | RECORD_EXPR_FIELD_LIST
| ITEM_LIST | ITEM_LIST
| EXTERN_ITEM_LIST | EXTERN_ITEM_LIST
| USE_TREE_LIST | USE_TREE_LIST

View file

@ -96,7 +96,7 @@ fn get_chaining_hints(
return None; return None;
} }
if matches!(expr, ast::Expr::RecordLit(_)) { if matches!(expr, ast::Expr::RecordExpr(_)) {
return None; return None;
} }

View file

@ -236,7 +236,7 @@ pub fn classify_name_ref(
} }
} }
if let Some(record_field) = ast::RecordField::for_field_name(name_ref) { if let Some(record_field) = ast::RecordExprField::for_field_name(name_ref) {
if let Some((field, local)) = sema.resolve_record_field(&record_field) { if let Some((field, local)) = sema.resolve_record_field(&record_field) {
let field = Definition::Field(field); let field = Definition::Field(field);
let res = match local { let res = match local {

View file

@ -315,7 +315,7 @@ fn is_record_lit_name_ref(name_ref: &ast::NameRef) -> bool {
name_ref name_ref
.syntax() .syntax()
.ancestors() .ancestors()
.find_map(ast::RecordLit::cast) .find_map(ast::RecordExpr::cast)
.and_then(|l| l.path()) .and_then(|l| l.path())
.and_then(|p| p.segment()) .and_then(|p| p.segment())
.map(|p| p.name_ref().as_ref() == Some(name_ref)) .map(|p| p.name_ref().as_ref() == Some(name_ref))

View file

@ -143,7 +143,7 @@ pub(crate) fn reparser(
let res = match node { let res = match node {
BLOCK_EXPR => expressions::block_expr, BLOCK_EXPR => expressions::block_expr,
RECORD_FIELD_DEF_LIST => items::record_field_def_list, RECORD_FIELD_DEF_LIST => items::record_field_def_list,
RECORD_FIELD_LIST => items::record_field_list, RECORD_EXPR_FIELD_LIST => items::record_field_list,
ENUM_VARIANT_LIST => items::enum_variant_list, ENUM_VARIANT_LIST => items::enum_variant_list,
MATCH_ARM_LIST => items::match_arm_list, MATCH_ARM_LIST => items::match_arm_list,
USE_TREE_LIST => items::use_tree_list, USE_TREE_LIST => items::use_tree_list,

View file

@ -587,7 +587,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
match p.current() { match p.current() {
T!['{'] if !r.forbid_structs => { T!['{'] if !r.forbid_structs => {
record_field_list(p); record_field_list(p);
(m.complete(p, RECORD_LIT), BlockLike::NotBlock) (m.complete(p, RECORD_EXPR), BlockLike::NotBlock)
} }
T![!] if !p.at(T![!=]) => { T![!] if !p.at(T![!=]) => {
let block_like = items::macro_call_after_excl(p); let block_like = items::macro_call_after_excl(p);
@ -627,7 +627,7 @@ pub(crate) fn record_field_list(p: &mut Parser) {
p.expect(T![:]); p.expect(T![:]);
} }
expr(p); expr(p);
m.complete(p, RECORD_FIELD); m.complete(p, RECORD_EXPR_FIELD);
} }
T![.] if p.at(T![..]) => { T![.] if p.at(T![..]) => {
m.abandon(p); m.abandon(p);
@ -648,5 +648,5 @@ pub(crate) fn record_field_list(p: &mut Parser) {
} }
} }
p.expect(T!['}']); p.expect(T!['}']);
m.complete(p, RECORD_FIELD_LIST); m.complete(p, RECORD_EXPR_FIELD_LIST);
} }

View file

@ -188,9 +188,9 @@ pub enum SyntaxKind {
MATCH_ARM_LIST, MATCH_ARM_LIST,
MATCH_ARM, MATCH_ARM,
MATCH_GUARD, MATCH_GUARD,
RECORD_LIT, RECORD_EXPR,
RECORD_FIELD_LIST, RECORD_EXPR_FIELD_LIST,
RECORD_FIELD, RECORD_EXPR_FIELD,
EFFECT_EXPR, EFFECT_EXPR,
BOX_EXPR, BOX_EXPR,
CALL_EXPR, CALL_EXPR,

View file

@ -209,7 +209,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
// Some kinds of nodes have special handling. For everything else, we fall back to default // Some kinds of nodes have special handling. For everything else, we fall back to default
// matching. // matching.
match code.kind() { match code.kind() {
SyntaxKind::RECORD_FIELD_LIST => { SyntaxKind::RECORD_EXPR_FIELD_LIST => {
self.attempt_match_record_field_list(phase, pattern, code) self.attempt_match_record_field_list(phase, pattern, code)
} }
SyntaxKind::TOKEN_TREE => self.attempt_match_token_tree(phase, pattern, code), SyntaxKind::TOKEN_TREE => self.attempt_match_token_tree(phase, pattern, code),
@ -399,7 +399,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
// Build a map keyed by field name. // Build a map keyed by field name.
let mut fields_by_name = FxHashMap::default(); let mut fields_by_name = FxHashMap::default();
for child in code.children() { for child in code.children() {
if let Some(record) = ast::RecordField::cast(child.clone()) { if let Some(record) = ast::RecordExprField::cast(child.clone()) {
if let Some(name) = record.field_name() { if let Some(name) = record.field_name() {
fields_by_name.insert(name.text().clone(), child.clone()); fields_by_name.insert(name.text().clone(), child.clone());
} }

View file

@ -116,18 +116,18 @@ impl ast::AssocItemList {
} }
} }
impl ast::RecordFieldList { impl ast::RecordExprFieldList {
#[must_use] #[must_use]
pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList {
self.insert_field(InsertPosition::Last, field) self.insert_field(InsertPosition::Last, field)
} }
#[must_use] #[must_use]
pub fn insert_field( pub fn insert_field(
&self, &self,
position: InsertPosition<&'_ ast::RecordField>, position: InsertPosition<&'_ ast::RecordExprField>,
field: &ast::RecordField, field: &ast::RecordExprField,
) -> ast::RecordFieldList { ) -> ast::RecordExprFieldList {
let is_multiline = self.syntax().text().contains_char('\n'); let is_multiline = self.syntax().text().contains_char('\n');
let ws; let ws;
let space = if is_multiline { let space = if is_multiline {

View file

@ -412,8 +412,8 @@ fn test_literal_with_attr() {
assert_eq!(lit.token().text(), r#""Hello""#); assert_eq!(lit.token().text(), r#""Hello""#);
} }
impl ast::RecordField { impl ast::RecordExprField {
pub fn parent_record_lit(&self) -> ast::RecordLit { pub fn parent_record_lit(&self) -> ast::RecordExpr {
self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
} }
} }

View file

@ -909,30 +909,32 @@ impl MatchGuard {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordLit { pub struct RecordExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
impl RecordLit { impl RecordExpr {
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> {
support::child(&self.syntax)
}
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldList { pub struct RecordExprFieldList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
impl RecordFieldList { impl RecordExprFieldList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) }
pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordField { pub struct RecordExprField {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
impl ast::AttrsOwner for RecordField {} impl ast::AttrsOwner for RecordExprField {}
impl RecordField { impl RecordExprField {
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@ -1345,7 +1347,7 @@ pub enum Expr {
BlockExpr(BlockExpr), BlockExpr(BlockExpr),
ReturnExpr(ReturnExpr), ReturnExpr(ReturnExpr),
MatchExpr(MatchExpr), MatchExpr(MatchExpr),
RecordLit(RecordLit), RecordExpr(RecordExpr),
CallExpr(CallExpr), CallExpr(CallExpr),
IndexExpr(IndexExpr), IndexExpr(IndexExpr),
MethodCallExpr(MethodCallExpr), MethodCallExpr(MethodCallExpr),
@ -2357,8 +2359,8 @@ impl AstNode for MatchGuard {
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl AstNode for RecordLit { impl AstNode for RecordExpr {
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR }
fn cast(syntax: SyntaxNode) -> Option<Self> { fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) { if Self::can_cast(syntax.kind()) {
Some(Self { syntax }) Some(Self { syntax })
@ -2368,8 +2370,8 @@ impl AstNode for RecordLit {
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl AstNode for RecordFieldList { impl AstNode for RecordExprFieldList {
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST }
fn cast(syntax: SyntaxNode) -> Option<Self> { fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) { if Self::can_cast(syntax.kind()) {
Some(Self { syntax }) Some(Self { syntax })
@ -2379,8 +2381,8 @@ impl AstNode for RecordFieldList {
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl AstNode for RecordField { impl AstNode for RecordExprField {
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD }
fn cast(syntax: SyntaxNode) -> Option<Self> { fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) { if Self::can_cast(syntax.kind()) {
Some(Self { syntax }) Some(Self { syntax })
@ -3119,8 +3121,8 @@ impl From<ReturnExpr> for Expr {
impl From<MatchExpr> for Expr { impl From<MatchExpr> for Expr {
fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) }
} }
impl From<RecordLit> for Expr { impl From<RecordExpr> for Expr {
fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) } fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) }
} }
impl From<CallExpr> for Expr { impl From<CallExpr> for Expr {
fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
@ -3172,7 +3174,7 @@ impl AstNode for Expr {
match kind { match kind {
TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
| LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
| BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_EXPR | CALL_EXPR | INDEX_EXPR
| METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR
| REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => {
true true
@ -3197,7 +3199,7 @@ impl AstNode for Expr {
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }),
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
@ -3234,7 +3236,7 @@ impl AstNode for Expr {
Expr::BlockExpr(it) => &it.syntax, Expr::BlockExpr(it) => &it.syntax,
Expr::ReturnExpr(it) => &it.syntax, Expr::ReturnExpr(it) => &it.syntax,
Expr::MatchExpr(it) => &it.syntax, Expr::MatchExpr(it) => &it.syntax,
Expr::RecordLit(it) => &it.syntax, Expr::RecordExpr(it) => &it.syntax,
Expr::CallExpr(it) => &it.syntax, Expr::CallExpr(it) => &it.syntax,
Expr::IndexExpr(it) => &it.syntax, Expr::IndexExpr(it) => &it.syntax,
Expr::MethodCallExpr(it) => &it.syntax, Expr::MethodCallExpr(it) => &it.syntax,
@ -3893,17 +3895,17 @@ impl std::fmt::Display for MatchGuard {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }
} }
impl std::fmt::Display for RecordLit { impl std::fmt::Display for RecordExpr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }
} }
impl std::fmt::Display for RecordFieldList { impl std::fmt::Display for RecordExprFieldList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }
} }
impl std::fmt::Display for RecordField { impl std::fmt::Display for RecordExprField {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }

View file

@ -64,13 +64,13 @@ pub fn use_item(use_tree: ast::UseTree) -> ast::Use {
ast_from_text(&format!("use {};", use_tree)) ast_from_text(&format!("use {};", use_tree))
} }
pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField {
return match expr { return match expr {
Some(expr) => from_text(&format!("{}: {}", name, expr)), Some(expr) => from_text(&format!("{}: {}", name, expr)),
None => from_text(&name.to_string()), None => from_text(&name.to_string()),
}; };
fn from_text(text: &str) -> ast::RecordField { fn from_text(text: &str) -> ast::RecordExprField {
ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text))
} }
} }

View file

@ -189,11 +189,11 @@ impl ast::StructDef {
} }
} }
impl ast::RecordField { impl ast::RecordExprField {
pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> { pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> {
let candidate = let candidate =
field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| { field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| {
field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast) field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast)
})?; })?;
if candidate.field_name().as_ref() == Some(field_name) { if candidate.field_name().as_ref() == Some(field_name) {
Some(candidate) Some(candidate)

View file

@ -91,7 +91,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
ast::Literal(it) => validate_literal(it, &mut errors), ast::Literal(it) => validate_literal(it, &mut errors),
ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors),
ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors),
ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), &mut errors),
ast::Visibility(it) => validate_visibility(it, &mut errors), ast::Visibility(it) => validate_visibility(it, &mut errors),
ast::RangeExpr(it) => validate_range_expr(it, &mut errors), ast::RangeExpr(it) => validate_range_expr(it, &mut errors),
ast::PathSegment(it) => validate_path_keywords(it, &mut errors), ast::PathSegment(it) => validate_path_keywords(it, &mut errors),

View file

@ -75,16 +75,16 @@ SOURCE_FILE@0..183
IDENT@106..110 "push" IDENT@106..110 "push"
ARG_LIST@110..155 ARG_LIST@110..155
L_PAREN@110..111 "(" L_PAREN@110..111 "("
RECORD_LIT@111..154 RECORD_EXPR@111..154
PATH@111..120 PATH@111..120
PATH_SEGMENT@111..120 PATH_SEGMENT@111..120
NAME_REF@111..120 NAME_REF@111..120
IDENT@111..120 "ScopeData" IDENT@111..120 "ScopeData"
WHITESPACE@120..121 " " WHITESPACE@120..121 " "
RECORD_FIELD_LIST@121..154 RECORD_EXPR_FIELD_LIST@121..154
L_CURLY@121..122 "{" L_CURLY@121..122 "{"
WHITESPACE@122..123 " " WHITESPACE@122..123 " "
RECORD_FIELD@123..135 RECORD_EXPR_FIELD@123..135
NAME_REF@123..129 NAME_REF@123..129
IDENT@123..129 "parent" IDENT@123..129 "parent"
COLON@129..130 ":" COLON@129..130 ":"
@ -96,7 +96,7 @@ SOURCE_FILE@0..183
IDENT@131..135 "None" IDENT@131..135 "None"
COMMA@135..136 "," COMMA@135..136 ","
WHITESPACE@136..137 " " WHITESPACE@136..137 " "
RECORD_FIELD@137..152 RECORD_EXPR_FIELD@137..152
NAME_REF@137..144 NAME_REF@137..144
IDENT@137..144 "entries" IDENT@137..144 "entries"
COLON@144..145 ":" COLON@144..145 ":"

View file

@ -11,16 +11,16 @@ SOURCE_FILE@0..45
BLOCK_EXPR@10..44 BLOCK_EXPR@10..44
L_CURLY@10..11 "{" L_CURLY@10..11 "{"
WHITESPACE@11..16 "\n " WHITESPACE@11..16 "\n "
RECORD_LIT@16..42 RECORD_EXPR@16..42
PATH@16..17 PATH@16..17
PATH_SEGMENT@16..17 PATH_SEGMENT@16..17
NAME_REF@16..17 NAME_REF@16..17
IDENT@16..17 "S" IDENT@16..17 "S"
WHITESPACE@17..18 " " WHITESPACE@17..18 " "
RECORD_FIELD_LIST@18..42 RECORD_EXPR_FIELD_LIST@18..42
L_CURLY@18..19 "{" L_CURLY@18..19 "{"
WHITESPACE@19..20 " " WHITESPACE@19..20 " "
RECORD_FIELD@20..40 RECORD_EXPR_FIELD@20..40
NAME_REF@20..25 NAME_REF@20..25
IDENT@20..25 "field" IDENT@20..25 "field"
WHITESPACE@25..26 " " WHITESPACE@25..26 " "

View file

@ -12,28 +12,28 @@ SOURCE_FILE@0..112
L_CURLY@9..10 "{" L_CURLY@9..10 "{"
WHITESPACE@10..15 "\n " WHITESPACE@10..15 "\n "
EXPR_STMT@15..20 EXPR_STMT@15..20
RECORD_LIT@15..19 RECORD_EXPR@15..19
PATH@15..16 PATH@15..16
PATH_SEGMENT@15..16 PATH_SEGMENT@15..16
NAME_REF@15..16 NAME_REF@15..16
IDENT@15..16 "S" IDENT@15..16 "S"
WHITESPACE@16..17 " " WHITESPACE@16..17 " "
RECORD_FIELD_LIST@17..19 RECORD_EXPR_FIELD_LIST@17..19
L_CURLY@17..18 "{" L_CURLY@17..18 "{"
R_CURLY@18..19 "}" R_CURLY@18..19 "}"
SEMICOLON@19..20 ";" SEMICOLON@19..20 ";"
WHITESPACE@20..25 "\n " WHITESPACE@20..25 "\n "
EXPR_STMT@25..41 EXPR_STMT@25..41
RECORD_LIT@25..40 RECORD_EXPR@25..40
PATH@25..26 PATH@25..26
PATH_SEGMENT@25..26 PATH_SEGMENT@25..26
NAME_REF@25..26 NAME_REF@25..26
IDENT@25..26 "S" IDENT@25..26 "S"
WHITESPACE@26..27 " " WHITESPACE@26..27 " "
RECORD_FIELD_LIST@27..40 RECORD_EXPR_FIELD_LIST@27..40
L_CURLY@27..28 "{" L_CURLY@27..28 "{"
WHITESPACE@28..29 " " WHITESPACE@28..29 " "
RECORD_FIELD@29..30 RECORD_EXPR_FIELD@29..30
PATH_EXPR@29..30 PATH_EXPR@29..30
PATH@29..30 PATH@29..30
PATH_SEGMENT@29..30 PATH_SEGMENT@29..30
@ -41,7 +41,7 @@ SOURCE_FILE@0..112
IDENT@29..30 "x" IDENT@29..30 "x"
COMMA@30..31 "," COMMA@30..31 ","
WHITESPACE@31..32 " " WHITESPACE@31..32 " "
RECORD_FIELD@32..37 RECORD_EXPR_FIELD@32..37
NAME_REF@32..33 NAME_REF@32..33
IDENT@32..33 "y" IDENT@32..33 "y"
COLON@33..34 ":" COLON@33..34 ":"
@ -54,16 +54,16 @@ SOURCE_FILE@0..112
SEMICOLON@40..41 ";" SEMICOLON@40..41 ";"
WHITESPACE@41..46 "\n " WHITESPACE@41..46 "\n "
EXPR_STMT@46..83 EXPR_STMT@46..83
RECORD_LIT@46..82 RECORD_EXPR@46..82
PATH@46..47 PATH@46..47
PATH_SEGMENT@46..47 PATH_SEGMENT@46..47
NAME_REF@46..47 NAME_REF@46..47
IDENT@46..47 "S" IDENT@46..47 "S"
WHITESPACE@47..48 " " WHITESPACE@47..48 " "
RECORD_FIELD_LIST@48..82 RECORD_EXPR_FIELD_LIST@48..82
L_CURLY@48..49 "{" L_CURLY@48..49 "{"
WHITESPACE@49..50 " " WHITESPACE@49..50 " "
RECORD_FIELD@50..51 RECORD_EXPR_FIELD@50..51
PATH_EXPR@50..51 PATH_EXPR@50..51
PATH@50..51 PATH@50..51
PATH_SEGMENT@50..51 PATH_SEGMENT@50..51
@ -71,7 +71,7 @@ SOURCE_FILE@0..112
IDENT@50..51 "x" IDENT@50..51 "x"
COMMA@51..52 "," COMMA@51..52 ","
WHITESPACE@52..53 " " WHITESPACE@52..53 " "
RECORD_FIELD@53..58 RECORD_EXPR_FIELD@53..58
NAME_REF@53..54 NAME_REF@53..54
IDENT@53..54 "y" IDENT@53..54 "y"
COLON@54..55 ":" COLON@54..55 ":"
@ -100,16 +100,16 @@ SOURCE_FILE@0..112
SEMICOLON@82..83 ";" SEMICOLON@82..83 ";"
WHITESPACE@83..88 "\n " WHITESPACE@83..88 "\n "
EXPR_STMT@88..109 EXPR_STMT@88..109
RECORD_LIT@88..108 RECORD_EXPR@88..108
PATH@88..99 PATH@88..99
PATH_SEGMENT@88..99 PATH_SEGMENT@88..99
NAME_REF@88..99 NAME_REF@88..99
IDENT@88..99 "TupleStruct" IDENT@88..99 "TupleStruct"
WHITESPACE@99..100 " " WHITESPACE@99..100 " "
RECORD_FIELD_LIST@100..108 RECORD_EXPR_FIELD_LIST@100..108
L_CURLY@100..101 "{" L_CURLY@100..101 "{"
WHITESPACE@101..102 " " WHITESPACE@101..102 " "
RECORD_FIELD@102..106 RECORD_EXPR_FIELD@102..106
NAME_REF@102..103 NAME_REF@102..103
INT_NUMBER@102..103 "0" INT_NUMBER@102..103 "0"
COLON@103..104 ":" COLON@103..104 ":"

View file

@ -49,14 +49,14 @@ SOURCE_FILE@0..167
WHITESPACE@60..61 " " WHITESPACE@60..61 " "
R_ANGLE@61..62 ">" R_ANGLE@61..62 ">"
WHITESPACE@62..63 " " WHITESPACE@62..63 " "
RECORD_LIT@63..77 RECORD_EXPR@63..77
PATH@63..67 PATH@63..67
PATH_SEGMENT@63..67 PATH_SEGMENT@63..67
NAME_REF@63..67 NAME_REF@63..67
IDENT@63..67 "Test" IDENT@63..67 "Test"
RECORD_FIELD_LIST@67..77 RECORD_EXPR_FIELD_LIST@67..77
L_CURLY@67..68 "{" L_CURLY@67..68 "{"
RECORD_FIELD@68..76 RECORD_EXPR_FIELD@68..76
NAME_REF@68..73 NAME_REF@68..73
IDENT@68..73 "field" IDENT@68..73 "field"
COLON@73..74 ":" COLON@73..74 ":"

View file

@ -72,13 +72,13 @@ SOURCE_FILE@0..97
BLOCK_EXPR@82..90 BLOCK_EXPR@82..90
L_CURLY@82..83 "{" L_CURLY@82..83 "{"
WHITESPACE@83..84 " " WHITESPACE@83..84 " "
RECORD_LIT@84..88 RECORD_EXPR@84..88
PATH@84..85 PATH@84..85
PATH_SEGMENT@84..85 PATH_SEGMENT@84..85
NAME_REF@84..85 NAME_REF@84..85
IDENT@84..85 "S" IDENT@84..85 "S"
WHITESPACE@85..86 " " WHITESPACE@85..86 " "
RECORD_FIELD_LIST@86..88 RECORD_EXPR_FIELD_LIST@86..88
L_CURLY@86..87 "{" L_CURLY@86..87 "{"
R_CURLY@87..88 "}" R_CURLY@87..88 "}"
WHITESPACE@88..89 " " WHITESPACE@88..89 " "

View file

@ -11,16 +11,16 @@ SOURCE_FILE@0..46
BLOCK_EXPR@10..45 BLOCK_EXPR@10..45
L_CURLY@10..11 "{" L_CURLY@10..11 "{"
WHITESPACE@11..16 "\n " WHITESPACE@11..16 "\n "
RECORD_LIT@16..43 RECORD_EXPR@16..43
PATH@16..17 PATH@16..17
PATH_SEGMENT@16..17 PATH_SEGMENT@16..17
NAME_REF@16..17 NAME_REF@16..17
IDENT@16..17 "S" IDENT@16..17 "S"
WHITESPACE@17..18 " " WHITESPACE@17..18 " "
RECORD_FIELD_LIST@18..43 RECORD_EXPR_FIELD_LIST@18..43
L_CURLY@18..19 "{" L_CURLY@18..19 "{"
WHITESPACE@19..20 " " WHITESPACE@19..20 " "
RECORD_FIELD@20..41 RECORD_EXPR_FIELD@20..41
ATTR@20..32 ATTR@20..32
POUND@20..21 "#" POUND@20..21 "#"
L_BRACK@21..22 "[" L_BRACK@21..22 "["

View file

@ -22,14 +22,14 @@ SOURCE_FILE@0..52
WHITESPACE@23..24 " " WHITESPACE@23..24 " "
EQ@24..25 "=" EQ@24..25 "="
WHITESPACE@25..26 " " WHITESPACE@25..26 " "
RECORD_LIT@26..33 RECORD_EXPR@26..33
PATH@26..27 PATH@26..27
PATH_SEGMENT@26..27 PATH_SEGMENT@26..27
NAME_REF@26..27 NAME_REF@26..27
IDENT@26..27 "F" IDENT@26..27 "F"
RECORD_FIELD_LIST@27..33 RECORD_EXPR_FIELD_LIST@27..33
L_CURLY@27..28 "{" L_CURLY@27..28 "{"
RECORD_FIELD@28..32 RECORD_EXPR_FIELD@28..32
NAME_REF@28..29 NAME_REF@28..29
IDENT@28..29 "x" IDENT@28..29 "x"
COLON@29..30 ":" COLON@29..30 ":"

View file

@ -46,16 +46,16 @@ SOURCE_FILE@0..160
BIN_EXPR@107..135 BIN_EXPR@107..135
INDEX_EXPR@107..131 INDEX_EXPR@107..131
FIELD_EXPR@107..128 FIELD_EXPR@107..128
RECORD_LIT@107..124 RECORD_EXPR@107..124
PATH@107..111 PATH@107..111
PATH_SEGMENT@107..111 PATH_SEGMENT@107..111
NAME_REF@107..111 NAME_REF@107..111
IDENT@107..111 "Repr" IDENT@107..111 "Repr"
WHITESPACE@111..112 " " WHITESPACE@111..112 " "
RECORD_FIELD_LIST@112..124 RECORD_EXPR_FIELD_LIST@112..124
L_CURLY@112..113 "{" L_CURLY@112..113 "{"
WHITESPACE@113..114 " " WHITESPACE@113..114 " "
RECORD_FIELD@114..122 RECORD_EXPR_FIELD@114..122
NAME_REF@114..117 NAME_REF@114..117
IDENT@114..117 "raw" IDENT@114..117 "raw"
COLON@117..118 ":" COLON@117..118 ":"
@ -83,14 +83,14 @@ SOURCE_FILE@0..160
WHITESPACE@136..141 "\n " WHITESPACE@136..141 "\n "
EXPR_STMT@141..157 EXPR_STMT@141..157
CALL_EXPR@141..156 CALL_EXPR@141..156
RECORD_LIT@141..154 RECORD_EXPR@141..154
PATH@141..145 PATH@141..145
PATH_SEGMENT@141..145 PATH_SEGMENT@141..145
NAME_REF@141..145 NAME_REF@141..145
IDENT@141..145 "Repr" IDENT@141..145 "Repr"
RECORD_FIELD_LIST@145..154 RECORD_EXPR_FIELD_LIST@145..154
L_CURLY@145..146 "{" L_CURLY@145..146 "{"
RECORD_FIELD@146..153 RECORD_EXPR_FIELD@146..153
NAME_REF@146..149 NAME_REF@146..149
IDENT@146..149 "raw" IDENT@146..149 "raw"
COLON@149..150 ":" COLON@149..150 ":"

View file

@ -159,9 +159,9 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
"MATCH_ARM_LIST", "MATCH_ARM_LIST",
"MATCH_ARM", "MATCH_ARM",
"MATCH_GUARD", "MATCH_GUARD",
"RECORD_LIT", "RECORD_EXPR",
"RECORD_FIELD_LIST", "RECORD_EXPR_FIELD_LIST",
"RECORD_FIELD", "RECORD_EXPR_FIELD",
"EFFECT_EXPR", "EFFECT_EXPR",
"BOX_EXPR", "BOX_EXPR",
// postfix // postfix

View file

@ -82,10 +82,6 @@ StructDef =
| TupleFieldDefList WhereClause? ';' | TupleFieldDefList WhereClause? ';'
) )
UnionDef =
Attr* Visibility? 'union' Name GenericParamList? WhereClause?
RecordFieldDefList
RecordFieldDefList = RecordFieldDefList =
'{' fields:RecordFieldDef* '}' '{' fields:RecordFieldDef* '}'
@ -102,6 +98,11 @@ FieldDefList =
RecordFieldDefList RecordFieldDefList
| TupleFieldDefList | TupleFieldDefList
UnionDef =
Attr* Visibility? 'union' Name GenericParamList? WhereClause?
RecordFieldDefList
EnumDef = EnumDef =
Attr* Visibility? 'enum' Name GenericParamList? WhereClause? Attr* Visibility? 'enum' Name GenericParamList? WhereClause?
variant_list:EnumVariantList variant_list:EnumVariantList
@ -284,16 +285,16 @@ MatchArm =
MatchGuard = MatchGuard =
'if' Expr 'if' Expr
RecordLit = RecordExpr =
Path RecordFieldList Path RecordExprFieldList
RecordFieldList = RecordExprFieldList =
'{' '{'
fields:RecordField* fields:RecordExprField*
('..' spread:Expr)? ('..' spread:Expr)?
'}' '}'
RecordField = RecordExprField =
Attr* NameRef (':' Expr)? Attr* NameRef (':' Expr)?
OrPat = OrPat =
@ -522,7 +523,7 @@ Expr =
| BlockExpr | BlockExpr
| ReturnExpr | ReturnExpr
| MatchExpr | MatchExpr
| RecordLit | RecordExpr
| CallExpr | CallExpr
| IndexExpr | IndexExpr
| MethodCallExpr | MethodCallExpr