mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
Rename RecordLit -> RecordExpr
This commit is contained in:
parent
98ec5f2c21
commit
6f8aa75329
38 changed files with 140 additions and 135 deletions
|
@ -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::PathExpr(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::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
||||
|
|
|
@ -45,7 +45,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
|
|||
target,
|
||||
move |edit| {
|
||||
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(),
|
||||
None => None,
|
||||
};
|
||||
|
|
|
@ -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<()> {
|
||||
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 current_module = ctx.sema.scope(record_field.syntax()).module()?;
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
|
|||
// ```
|
||||
//
|
||||
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<()> {
|
||||
|
@ -56,7 +56,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
|||
|
||||
fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
|
||||
match node.kind() {
|
||||
RECORD_LIT => vec![RECORD_FIELD],
|
||||
RECORD_EXPR => vec![RECORD_EXPR_FIELD],
|
||||
RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT],
|
||||
_ => vec![],
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
|
|||
fn get_field_name(node: &SyntaxNode) -> String {
|
||||
let res = match_ast! {
|
||||
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()),
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
@ -209,7 +209,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -225,7 +228,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -240,7 +243,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
|||
// FIXME: use this instead?
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -422,7 +425,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -440,7 +443,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -453,7 +456,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
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())
|
||||
.record_literal_missing_fields(self.db, literal)
|
||||
.unwrap_or_default()
|
||||
|
|
|
@ -159,7 +159,7 @@ impl SourceAnalyzer {
|
|||
pub(crate) fn resolve_record_field(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
field: &ast::RecordField,
|
||||
field: &ast::RecordExprField,
|
||||
) -> Option<(Field, Option<Local>)> {
|
||||
let expr = field.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())?;
|
||||
if let Some(VariantId::EnumVariantId(variant)) =
|
||||
self.infer.as_ref()?.variant_resolution_for_expr(expr_id)
|
||||
|
@ -284,7 +284,7 @@ impl SourceAnalyzer {
|
|||
pub(crate) fn record_literal_missing_fields(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
literal: &ast::RecordLit,
|
||||
literal: &ast::RecordExpr,
|
||||
) -> Option<Vec<(Field, Type)>> {
|
||||
let krate = self.resolver.krate()?;
|
||||
let body = self.body.as_ref()?;
|
||||
|
@ -358,7 +358,7 @@ impl SourceAnalyzer {
|
|||
pub(crate) fn resolve_variant(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
record_lit: ast::RecordLit,
|
||||
record_lit: ast::RecordExpr,
|
||||
) -> Option<VariantId> {
|
||||
let infer = self.infer.as_ref()?;
|
||||
let expr_id = self.expr_id(db, &record_lit.into())?;
|
||||
|
|
|
@ -216,7 +216,7 @@ pub struct BodySourceMap {
|
|||
expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>,
|
||||
pat_map: FxHashMap<PatSource, PatId>,
|
||||
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>,
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ impl BodySourceMap {
|
|||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,10 +379,10 @@ impl ExprCollector<'_> {
|
|||
let expr = e.expr().map(|e| self.collect_expr(e));
|
||||
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 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
|
||||
.fields()
|
||||
.inspect(|field| field_ptrs.push(AstPtr::new(field)))
|
||||
|
|
|
@ -386,7 +386,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind {
|
|||
MATCH_EXPR => FragmentKind::Expr,
|
||||
MATCH_ARM => FragmentKind::Expr,
|
||||
MATCH_GUARD => FragmentKind::Expr,
|
||||
RECORD_FIELD => FragmentKind::Expr,
|
||||
RECORD_EXPR_FIELD => FragmentKind::Expr,
|
||||
CALL_EXPR => FragmentKind::Expr,
|
||||
INDEX_EXPR => FragmentKind::Expr,
|
||||
METHOD_CALL_EXPR => FragmentKind::Expr,
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag
|
|||
#[derive(Debug)]
|
||||
pub struct NoSuchField {
|
||||
pub file: HirFileId,
|
||||
pub field: AstPtr<ast::RecordField>,
|
||||
pub field: AstPtr<ast::RecordExprField>,
|
||||
}
|
||||
|
||||
impl Diagnostic for NoSuchField {
|
||||
|
@ -47,19 +47,19 @@ impl Diagnostic for NoSuchField {
|
|||
}
|
||||
|
||||
impl AstDiagnostic for NoSuchField {
|
||||
type AST = ast::RecordField;
|
||||
type AST = ast::RecordExprField;
|
||||
|
||||
fn ast(&self, db: &dyn AstDatabase) -> Self::AST {
|
||||
let root = db.parse_or_expand(self.source().file_id).unwrap();
|
||||
let node = self.source().value.to_node(&root);
|
||||
ast::RecordField::cast(node).unwrap()
|
||||
ast::RecordExprField::cast(node).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MissingFields {
|
||||
pub file: HirFileId,
|
||||
pub field_list: AstPtr<ast::RecordFieldList>,
|
||||
pub field_list: AstPtr<ast::RecordExprFieldList>,
|
||||
pub missed_fields: Vec<Name>,
|
||||
}
|
||||
|
||||
|
@ -80,12 +80,12 @@ impl Diagnostic for MissingFields {
|
|||
}
|
||||
|
||||
impl AstDiagnostic for MissingFields {
|
||||
type AST = ast::RecordFieldList;
|
||||
type AST = ast::RecordExprFieldList;
|
||||
|
||||
fn ast(&self, db: &dyn AstDatabase) -> Self::AST {
|
||||
let root = db.parse_or_expand(self.source().file_id).unwrap();
|
||||
let node = self.source().value.to_node(&root);
|
||||
ast::RecordFieldList::cast(node).unwrap()
|
||||
ast::RecordExprFieldList::cast(node).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(id) {
|
||||
let root = source_ptr.file_syntax(db.upcast());
|
||||
if let ast::Expr::RecordLit(record_lit) = &source_ptr.value.to_node(&root) {
|
||||
if let Some(field_list) = record_lit.record_field_list() {
|
||||
if let ast::Expr::RecordExpr(record_lit) = &source_ptr.value.to_node(&root) {
|
||||
if let Some(field_list) = record_lit.record_expr_field_list() {
|
||||
let variant_data = variant_data(db.upcast(), variant_def);
|
||||
let missed_fields = missed_fields
|
||||
.into_iter()
|
||||
|
|
|
@ -37,9 +37,9 @@ pub(crate) struct CompletionContext<'a> {
|
|||
pub(super) name_ref_syntax: Option<ast::NameRef>,
|
||||
pub(super) function_syntax: Option<ast::Fn>,
|
||||
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_field_syntax: Option<ast::RecordField>,
|
||||
pub(super) record_field_syntax: Option<ast::RecordExprField>,
|
||||
pub(super) impl_def: Option<ast::ImplDef>,
|
||||
/// FIXME: `ActiveParameter` is string-based, which is very very wrong
|
||||
pub(super) active_parameter: Option<ActiveParameter>,
|
||||
|
@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> {
|
|||
self.name_ref_syntax =
|
||||
find_node_at_offset(&original_file, name_ref.syntax().text_range().start());
|
||||
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.sema.find_node_at_offset_with_macros(&original_file, offset);
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> {
|
|||
.take_while(|it| {
|
||||
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() {
|
||||
Some(it) => it,
|
||||
|
|
|
@ -146,7 +146,7 @@ fn missing_struct_field_fix(
|
|||
) -> Option<Fix> {
|
||||
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 module;
|
||||
let def_file_id;
|
||||
|
@ -263,8 +263,8 @@ fn check_struct_shorthand_initialization(
|
|||
file_id: FileId,
|
||||
node: &SyntaxNode,
|
||||
) -> Option<()> {
|
||||
let record_lit = ast::RecordLit::cast(node.clone())?;
|
||||
let record_field_list = record_lit.record_field_list()?;
|
||||
let record_lit = ast::RecordExpr::cast(node.clone())?;
|
||||
let record_field_list = record_lit.record_expr_field_list()?;
|
||||
for record_field in record_field_list.fields() {
|
||||
if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
|
||||
let field_name = name_ref.syntax().text().to_string();
|
||||
|
|
|
@ -41,7 +41,7 @@ fn try_extend_selection(
|
|||
MATCH_ARM_LIST,
|
||||
RECORD_FIELD_DEF_LIST,
|
||||
TUPLE_FIELD_DEF_LIST,
|
||||
RECORD_FIELD_LIST,
|
||||
RECORD_EXPR_FIELD_LIST,
|
||||
ENUM_VARIANT_LIST,
|
||||
USE_TREE_LIST,
|
||||
GENERIC_PARAM_LIST,
|
||||
|
|
|
@ -87,7 +87,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
|
|||
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
|
||||
RECORD_FIELD_DEF_LIST
|
||||
| RECORD_FIELD_PAT_LIST
|
||||
| RECORD_FIELD_LIST
|
||||
| RECORD_EXPR_FIELD_LIST
|
||||
| ITEM_LIST
|
||||
| EXTERN_ITEM_LIST
|
||||
| USE_TREE_LIST
|
||||
|
|
|
@ -96,7 +96,7 @@ fn get_chaining_hints(
|
|||
return None;
|
||||
}
|
||||
|
||||
if matches!(expr, ast::Expr::RecordLit(_)) {
|
||||
if matches!(expr, ast::Expr::RecordExpr(_)) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
let field = Definition::Field(field);
|
||||
let res = match local {
|
||||
|
|
|
@ -315,7 +315,7 @@ fn is_record_lit_name_ref(name_ref: &ast::NameRef) -> bool {
|
|||
name_ref
|
||||
.syntax()
|
||||
.ancestors()
|
||||
.find_map(ast::RecordLit::cast)
|
||||
.find_map(ast::RecordExpr::cast)
|
||||
.and_then(|l| l.path())
|
||||
.and_then(|p| p.segment())
|
||||
.map(|p| p.name_ref().as_ref() == Some(name_ref))
|
||||
|
|
|
@ -143,7 +143,7 @@ pub(crate) fn reparser(
|
|||
let res = match node {
|
||||
BLOCK_EXPR => expressions::block_expr,
|
||||
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,
|
||||
MATCH_ARM_LIST => items::match_arm_list,
|
||||
USE_TREE_LIST => items::use_tree_list,
|
||||
|
|
|
@ -587,7 +587,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
|
|||
match p.current() {
|
||||
T!['{'] if !r.forbid_structs => {
|
||||
record_field_list(p);
|
||||
(m.complete(p, RECORD_LIT), BlockLike::NotBlock)
|
||||
(m.complete(p, RECORD_EXPR), BlockLike::NotBlock)
|
||||
}
|
||||
T![!] if !p.at(T![!=]) => {
|
||||
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![:]);
|
||||
}
|
||||
expr(p);
|
||||
m.complete(p, RECORD_FIELD);
|
||||
m.complete(p, RECORD_EXPR_FIELD);
|
||||
}
|
||||
T![.] if p.at(T![..]) => {
|
||||
m.abandon(p);
|
||||
|
@ -648,5 +648,5 @@ pub(crate) fn record_field_list(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
p.expect(T!['}']);
|
||||
m.complete(p, RECORD_FIELD_LIST);
|
||||
m.complete(p, RECORD_EXPR_FIELD_LIST);
|
||||
}
|
||||
|
|
|
@ -188,9 +188,9 @@ pub enum SyntaxKind {
|
|||
MATCH_ARM_LIST,
|
||||
MATCH_ARM,
|
||||
MATCH_GUARD,
|
||||
RECORD_LIT,
|
||||
RECORD_FIELD_LIST,
|
||||
RECORD_FIELD,
|
||||
RECORD_EXPR,
|
||||
RECORD_EXPR_FIELD_LIST,
|
||||
RECORD_EXPR_FIELD,
|
||||
EFFECT_EXPR,
|
||||
BOX_EXPR,
|
||||
CALL_EXPR,
|
||||
|
|
|
@ -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
|
||||
// matching.
|
||||
match code.kind() {
|
||||
SyntaxKind::RECORD_FIELD_LIST => {
|
||||
SyntaxKind::RECORD_EXPR_FIELD_LIST => {
|
||||
self.attempt_match_record_field_list(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.
|
||||
let mut fields_by_name = FxHashMap::default();
|
||||
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() {
|
||||
fields_by_name.insert(name.text().clone(), child.clone());
|
||||
}
|
||||
|
|
|
@ -116,18 +116,18 @@ impl ast::AssocItemList {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::RecordFieldList {
|
||||
impl ast::RecordExprFieldList {
|
||||
#[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)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn insert_field(
|
||||
&self,
|
||||
position: InsertPosition<&'_ ast::RecordField>,
|
||||
field: &ast::RecordField,
|
||||
) -> ast::RecordFieldList {
|
||||
position: InsertPosition<&'_ ast::RecordExprField>,
|
||||
field: &ast::RecordExprField,
|
||||
) -> ast::RecordExprFieldList {
|
||||
let is_multiline = self.syntax().text().contains_char('\n');
|
||||
let ws;
|
||||
let space = if is_multiline {
|
||||
|
|
|
@ -412,8 +412,8 @@ fn test_literal_with_attr() {
|
|||
assert_eq!(lit.token().text(), r#""Hello""#);
|
||||
}
|
||||
|
||||
impl ast::RecordField {
|
||||
pub fn parent_record_lit(&self) -> ast::RecordLit {
|
||||
self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap()
|
||||
impl ast::RecordExprField {
|
||||
pub fn parent_record_lit(&self) -> ast::RecordExpr {
|
||||
self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -909,30 +909,32 @@ impl MatchGuard {
|
|||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct RecordLit {
|
||||
pub struct RecordExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl RecordLit {
|
||||
impl RecordExpr {
|
||||
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)]
|
||||
pub struct RecordFieldList {
|
||||
pub struct RecordExprFieldList {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl RecordFieldList {
|
||||
impl RecordExprFieldList {
|
||||
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 spread(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct RecordField {
|
||||
pub struct RecordExprField {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for RecordField {}
|
||||
impl RecordField {
|
||||
impl ast::AttrsOwner for RecordExprField {}
|
||||
impl RecordExprField {
|
||||
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 expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
|
@ -1345,7 +1347,7 @@ pub enum Expr {
|
|||
BlockExpr(BlockExpr),
|
||||
ReturnExpr(ReturnExpr),
|
||||
MatchExpr(MatchExpr),
|
||||
RecordLit(RecordLit),
|
||||
RecordExpr(RecordExpr),
|
||||
CallExpr(CallExpr),
|
||||
IndexExpr(IndexExpr),
|
||||
MethodCallExpr(MethodCallExpr),
|
||||
|
@ -2357,8 +2359,8 @@ impl AstNode for MatchGuard {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for RecordLit {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT }
|
||||
impl AstNode for RecordExpr {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -2368,8 +2370,8 @@ impl AstNode for RecordLit {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for RecordFieldList {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
|
||||
impl AstNode for RecordExprFieldList {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -2379,8 +2381,8 @@ impl AstNode for RecordFieldList {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for RecordField {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
|
||||
impl AstNode for RecordExprField {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -3119,8 +3121,8 @@ impl From<ReturnExpr> for Expr {
|
|||
impl From<MatchExpr> for Expr {
|
||||
fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) }
|
||||
}
|
||||
impl From<RecordLit> for Expr {
|
||||
fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) }
|
||||
impl From<RecordExpr> for Expr {
|
||||
fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) }
|
||||
}
|
||||
impl From<CallExpr> for Expr {
|
||||
fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
|
||||
|
@ -3172,7 +3174,7 @@ impl AstNode for Expr {
|
|||
match kind {
|
||||
TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
|
||||
| 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
|
||||
| REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => {
|
||||
true
|
||||
|
@ -3197,7 +3199,7 @@ impl AstNode for Expr {
|
|||
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
|
||||
RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { 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 }),
|
||||
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
|
||||
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
|
||||
|
@ -3234,7 +3236,7 @@ impl AstNode for Expr {
|
|||
Expr::BlockExpr(it) => &it.syntax,
|
||||
Expr::ReturnExpr(it) => &it.syntax,
|
||||
Expr::MatchExpr(it) => &it.syntax,
|
||||
Expr::RecordLit(it) => &it.syntax,
|
||||
Expr::RecordExpr(it) => &it.syntax,
|
||||
Expr::CallExpr(it) => &it.syntax,
|
||||
Expr::IndexExpr(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)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for RecordLit {
|
||||
impl std::fmt::Display for RecordExpr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
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 {
|
||||
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 {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ pub fn use_item(use_tree: ast::UseTree) -> ast::Use {
|
|||
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 {
|
||||
Some(expr) => from_text(&format!("{}: {}", name, expr)),
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,11 +189,11 @@ impl ast::StructDef {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::RecordField {
|
||||
pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> {
|
||||
impl ast::RecordExprField {
|
||||
pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> {
|
||||
let candidate =
|
||||
field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| {
|
||||
field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast)
|
||||
field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| {
|
||||
field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast)
|
||||
})?;
|
||||
if candidate.field_name().as_ref() == Some(field_name) {
|
||||
Some(candidate)
|
||||
|
|
|
@ -91,7 +91,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
|
|||
ast::Literal(it) => validate_literal(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::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::RangeExpr(it) => validate_range_expr(it, &mut errors),
|
||||
ast::PathSegment(it) => validate_path_keywords(it, &mut errors),
|
||||
|
|
|
@ -75,16 +75,16 @@ SOURCE_FILE@0..183
|
|||
IDENT@106..110 "push"
|
||||
ARG_LIST@110..155
|
||||
L_PAREN@110..111 "("
|
||||
RECORD_LIT@111..154
|
||||
RECORD_EXPR@111..154
|
||||
PATH@111..120
|
||||
PATH_SEGMENT@111..120
|
||||
NAME_REF@111..120
|
||||
IDENT@111..120 "ScopeData"
|
||||
WHITESPACE@120..121 " "
|
||||
RECORD_FIELD_LIST@121..154
|
||||
RECORD_EXPR_FIELD_LIST@121..154
|
||||
L_CURLY@121..122 "{"
|
||||
WHITESPACE@122..123 " "
|
||||
RECORD_FIELD@123..135
|
||||
RECORD_EXPR_FIELD@123..135
|
||||
NAME_REF@123..129
|
||||
IDENT@123..129 "parent"
|
||||
COLON@129..130 ":"
|
||||
|
@ -96,7 +96,7 @@ SOURCE_FILE@0..183
|
|||
IDENT@131..135 "None"
|
||||
COMMA@135..136 ","
|
||||
WHITESPACE@136..137 " "
|
||||
RECORD_FIELD@137..152
|
||||
RECORD_EXPR_FIELD@137..152
|
||||
NAME_REF@137..144
|
||||
IDENT@137..144 "entries"
|
||||
COLON@144..145 ":"
|
||||
|
|
|
@ -11,16 +11,16 @@ SOURCE_FILE@0..45
|
|||
BLOCK_EXPR@10..44
|
||||
L_CURLY@10..11 "{"
|
||||
WHITESPACE@11..16 "\n "
|
||||
RECORD_LIT@16..42
|
||||
RECORD_EXPR@16..42
|
||||
PATH@16..17
|
||||
PATH_SEGMENT@16..17
|
||||
NAME_REF@16..17
|
||||
IDENT@16..17 "S"
|
||||
WHITESPACE@17..18 " "
|
||||
RECORD_FIELD_LIST@18..42
|
||||
RECORD_EXPR_FIELD_LIST@18..42
|
||||
L_CURLY@18..19 "{"
|
||||
WHITESPACE@19..20 " "
|
||||
RECORD_FIELD@20..40
|
||||
RECORD_EXPR_FIELD@20..40
|
||||
NAME_REF@20..25
|
||||
IDENT@20..25 "field"
|
||||
WHITESPACE@25..26 " "
|
||||
|
|
|
@ -12,28 +12,28 @@ SOURCE_FILE@0..112
|
|||
L_CURLY@9..10 "{"
|
||||
WHITESPACE@10..15 "\n "
|
||||
EXPR_STMT@15..20
|
||||
RECORD_LIT@15..19
|
||||
RECORD_EXPR@15..19
|
||||
PATH@15..16
|
||||
PATH_SEGMENT@15..16
|
||||
NAME_REF@15..16
|
||||
IDENT@15..16 "S"
|
||||
WHITESPACE@16..17 " "
|
||||
RECORD_FIELD_LIST@17..19
|
||||
RECORD_EXPR_FIELD_LIST@17..19
|
||||
L_CURLY@17..18 "{"
|
||||
R_CURLY@18..19 "}"
|
||||
SEMICOLON@19..20 ";"
|
||||
WHITESPACE@20..25 "\n "
|
||||
EXPR_STMT@25..41
|
||||
RECORD_LIT@25..40
|
||||
RECORD_EXPR@25..40
|
||||
PATH@25..26
|
||||
PATH_SEGMENT@25..26
|
||||
NAME_REF@25..26
|
||||
IDENT@25..26 "S"
|
||||
WHITESPACE@26..27 " "
|
||||
RECORD_FIELD_LIST@27..40
|
||||
RECORD_EXPR_FIELD_LIST@27..40
|
||||
L_CURLY@27..28 "{"
|
||||
WHITESPACE@28..29 " "
|
||||
RECORD_FIELD@29..30
|
||||
RECORD_EXPR_FIELD@29..30
|
||||
PATH_EXPR@29..30
|
||||
PATH@29..30
|
||||
PATH_SEGMENT@29..30
|
||||
|
@ -41,7 +41,7 @@ SOURCE_FILE@0..112
|
|||
IDENT@29..30 "x"
|
||||
COMMA@30..31 ","
|
||||
WHITESPACE@31..32 " "
|
||||
RECORD_FIELD@32..37
|
||||
RECORD_EXPR_FIELD@32..37
|
||||
NAME_REF@32..33
|
||||
IDENT@32..33 "y"
|
||||
COLON@33..34 ":"
|
||||
|
@ -54,16 +54,16 @@ SOURCE_FILE@0..112
|
|||
SEMICOLON@40..41 ";"
|
||||
WHITESPACE@41..46 "\n "
|
||||
EXPR_STMT@46..83
|
||||
RECORD_LIT@46..82
|
||||
RECORD_EXPR@46..82
|
||||
PATH@46..47
|
||||
PATH_SEGMENT@46..47
|
||||
NAME_REF@46..47
|
||||
IDENT@46..47 "S"
|
||||
WHITESPACE@47..48 " "
|
||||
RECORD_FIELD_LIST@48..82
|
||||
RECORD_EXPR_FIELD_LIST@48..82
|
||||
L_CURLY@48..49 "{"
|
||||
WHITESPACE@49..50 " "
|
||||
RECORD_FIELD@50..51
|
||||
RECORD_EXPR_FIELD@50..51
|
||||
PATH_EXPR@50..51
|
||||
PATH@50..51
|
||||
PATH_SEGMENT@50..51
|
||||
|
@ -71,7 +71,7 @@ SOURCE_FILE@0..112
|
|||
IDENT@50..51 "x"
|
||||
COMMA@51..52 ","
|
||||
WHITESPACE@52..53 " "
|
||||
RECORD_FIELD@53..58
|
||||
RECORD_EXPR_FIELD@53..58
|
||||
NAME_REF@53..54
|
||||
IDENT@53..54 "y"
|
||||
COLON@54..55 ":"
|
||||
|
@ -100,16 +100,16 @@ SOURCE_FILE@0..112
|
|||
SEMICOLON@82..83 ";"
|
||||
WHITESPACE@83..88 "\n "
|
||||
EXPR_STMT@88..109
|
||||
RECORD_LIT@88..108
|
||||
RECORD_EXPR@88..108
|
||||
PATH@88..99
|
||||
PATH_SEGMENT@88..99
|
||||
NAME_REF@88..99
|
||||
IDENT@88..99 "TupleStruct"
|
||||
WHITESPACE@99..100 " "
|
||||
RECORD_FIELD_LIST@100..108
|
||||
RECORD_EXPR_FIELD_LIST@100..108
|
||||
L_CURLY@100..101 "{"
|
||||
WHITESPACE@101..102 " "
|
||||
RECORD_FIELD@102..106
|
||||
RECORD_EXPR_FIELD@102..106
|
||||
NAME_REF@102..103
|
||||
INT_NUMBER@102..103 "0"
|
||||
COLON@103..104 ":"
|
||||
|
|
|
@ -49,14 +49,14 @@ SOURCE_FILE@0..167
|
|||
WHITESPACE@60..61 " "
|
||||
R_ANGLE@61..62 ">"
|
||||
WHITESPACE@62..63 " "
|
||||
RECORD_LIT@63..77
|
||||
RECORD_EXPR@63..77
|
||||
PATH@63..67
|
||||
PATH_SEGMENT@63..67
|
||||
NAME_REF@63..67
|
||||
IDENT@63..67 "Test"
|
||||
RECORD_FIELD_LIST@67..77
|
||||
RECORD_EXPR_FIELD_LIST@67..77
|
||||
L_CURLY@67..68 "{"
|
||||
RECORD_FIELD@68..76
|
||||
RECORD_EXPR_FIELD@68..76
|
||||
NAME_REF@68..73
|
||||
IDENT@68..73 "field"
|
||||
COLON@73..74 ":"
|
||||
|
|
|
@ -72,13 +72,13 @@ SOURCE_FILE@0..97
|
|||
BLOCK_EXPR@82..90
|
||||
L_CURLY@82..83 "{"
|
||||
WHITESPACE@83..84 " "
|
||||
RECORD_LIT@84..88
|
||||
RECORD_EXPR@84..88
|
||||
PATH@84..85
|
||||
PATH_SEGMENT@84..85
|
||||
NAME_REF@84..85
|
||||
IDENT@84..85 "S"
|
||||
WHITESPACE@85..86 " "
|
||||
RECORD_FIELD_LIST@86..88
|
||||
RECORD_EXPR_FIELD_LIST@86..88
|
||||
L_CURLY@86..87 "{"
|
||||
R_CURLY@87..88 "}"
|
||||
WHITESPACE@88..89 " "
|
||||
|
|
|
@ -11,16 +11,16 @@ SOURCE_FILE@0..46
|
|||
BLOCK_EXPR@10..45
|
||||
L_CURLY@10..11 "{"
|
||||
WHITESPACE@11..16 "\n "
|
||||
RECORD_LIT@16..43
|
||||
RECORD_EXPR@16..43
|
||||
PATH@16..17
|
||||
PATH_SEGMENT@16..17
|
||||
NAME_REF@16..17
|
||||
IDENT@16..17 "S"
|
||||
WHITESPACE@17..18 " "
|
||||
RECORD_FIELD_LIST@18..43
|
||||
RECORD_EXPR_FIELD_LIST@18..43
|
||||
L_CURLY@18..19 "{"
|
||||
WHITESPACE@19..20 " "
|
||||
RECORD_FIELD@20..41
|
||||
RECORD_EXPR_FIELD@20..41
|
||||
ATTR@20..32
|
||||
POUND@20..21 "#"
|
||||
L_BRACK@21..22 "["
|
||||
|
|
|
@ -22,14 +22,14 @@ SOURCE_FILE@0..52
|
|||
WHITESPACE@23..24 " "
|
||||
EQ@24..25 "="
|
||||
WHITESPACE@25..26 " "
|
||||
RECORD_LIT@26..33
|
||||
RECORD_EXPR@26..33
|
||||
PATH@26..27
|
||||
PATH_SEGMENT@26..27
|
||||
NAME_REF@26..27
|
||||
IDENT@26..27 "F"
|
||||
RECORD_FIELD_LIST@27..33
|
||||
RECORD_EXPR_FIELD_LIST@27..33
|
||||
L_CURLY@27..28 "{"
|
||||
RECORD_FIELD@28..32
|
||||
RECORD_EXPR_FIELD@28..32
|
||||
NAME_REF@28..29
|
||||
IDENT@28..29 "x"
|
||||
COLON@29..30 ":"
|
||||
|
|
|
@ -46,16 +46,16 @@ SOURCE_FILE@0..160
|
|||
BIN_EXPR@107..135
|
||||
INDEX_EXPR@107..131
|
||||
FIELD_EXPR@107..128
|
||||
RECORD_LIT@107..124
|
||||
RECORD_EXPR@107..124
|
||||
PATH@107..111
|
||||
PATH_SEGMENT@107..111
|
||||
NAME_REF@107..111
|
||||
IDENT@107..111 "Repr"
|
||||
WHITESPACE@111..112 " "
|
||||
RECORD_FIELD_LIST@112..124
|
||||
RECORD_EXPR_FIELD_LIST@112..124
|
||||
L_CURLY@112..113 "{"
|
||||
WHITESPACE@113..114 " "
|
||||
RECORD_FIELD@114..122
|
||||
RECORD_EXPR_FIELD@114..122
|
||||
NAME_REF@114..117
|
||||
IDENT@114..117 "raw"
|
||||
COLON@117..118 ":"
|
||||
|
@ -83,14 +83,14 @@ SOURCE_FILE@0..160
|
|||
WHITESPACE@136..141 "\n "
|
||||
EXPR_STMT@141..157
|
||||
CALL_EXPR@141..156
|
||||
RECORD_LIT@141..154
|
||||
RECORD_EXPR@141..154
|
||||
PATH@141..145
|
||||
PATH_SEGMENT@141..145
|
||||
NAME_REF@141..145
|
||||
IDENT@141..145 "Repr"
|
||||
RECORD_FIELD_LIST@145..154
|
||||
RECORD_EXPR_FIELD_LIST@145..154
|
||||
L_CURLY@145..146 "{"
|
||||
RECORD_FIELD@146..153
|
||||
RECORD_EXPR_FIELD@146..153
|
||||
NAME_REF@146..149
|
||||
IDENT@146..149 "raw"
|
||||
COLON@149..150 ":"
|
||||
|
|
|
@ -159,9 +159,9 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
|
|||
"MATCH_ARM_LIST",
|
||||
"MATCH_ARM",
|
||||
"MATCH_GUARD",
|
||||
"RECORD_LIT",
|
||||
"RECORD_FIELD_LIST",
|
||||
"RECORD_FIELD",
|
||||
"RECORD_EXPR",
|
||||
"RECORD_EXPR_FIELD_LIST",
|
||||
"RECORD_EXPR_FIELD",
|
||||
"EFFECT_EXPR",
|
||||
"BOX_EXPR",
|
||||
// postfix
|
||||
|
|
|
@ -285,16 +285,16 @@ MatchArm =
|
|||
MatchGuard =
|
||||
'if' Expr
|
||||
|
||||
RecordLit =
|
||||
Path RecordFieldList
|
||||
RecordExpr =
|
||||
Path RecordExprFieldList
|
||||
|
||||
RecordFieldList =
|
||||
RecordExprFieldList =
|
||||
'{'
|
||||
fields:RecordField*
|
||||
fields:RecordExprField*
|
||||
('..' spread:Expr)?
|
||||
'}'
|
||||
|
||||
RecordField =
|
||||
RecordExprField =
|
||||
Attr* NameRef (':' Expr)?
|
||||
|
||||
OrPat =
|
||||
|
@ -523,7 +523,7 @@ Expr =
|
|||
| BlockExpr
|
||||
| ReturnExpr
|
||||
| MatchExpr
|
||||
| RecordLit
|
||||
| RecordExpr
|
||||
| CallExpr
|
||||
| IndexExpr
|
||||
| MethodCallExpr
|
||||
|
|
Loading…
Reference in a new issue