1731: rename pos_field -> tuple_field r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-08-23 14:01:06 +00:00 committed by GitHub
commit a832a2f7dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 640 additions and 634 deletions

View file

@ -93,15 +93,15 @@ impl<N: AstNode> AstEditor<N> {
}
}
impl AstEditor<ast::NamedFieldList> {
pub fn append_field(&mut self, field: &ast::NamedField) {
impl AstEditor<ast::RecordFieldList> {
pub fn append_field(&mut self, field: &ast::RecordField) {
self.insert_field(InsertPosition::Last, field)
}
pub fn insert_field(
&mut self,
position: InsertPosition<&'_ ast::NamedField>,
field: &ast::NamedField,
position: InsertPosition<&'_ ast::RecordField>,
field: &ast::RecordField,
) {
let is_multiline = self.ast().syntax().text().contains_char('\n');
let ws;
@ -245,16 +245,16 @@ pub struct AstBuilder<N: AstNode> {
_phantom: std::marker::PhantomData<N>,
}
impl AstBuilder<ast::NamedField> {
pub fn from_name(name: &Name) -> ast::NamedField {
impl AstBuilder<ast::RecordField> {
pub fn from_name(name: &Name) -> ast::RecordField {
ast_node_from_file_text(&format!("fn f() {{ S {{ {}: (), }} }}", name))
}
fn from_text(text: &str) -> ast::NamedField {
fn from_text(text: &str) -> ast::RecordField {
ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text))
}
pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::NamedField {
pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::RecordField {
match expr {
Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())),
None => Self::from_text(&name.syntax().to_string()),
@ -336,12 +336,12 @@ impl AstBuilder<ast::TupleStructPat> {
}
}
impl AstBuilder<ast::StructPat> {
fn from_text(text: &str) -> ast::StructPat {
impl AstBuilder<ast::RecordPat> {
fn from_text(text: &str) -> ast::RecordPat {
ast_node_from_file_text(&format!("fn f({}: ())", text))
}
pub fn from_pieces(path: &ast::Path, pats: impl Iterator<Item = ast::Pat>) -> ast::StructPat {
pub fn from_pieces(path: &ast::Path, pats: impl Iterator<Item = ast::Pat>) -> ast::RecordPat {
let pats_str = pats.map(|p| p.syntax().to_string()).collect::<Vec<_>>().join(", ");
Self::from_text(&format!("{}{{ {} }}", path.syntax(), pats_str))
}

View file

@ -38,7 +38,7 @@ fn add_vis(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
(vis_offset(&parent), keyword.text_range())
} else {
let ident = ctx.token_at_offset().find(|leaf| leaf.kind() == IDENT)?;
let field = ident.parent().ancestors().find_map(ast::NamedFieldDef::cast)?;
let field = ident.parent().ancestors().find_map(ast::RecordFieldDef::cast)?;
if field.name()?.syntax().text_range() != ident.text_range() && field.visibility().is_some()
{
return None;

View file

@ -78,7 +78,7 @@ fn build_pat(var: ast::EnumVariant) -> Option<ast::Pat> {
let pats = field_list
.fields()
.map(|f| AstBuilder::<ast::BindPat>::from_name(&f.name().unwrap()).into());
AstBuilder::<ast::StructPat>::from_pieces(path, pats).into()
AstBuilder::<ast::RecordPat>::from_pieces(path, pats).into()
}
ast::StructKind::Unit => AstBuilder::<ast::PathPat>::from_path(path).into(),
};

View file

@ -318,8 +318,8 @@ pub struct StructField {
#[derive(Debug)]
pub enum FieldSource {
Named(ast::NamedFieldDef),
Pos(ast::PosFieldDef),
Named(ast::RecordFieldDef),
Pos(ast::TupleFieldDef),
}
impl StructField {

View file

@ -79,7 +79,7 @@ impl<'a> DiagnosticSink<'a> {
#[derive(Debug)]
pub struct NoSuchField {
pub file: HirFileId,
pub field: AstPtr<ast::NamedField>,
pub field: AstPtr<ast::RecordField>,
}
impl Diagnostic for NoSuchField {
@ -118,7 +118,7 @@ impl Diagnostic for UnresolvedModule {
#[derive(Debug)]
pub struct MissingFields {
pub file: HirFileId,
pub field_list: AstPtr<ast::NamedFieldList>,
pub field_list: AstPtr<ast::RecordFieldList>,
pub missed_fields: Vec<Name>,
}
@ -135,11 +135,11 @@ impl Diagnostic for MissingFields {
}
impl AstDiagnostic for MissingFields {
type AST = ast::NamedFieldList;
type AST = ast::RecordFieldList;
fn ast(&self, db: &impl HirDatabase) -> Self::AST {
let root = db.parse_or_expand(self.source().file_id).unwrap();
let node = self.source().ast.to_node(&root);
ast::NamedFieldList::cast(node).unwrap()
ast::RecordFieldList::cast(node).unwrap()
}
}

View file

@ -60,7 +60,7 @@ pub struct BodySourceMap {
expr_map_back: ArenaMap<ExprId, SyntaxNodePtr>,
pat_map: FxHashMap<PatPtr, PatId>,
pat_map_back: ArenaMap<PatId, PatPtr>,
field_map: FxHashMap<(ExprId, usize), AstPtr<ast::NamedField>>,
field_map: FxHashMap<(ExprId, usize), AstPtr<ast::RecordField>>,
}
type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>;
@ -148,7 +148,7 @@ impl BodySourceMap {
self.pat_map.get(&Either::A(AstPtr::new(node))).cloned()
}
pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::NamedField> {
pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::RecordField> {
self.field_map[&(expr, field)]
}
}
@ -210,9 +210,9 @@ pub enum Expr {
Return {
expr: Option<ExprId>,
},
StructLit {
RecordLit {
path: Option<Path>,
fields: Vec<StructLitField>,
fields: Vec<RecordLitField>,
spread: Option<ExprId>,
},
Field {
@ -316,7 +316,7 @@ pub struct MatchArm {
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct StructLitField {
pub struct RecordLitField {
pub name: Name,
pub expr: ExprId,
}
@ -388,7 +388,7 @@ impl Expr {
f(*expr);
}
}
Expr::StructLit { fields, spread, .. } => {
Expr::RecordLit { fields, spread, .. } => {
for field in fields {
f(field.expr);
}
@ -474,7 +474,7 @@ impl BindingAnnotation {
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct FieldPat {
pub struct RecordFieldPat {
pub(crate) name: Name,
pub(crate) pat: PatId,
}
@ -487,7 +487,7 @@ pub enum Pat {
Tuple(Vec<PatId>),
Struct {
path: Option<Path>,
args: Vec<FieldPat>,
args: Vec<RecordFieldPat>,
// FIXME: 'ellipsis' option
},
Range {
@ -746,14 +746,14 @@ where
let expr = e.expr().map(|e| self.collect_expr(e));
self.alloc_expr(Expr::Return { expr }, syntax_ptr)
}
ast::Expr::StructLit(e) => {
ast::Expr::RecordLit(e) => {
let path = e.path().and_then(Path::from_ast);
let mut field_ptrs = Vec::new();
let struct_lit = if let Some(nfl) = e.named_field_list() {
let record_lit = if let Some(nfl) = e.record_field_list() {
let fields = nfl
.fields()
.inspect(|field| field_ptrs.push(AstPtr::new(field)))
.map(|field| StructLitField {
.map(|field| RecordLitField {
name: field
.name_ref()
.map(|nr| nr.as_name())
@ -776,12 +776,12 @@ where
})
.collect();
let spread = nfl.spread().map(|s| self.collect_expr(s));
Expr::StructLit { path, fields, spread }
Expr::RecordLit { path, fields, spread }
} else {
Expr::StructLit { path, fields: Vec::new(), spread: None }
Expr::RecordLit { path, fields: Vec::new(), spread: None }
};
let res = self.alloc_expr(struct_lit, syntax_ptr);
let res = self.alloc_expr(record_lit, syntax_ptr);
for (i, ptr) in field_ptrs.into_iter().enumerate() {
self.source_map.field_map.insert((res, i), ptr);
}
@ -994,25 +994,25 @@ where
Pat::Tuple(args)
}
ast::Pat::PlaceholderPat(_) => Pat::Wild,
ast::Pat::StructPat(p) => {
ast::Pat::RecordPat(p) => {
let path = p.path().and_then(Path::from_ast);
let field_pat_list =
p.field_pat_list().expect("every struct should have a field list");
let mut fields: Vec<_> = field_pat_list
let record_field_pat_list =
p.record_field_pat_list().expect("every struct should have a field list");
let mut fields: Vec<_> = record_field_pat_list
.bind_pats()
.filter_map(|bind_pat| {
let ast_pat =
ast::Pat::cast(bind_pat.syntax().clone()).expect("bind pat is a pat");
let pat = self.collect_pat(ast_pat);
let name = bind_pat.name()?.as_name();
Some(FieldPat { name, pat })
Some(RecordFieldPat { name, pat })
})
.collect();
let iter = field_pat_list.field_pats().filter_map(|f| {
let iter = record_field_pat_list.record_field_pats().filter_map(|f| {
let ast_pat = f.pat()?;
let pat = self.collect_pat(ast_pat);
let name = f.name()?.as_name();
Some(FieldPat { name, pat })
Some(RecordFieldPat { name, pat })
});
fields.extend(iter);

View file

@ -1,9 +1,9 @@
use rustc_hash::FxHashSet;
use std::sync::Arc;
use ra_syntax::ast::{AstNode, StructLit};
use ra_syntax::ast::{AstNode, RecordLit};
use super::{Expr, ExprId, StructLitField};
use super::{Expr, ExprId, RecordLitField};
use crate::{
adt::AdtDef,
diagnostics::{DiagnosticSink, MissingFields},
@ -30,17 +30,17 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) {
let body = self.func.body(db);
for e in body.exprs() {
if let (id, Expr::StructLit { path, fields, spread }) = e {
self.validate_struct_literal(id, path, fields, *spread, db);
if let (id, Expr::RecordLit { path, fields, spread }) = e {
self.validate_record_literal(id, path, fields, *spread, db);
}
}
}
fn validate_struct_literal(
fn validate_record_literal(
&mut self,
id: ExprId,
_path: &Option<Path>,
fields: &[StructLitField],
fields: &[RecordLitField],
spread: Option<ExprId>,
db: &impl HirDatabase,
) {
@ -76,8 +76,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
if let Some(field_list_node) = source_map
.expr_syntax(id)
.map(|ptr| ptr.to_node(source_file.syntax()))
.and_then(StructLit::cast)
.and_then(|lit| lit.named_field_list())
.and_then(RecordLit::cast)
.and_then(|lit| lit.record_field_list())
{
let field_list_ptr = AstPtr::new(&field_list_node);
self.sink.push(MissingFields {

View file

@ -278,13 +278,13 @@ impl SourceAnalyzer {
self.infer.as_ref()?.field_resolution(expr_id)
}
pub fn resolve_struct_literal(&self, struct_lit: &ast::StructLit) -> Option<crate::VariantDef> {
let expr_id = self.body_source_map.as_ref()?.node_expr(&struct_lit.clone().into())?;
pub fn resolve_record_literal(&self, record_lit: &ast::RecordLit) -> Option<crate::VariantDef> {
let expr_id = self.body_source_map.as_ref()?.node_expr(&record_lit.clone().into())?;
self.infer.as_ref()?.variant_resolution_for_expr(expr_id)
}
pub fn resolve_struct_pattern(&self, struct_pat: &ast::StructPat) -> Option<crate::VariantDef> {
let pat_id = self.body_source_map.as_ref()?.node_pat(&struct_pat.clone().into())?;
pub fn resolve_record_pattern(&self, record_pat: &ast::RecordPat) -> Option<crate::VariantDef> {
let pat_id = self.body_source_map.as_ref()?.node_pat(&record_pat.clone().into())?;
self.infer.as_ref()?.variant_resolution_for_pat(pat_id)
}

View file

@ -37,8 +37,8 @@ use crate::{
code_model::{ModuleDef::Trait, TypeAlias},
diagnostics::DiagnosticSink,
expr::{
self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, FieldPat, Literal, Pat,
PatId, Statement, UnaryOp,
self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, Literal, Pat, PatId,
RecordFieldPat, Statement, UnaryOp,
},
generics::{GenericParams, HasGenericParams},
name,
@ -705,10 +705,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
ty
}
fn infer_struct_pat(
fn infer_record_pat(
&mut self,
path: Option<&Path>,
subpats: &[FieldPat],
subpats: &[RecordFieldPat],
expected: &Ty,
default_bm: BindingMode,
id: PatId,
@ -800,7 +800,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm)
}
Pat::Struct { path: ref p, args: ref fields } => {
self.infer_struct_pat(p.as_ref(), fields, expected, default_bm, pat)
self.infer_record_pat(p.as_ref(), fields, expected, default_bm, pat)
}
Pat::Path(path) => {
// FIXME use correct resolver for the surrounding expression
@ -1103,7 +1103,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
}
Ty::simple(TypeCtor::Never)
}
Expr::StructLit { path, fields, spread } => {
Expr::RecordLit { path, fields, spread } => {
let (ty, def_id) = self.resolve_variant(path.as_ref());
if let Some(variant) = def_id {
self.write_variant_resolution(tgt_expr.into(), variant);

View file

@ -3,8 +3,8 @@ mod completion_context;
mod presentation;
mod complete_dot;
mod complete_struct_literal;
mod complete_struct_pattern;
mod complete_record_literal;
mod complete_record_pattern;
mod complete_pattern;
mod complete_fn_param;
mod complete_keyword;
@ -65,8 +65,8 @@ pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Opti
complete_path::complete_path(&mut acc, &ctx);
complete_scope::complete_scope(&mut acc, &ctx);
complete_dot::complete_dot(&mut acc, &ctx);
complete_struct_literal::complete_struct_literal(&mut acc, &ctx);
complete_struct_pattern::complete_struct_pattern(&mut acc, &ctx);
complete_record_literal::complete_record_literal(&mut acc, &ctx);
complete_record_pattern::complete_record_pattern(&mut acc, &ctx);
complete_pattern::complete_pattern(&mut acc, &ctx);
complete_postfix::complete_postfix(&mut acc, &ctx);
Some(acc)

View file

@ -45,7 +45,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
// FIXME unions
TypeCtor::Tuple { .. } => {
for (i, ty) in a_ty.parameters.iter().enumerate() {
acc.add_pos_field(ctx, i, ty);
acc.add_tuple_field(ctx, i, ty);
}
}
_ => {}

View file

@ -3,11 +3,11 @@ use hir::Substs;
use crate::completion::{CompletionContext, Completions};
/// Complete fields in fields literals.
pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) {
let (ty, variant) = match ctx.struct_lit_syntax.as_ref().and_then(|it| {
pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionContext) {
let (ty, variant) = match ctx.record_lit_syntax.as_ref().and_then(|it| {
Some((
ctx.analyzer.type_of(ctx.db, &it.clone().into())?,
ctx.analyzer.resolve_struct_literal(it)?,
ctx.analyzer.resolve_record_literal(it)?,
))
}) {
Some(it) => it,
@ -30,7 +30,7 @@ mod tests {
}
#[test]
fn test_struct_literal_field() {
fn test_record_literal_field() {
let completions = complete(
r"
struct A { the_field: u32 }
@ -54,7 +54,7 @@ mod tests {
}
#[test]
fn test_struct_literal_enum_variant() {
fn test_record_literal_enum_variant() {
let completions = complete(
r"
enum E {
@ -80,7 +80,7 @@ mod tests {
}
#[test]
fn test_struct_literal_two_structs() {
fn test_record_literal_two_structs() {
let completions = complete(
r"
struct A { a: u32 }
@ -106,7 +106,7 @@ mod tests {
}
#[test]
fn test_struct_literal_generic_struct() {
fn test_record_literal_generic_struct() {
let completions = complete(
r"
struct A<T> { a: T }

View file

@ -2,11 +2,11 @@ use hir::Substs;
use crate::completion::{CompletionContext, Completions};
pub(super) fn complete_struct_pattern(acc: &mut Completions, ctx: &CompletionContext) {
let (ty, variant) = match ctx.struct_lit_pat.as_ref().and_then(|it| {
pub(super) fn complete_record_pattern(acc: &mut Completions, ctx: &CompletionContext) {
let (ty, variant) = match ctx.record_lit_pat.as_ref().and_then(|it| {
Some((
ctx.analyzer.type_of_pat(ctx.db, &it.clone().into())?,
ctx.analyzer.resolve_struct_pattern(it)?,
ctx.analyzer.resolve_record_pattern(it)?,
))
}) {
Some(it) => it,
@ -29,7 +29,7 @@ mod tests {
}
#[test]
fn test_struct_pattern_field() {
fn test_record_pattern_field() {
let completions = complete(
r"
struct S { foo: u32 }
@ -56,7 +56,7 @@ mod tests {
}
#[test]
fn test_struct_pattern_enum_variant() {
fn test_record_pattern_enum_variant() {
let completions = complete(
r"
enum E {

View file

@ -20,8 +20,8 @@ pub(crate) struct CompletionContext<'a> {
pub(super) module: Option<hir::Module>,
pub(super) function_syntax: Option<ast::FnDef>,
pub(super) use_item_syntax: Option<ast::UseItem>,
pub(super) struct_lit_syntax: Option<ast::StructLit>,
pub(super) struct_lit_pat: Option<ast::StructPat>,
pub(super) record_lit_syntax: Option<ast::RecordLit>,
pub(super) record_lit_pat: Option<ast::RecordPat>,
pub(super) is_param: bool,
/// If a name-binding or reference to a const in a pattern.
/// Irrefutable patterns (like let) are excluded.
@ -60,8 +60,8 @@ impl<'a> CompletionContext<'a> {
module,
function_syntax: None,
use_item_syntax: None,
struct_lit_syntax: None,
struct_lit_pat: None,
record_lit_syntax: None,
record_lit_pat: None,
is_param: false,
is_pat_binding: false,
is_trivial_path: false,
@ -120,8 +120,8 @@ impl<'a> CompletionContext<'a> {
self.is_param = true;
return;
}
if name.syntax().ancestors().find_map(ast::FieldPatList::cast).is_some() {
self.struct_lit_pat =
if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() {
self.record_lit_pat =
find_node_at_offset(original_parse.tree().syntax(), self.offset);
}
}
@ -129,8 +129,8 @@ impl<'a> CompletionContext<'a> {
fn classify_name_ref(&mut self, original_file: SourceFile, name_ref: ast::NameRef) {
let name_range = name_ref.syntax().text_range();
if name_ref.syntax().parent().and_then(ast::NamedField::cast).is_some() {
self.struct_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);
if name_ref.syntax().parent().and_then(ast::RecordField::cast).is_some() {
self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);
}
let top_node = name_ref

View file

@ -28,7 +28,7 @@ impl Completions {
.add_to(self);
}
pub(crate) fn add_pos_field(&mut self, ctx: &CompletionContext, field: usize, ty: &hir::Ty) {
pub(crate) fn add_tuple_field(&mut self, ctx: &CompletionContext, field: usize, ty: &hir::Ty) {
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), field.to_string())
.kind(CompletionItemKind::Field)
.detail(ty.display(ctx.db).to_string())

View file

@ -9,7 +9,7 @@ use ra_assists::ast_editor::{AstBuilder, AstEditor};
use ra_db::SourceDatabase;
use ra_prof::profile;
use ra_syntax::{
ast::{self, AstNode, NamedField},
ast::{self, AstNode, RecordField},
Location, SyntaxNode, TextRange, T,
};
use ra_text_edit::{TextEdit, TextEditBuilder};
@ -62,7 +62,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
let node = d.ast(db);
let mut ast_editor = AstEditor::new(node);
for f in d.missed_fields.iter() {
ast_editor.append_field(&AstBuilder::<NamedField>::from_name(f));
ast_editor.append_field(&AstBuilder::<RecordField>::from_name(f));
}
let mut builder = TextEditBuilder::default();
@ -141,20 +141,20 @@ fn check_struct_shorthand_initialization(
file_id: FileId,
node: &SyntaxNode,
) -> Option<()> {
let struct_lit = ast::StructLit::cast(node.clone())?;
let named_field_list = struct_lit.named_field_list()?;
for named_field in named_field_list.fields() {
if let (Some(name_ref), Some(expr)) = (named_field.name_ref(), named_field.expr()) {
let record_lit = ast::RecordLit::cast(node.clone())?;
let record_field_list = record_lit.record_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();
let field_expr = expr.syntax().text().to_string();
if field_name == field_expr {
let mut edit_builder = TextEditBuilder::default();
edit_builder.delete(named_field.syntax().text_range());
edit_builder.insert(named_field.syntax().text_range().start(), field_name);
edit_builder.delete(record_field.syntax().text_range());
edit_builder.insert(record_field.syntax().text_range().start(), field_name);
let edit = edit_builder.finish();
acc.push(Diagnostic {
range: named_field.syntax().text_range(),
range: record_field.syntax().text_range(),
message: "Shorthand struct initialization".to_string(),
severity: Severity::WeakWarning,
fix: Some(SourceChange::source_file_edit(

View file

@ -314,7 +314,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
.visit(|it: ast::TypeAliasDef| it.doc_comment_text())
.visit(|it: ast::ConstDef| it.doc_comment_text())
.visit(|it: ast::StaticDef| it.doc_comment_text())
.visit(|it: ast::NamedFieldDef| it.doc_comment_text())
.visit(|it: ast::RecordFieldDef| it.doc_comment_text())
.visit(|it: ast::EnumVariant| it.doc_comment_text())
.visit(|it: ast::MacroCall| it.doc_comment_text())
.accept(&node)?
@ -336,7 +336,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
.visit(|node: ast::TypeAliasDef| node.short_label())
.visit(|node: ast::ConstDef| node.short_label())
.visit(|node: ast::StaticDef| node.short_label())
.visit(|node: ast::NamedFieldDef| node.short_label())
.visit(|node: ast::RecordFieldDef| node.short_label())
.visit(|node: ast::EnumVariant| node.short_label())
.accept(&node)?
}

View file

@ -53,7 +53,7 @@ impl ShortLabel for ast::StaticDef {
}
}
impl ShortLabel for ast::NamedFieldDef {
impl ShortLabel for ast::RecordFieldDef {
fn short_label(&self) -> Option<String> {
short_label_from_ascribed_node(self, "")
}

View file

@ -124,7 +124,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
let ty = td.type_ref();
decl_with_type_ref(td, ty)
})
.visit(decl_with_ascription::<ast::NamedFieldDef>)
.visit(decl_with_ascription::<ast::RecordFieldDef>)
.visit(decl_with_ascription::<ast::ConstDef>)
.visit(decl_with_ascription::<ast::StaticDef>)
.visit(|im: ast::ImplBlock| {
@ -222,7 +222,7 @@ fn very_obsolete() {}
label: "x",
navigation_range: [18; 19),
node_range: [18; 24),
kind: NAMED_FIELD_DEF,
kind: RECORD_FIELD_DEF,
detail: Some(
"i32",
),

View file

@ -18,11 +18,11 @@ pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRang
fn try_extend_selection(root: &SyntaxNode, range: TextRange) -> Option<TextRange> {
let string_kinds = [COMMENT, STRING, RAW_STRING, BYTE_STRING, RAW_BYTE_STRING];
let list_kinds = [
FIELD_PAT_LIST,
RECORD_FIELD_PAT_LIST,
MATCH_ARM_LIST,
NAMED_FIELD_DEF_LIST,
POS_FIELD_DEF_LIST,
NAMED_FIELD_LIST,
RECORD_FIELD_DEF_LIST,
TUPLE_FIELD_DEF_LIST,
RECORD_FIELD_LIST,
ENUM_VARIANT_LIST,
USE_TREE_LIST,
TYPE_PARAM_LIST,

View file

@ -81,8 +81,14 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
match kind {
COMMENT => Some(FoldKind::Comment),
USE_ITEM => Some(FoldKind::Imports),
NAMED_FIELD_DEF_LIST | FIELD_PAT_LIST | ITEM_LIST | EXTERN_ITEM_LIST | USE_TREE_LIST
| BLOCK | ENUM_VARIANT_LIST | TOKEN_TREE => Some(FoldKind::Block),
RECORD_FIELD_DEF_LIST
| RECORD_FIELD_PAT_LIST
| ITEM_LIST
| EXTERN_ITEM_LIST
| USE_TREE_LIST
| BLOCK
| ENUM_VARIANT_LIST
| TOKEN_TREE => Some(FoldKind::Block),
_ => None,
}
}

View file

@ -178,7 +178,7 @@ fn named_target(file_id: FileId, node: &SyntaxNode) -> Option<NavigationTarget>
node.short_label(),
)
})
.visit(|node: ast::NamedFieldDef| {
.visit(|node: ast::RecordFieldDef| {
NavigationTarget::from_named(
file_id,
&node,
@ -344,13 +344,13 @@ mod tests {
foo.spam<|>;
}
",
"spam NAMED_FIELD_DEF FileId(1) [17; 26) [17; 21)",
"spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)",
);
}
#[test]
fn goto_definition_works_for_named_fields() {
covers!(goto_definition_works_for_named_fields);
fn goto_definition_works_for_record_fields() {
covers!(goto_definition_works_for_record_fields);
check_goto(
"
//- /lib.rs
@ -364,7 +364,7 @@ mod tests {
}
}
",
"spam NAMED_FIELD_DEF FileId(1) [17; 26) [17; 21)",
"spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)",
);
}
#[test]
@ -473,7 +473,7 @@ mod tests {
field<|>: string,
}
"#,
"field NAMED_FIELD_DEF FileId(1) [17; 30) [17; 22)",
"field RECORD_FIELD_DEF FileId(1) [17; 30) [17; 22)",
);
check_goto(

View file

@ -197,7 +197,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
.visit(|node: ast::TraitDef| {
hover_text(node.doc_comment_text(), node.short_label())
})
.visit(|node: ast::NamedFieldDef| {
.visit(|node: ast::RecordFieldDef| {
hover_text(node.doc_comment_text(), node.short_label())
})
.visit(|node: ast::Module| hover_text(node.doc_comment_text(), node.short_label()))

View file

@ -125,13 +125,13 @@ fn get_leaf_pats(root_pat: ast::Pat) -> Vec<ast::Pat> {
pats_to_process.push_back(arg_pat);
}
}
ast::Pat::StructPat(struct_pat) => {
if let Some(pat_list) = struct_pat.field_pat_list() {
ast::Pat::RecordPat(record_pat) => {
if let Some(pat_list) = record_pat.record_field_pat_list() {
pats_to_process.extend(
pat_list
.field_pats()
.filter_map(|field_pat| {
field_pat
.record_field_pats()
.filter_map(|record_field_pat| {
record_field_pat
.pat()
.filter(|pat| pat.syntax().kind() != SyntaxKind::BIND_PAT)
})

View file

@ -3,7 +3,7 @@ test_utils::marks!(
goto_definition_works_for_macros
goto_definition_works_for_methods
goto_definition_works_for_fields
goto_definition_works_for_named_fields
goto_definition_works_for_record_fields
call_info_bad_offset
dont_complete_current_use
dont_complete_primitive_in_use

View file

@ -54,12 +54,12 @@ pub(crate) fn classify_name_ref(
}
// It could also be a named field
if let Some(field_expr) = name_ref.syntax().parent().and_then(ast::NamedField::cast) {
tested_by!(goto_definition_works_for_named_fields);
if let Some(field_expr) = name_ref.syntax().parent().and_then(ast::RecordField::cast) {
tested_by!(goto_definition_works_for_record_fields);
let struct_lit = field_expr.syntax().ancestors().find_map(ast::StructLit::cast);
let record_lit = field_expr.syntax().ancestors().find_map(ast::RecordLit::cast);
if let Some(ty) = struct_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) {
if let Some(ty) = record_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) {
if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() {
let hir_path = hir::Path::from_name_ref(name_ref);
let hir_name = hir_path.as_ident().unwrap();

View file

@ -165,7 +165,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => {
"type"
}
NAMED_FIELD_DEF => "field",
RECORD_FIELD_DEF => "field",
_ => "function",
})
.unwrap_or("function")

View file

@ -42,7 +42,7 @@ impl Conv for SyntaxKind {
SyntaxKind::TRAIT_DEF => SymbolKind::Interface,
SyntaxKind::MODULE => SymbolKind::Module,
SyntaxKind::TYPE_ALIAS_DEF => SymbolKind::TypeParameter,
SyntaxKind::NAMED_FIELD_DEF => SymbolKind::Field,
SyntaxKind::RECORD_FIELD_DEF => SymbolKind::Field,
SyntaxKind::STATIC_DEF => SymbolKind::Constant,
SyntaxKind::CONST_DEF => SymbolKind::Constant,
SyntaxKind::IMPL_BLOCK => SymbolKind::Object,

View file

@ -419,9 +419,9 @@ MACRO_ITEMS@[0; 40)
STRUCT_KW@[0; 6) "struct"
NAME@[6; 9)
IDENT@[6; 9) "Foo"
NAMED_FIELD_DEF_LIST@[9; 20)
RECORD_FIELD_DEF_LIST@[9; 20)
L_CURLY@[9; 10) "{"
NAMED_FIELD_DEF@[10; 19)
RECORD_FIELD_DEF@[10; 19)
NAME@[10; 15)
IDENT@[10; 15) "field"
COLON@[15; 16) ":"
@ -435,9 +435,9 @@ MACRO_ITEMS@[0; 40)
STRUCT_KW@[20; 26) "struct"
NAME@[26; 29)
IDENT@[26; 29) "Bar"
NAMED_FIELD_DEF_LIST@[29; 40)
RECORD_FIELD_DEF_LIST@[29; 40)
L_CURLY@[29; 30) "{"
NAMED_FIELD_DEF@[30; 39)
RECORD_FIELD_DEF@[30; 39)
NAME@[30; 35)
IDENT@[30; 35) "field"
COLON@[35; 36) ":"

View file

@ -150,8 +150,8 @@ pub(crate) fn reparser(
) -> Option<fn(&mut Parser)> {
let res = match node {
BLOCK => expressions::block,
NAMED_FIELD_DEF_LIST => items::named_field_def_list,
NAMED_FIELD_LIST => items::named_field_list,
RECORD_FIELD_DEF_LIST => items::record_field_def_list,
RECORD_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,

View file

@ -559,8 +559,8 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
paths::expr_path(p);
match p.current() {
T!['{'] if !r.forbid_structs => {
named_field_list(p);
(m.complete(p, STRUCT_LIT), BlockLike::NotBlock)
record_field_list(p);
(m.complete(p, RECORD_LIT), BlockLike::NotBlock)
}
T![!] => {
let block_like = items::macro_call_after_excl(p);
@ -570,20 +570,20 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
}
}
// test struct_lit
// test record_lit
// fn foo() {
// S {};
// S { x, y: 32, };
// S { x, y: 32, ..Default::default() };
// TupleStruct { 0: 1 };
// }
pub(crate) fn named_field_list(p: &mut Parser) {
pub(crate) fn record_field_list(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump();
while !p.at(EOF) && !p.at(T!['}']) {
match p.current() {
// test struct_literal_field_with_attr
// test record_literal_field_with_attr
// fn main() {
// S { #[cfg(test)] field: 1 }
// }
@ -594,7 +594,7 @@ pub(crate) fn named_field_list(p: &mut Parser) {
if p.eat(T![:]) {
expr(p);
}
m.complete(p, NAMED_FIELD);
m.complete(p, RECORD_FIELD);
}
T![..] => {
p.bump();
@ -608,5 +608,5 @@ pub(crate) fn named_field_list(p: &mut Parser) {
}
}
p.expect(T!['}']);
m.complete(p, NAMED_FIELD_LIST);
m.complete(p, RECORD_FIELD_LIST);
}

View file

@ -4,8 +4,8 @@ mod traits;
mod use_item;
pub(crate) use self::{
expressions::{match_arm_list, named_field_list},
nominal::{enum_variant_list, named_field_def_list},
expressions::{match_arm_list, record_field_list},
nominal::{enum_variant_list, record_field_def_list},
traits::{impl_item_list, trait_item_list},
use_item::use_tree_list,
};

View file

@ -13,7 +13,7 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) {
T![;] => {
p.bump();
}
T!['{'] => named_field_def_list(p),
T!['{'] => record_field_def_list(p),
_ => {
//FIXME: special case `(` error message
p.error("expected `;` or `{`");
@ -23,9 +23,9 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) {
T![;] if kind == T![struct] => {
p.bump();
}
T!['{'] => named_field_def_list(p),
T!['{'] => record_field_def_list(p),
T!['('] if kind == T![struct] => {
pos_field_def_list(p);
tuple_field_def_list(p);
// test tuple_struct_where
// struct Test<T>(T) where T: Clone;
// struct Test<T>(T);
@ -70,8 +70,8 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
if p.at(IDENT) {
name(p);
match p.current() {
T!['{'] => named_field_def_list(p),
T!['('] => pos_field_def_list(p),
T!['{'] => record_field_def_list(p),
T!['('] => tuple_field_def_list(p),
T![=] => {
p.bump();
expressions::expr(p);
@ -91,7 +91,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
m.complete(p, ENUM_VARIANT_LIST);
}
pub(crate) fn named_field_def_list(p: &mut Parser) {
pub(crate) fn record_field_def_list(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump();
@ -100,17 +100,17 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
error_block(p, "expected field");
continue;
}
named_field_def(p);
record_field_def(p);
if !p.at(T!['}']) {
p.expect(T![,]);
}
}
p.expect(T!['}']);
m.complete(p, NAMED_FIELD_DEF_LIST);
m.complete(p, RECORD_FIELD_DEF_LIST);
fn named_field_def(p: &mut Parser) {
fn record_field_def(p: &mut Parser) {
let m = p.start();
// test field_attrs
// test record_field_attrs
// struct S {
// #[serde(with = "url_serde")]
// pub uri: Uri,
@ -121,7 +121,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
name(p);
p.expect(T![:]);
types::type_(p);
m.complete(p, NAMED_FIELD_DEF);
m.complete(p, RECORD_FIELD_DEF);
} else {
m.abandon(p);
p.err_and_bump("expected field declaration");
@ -129,7 +129,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
}
}
fn pos_field_def_list(p: &mut Parser) {
fn tuple_field_def_list(p: &mut Parser) {
assert!(p.at(T!['(']));
let m = p.start();
if !p.expect(T!['(']) {
@ -137,7 +137,7 @@ fn pos_field_def_list(p: &mut Parser) {
}
while !p.at(T![')']) && !p.at(EOF) {
let m = p.start();
// test pos_field_attrs
// test tuple_field_attrs
// struct S (
// #[serde(with = "url_serde")]
// pub Uri,
@ -154,12 +154,12 @@ fn pos_field_def_list(p: &mut Parser) {
break;
}
types::type_(p);
m.complete(p, POS_FIELD_DEF);
m.complete(p, TUPLE_FIELD_DEF);
if !p.at(T![')']) {
p.expect(T![,]);
}
}
p.expect(T![')']);
m.complete(p, POS_FIELD_DEF_LIST);
m.complete(p, TUPLE_FIELD_DEF_LIST);
}

View file

@ -127,8 +127,8 @@ fn path_pat(p: &mut Parser) -> CompletedMarker {
TUPLE_STRUCT_PAT
}
T!['{'] => {
field_pat_list(p);
STRUCT_PAT
record_field_pat_list(p);
RECORD_PAT
}
_ => PATH_PAT,
};
@ -149,21 +149,21 @@ fn tuple_pat_fields(p: &mut Parser) {
p.expect(T![')']);
}
// test field_pat_list
// test record_field_pat_list
// fn foo() {
// let S {} = ();
// let S { f, ref mut g } = ();
// let S { h: _, ..} = ();
// let S { h: _, } = ();
// }
fn field_pat_list(p: &mut Parser) {
fn record_field_pat_list(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump();
while !p.at(EOF) && !p.at(T!['}']) {
match p.current() {
T![..] => p.bump(),
IDENT if p.nth(1) == T![:] => field_pat(p),
IDENT if p.nth(1) == T![:] => record_field_pat(p),
T!['{'] => error_block(p, "expected ident"),
_ => {
bind_pat(p, false);
@ -174,10 +174,10 @@ fn field_pat_list(p: &mut Parser) {
}
}
p.expect(T!['}']);
m.complete(p, FIELD_PAT_LIST);
m.complete(p, RECORD_FIELD_PAT_LIST);
}
fn field_pat(p: &mut Parser) {
fn record_field_pat(p: &mut Parser) {
assert!(p.at(IDENT));
assert!(p.nth(1) == T![:]);
@ -185,7 +185,7 @@ fn field_pat(p: &mut Parser) {
name(p);
p.bump();
pattern(p);
m.complete(p, FIELD_PAT);
m.complete(p, RECORD_FIELD_PAT);
}
// test placeholder_pat

View file

@ -152,9 +152,9 @@ pub enum SyntaxKind {
BIND_PAT,
PLACEHOLDER_PAT,
PATH_PAT,
STRUCT_PAT,
FIELD_PAT_LIST,
FIELD_PAT,
RECORD_PAT,
RECORD_FIELD_PAT_LIST,
RECORD_FIELD_PAT,
TUPLE_STRUCT_PAT,
TUPLE_PAT,
SLICE_PAT,
@ -179,9 +179,9 @@ pub enum SyntaxKind {
MATCH_ARM_LIST,
MATCH_ARM,
MATCH_GUARD,
STRUCT_LIT,
NAMED_FIELD_LIST,
NAMED_FIELD,
RECORD_LIT,
RECORD_FIELD_LIST,
RECORD_FIELD,
TRY_BLOCK_EXPR,
BOX_EXPR,
CALL_EXPR,
@ -199,10 +199,10 @@ pub enum SyntaxKind {
EXTERN_BLOCK,
EXTERN_ITEM_LIST,
ENUM_VARIANT,
NAMED_FIELD_DEF_LIST,
NAMED_FIELD_DEF,
POS_FIELD_DEF_LIST,
POS_FIELD_DEF,
RECORD_FIELD_DEF_LIST,
RECORD_FIELD_DEF,
TUPLE_FIELD_DEF_LIST,
TUPLE_FIELD_DEF,
ENUM_VARIANT_LIST,
ITEM_LIST,
ATTR,

View file

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

View file

@ -195,16 +195,16 @@ impl ast::ImplBlock {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StructKind {
Tuple(ast::PosFieldDefList),
Named(ast::NamedFieldDefList),
Tuple(ast::TupleFieldDefList),
Named(ast::RecordFieldDefList),
Unit,
}
impl StructKind {
fn from_node<N: AstNode>(node: &N) -> StructKind {
if let Some(nfdl) = child_opt::<_, ast::NamedFieldDefList>(node) {
if let Some(nfdl) = child_opt::<_, ast::RecordFieldDefList>(node) {
StructKind::Named(nfdl)
} else if let Some(pfl) = child_opt::<_, ast::PosFieldDefList>(node) {
} else if let Some(pfl) = child_opt::<_, ast::TupleFieldDefList>(node) {
StructKind::Tuple(pfl)
} else {
StructKind::Unit

View file

@ -607,7 +607,7 @@ pub enum Expr {
BlockExpr(BlockExpr),
ReturnExpr(ReturnExpr),
MatchExpr(MatchExpr),
StructLit(StructLit),
RecordLit(RecordLit),
CallExpr(CallExpr),
IndexExpr(IndexExpr),
MethodCallExpr(MethodCallExpr),
@ -698,9 +698,9 @@ impl From<MatchExpr> for Expr {
Expr::MatchExpr(node)
}
}
impl From<StructLit> for Expr {
fn from(node: StructLit) -> Expr {
Expr::StructLit(node)
impl From<RecordLit> for Expr {
fn from(node: RecordLit) -> Expr {
Expr::RecordLit(node)
}
}
impl From<CallExpr> for Expr {
@ -778,7 +778,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 | STRUCT_LIT | CALL_EXPR | INDEX_EXPR
| BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
| METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
| CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
true
@ -803,7 +803,7 @@ impl AstNode for Expr {
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
STRUCT_LIT => Expr::StructLit(StructLit { syntax }),
RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
@ -839,7 +839,7 @@ impl AstNode for Expr {
Expr::BlockExpr(it) => &it.syntax,
Expr::ReturnExpr(it) => &it.syntax,
Expr::MatchExpr(it) => &it.syntax,
Expr::StructLit(it) => &it.syntax,
Expr::RecordLit(it) => &it.syntax,
Expr::CallExpr(it) => &it.syntax,
Expr::IndexExpr(it) => &it.syntax,
Expr::MethodCallExpr(it) => &it.syntax,
@ -946,64 +946,6 @@ impl FieldExpr {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FieldPat {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for FieldPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FIELD_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::NameOwner for FieldPat {}
impl FieldPat {
pub fn pat(&self) -> Option<Pat> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FieldPatList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for FieldPatList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FIELD_PAT_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl FieldPatList {
pub fn field_pats(&self) -> AstChildren<FieldPat> {
AstChildren::new(&self.syntax)
}
pub fn bind_pats(&self) -> AstChildren<BindPat> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnDef {
pub(crate) syntax: SyntaxNode,
}
@ -1942,121 +1884,6 @@ impl AstNode for NameRef {
}
impl NameRef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NamedField {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for NamedField {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NAMED_FIELD => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl NamedField {
pub fn name_ref(&self) -> Option<NameRef> {
AstChildren::new(&self.syntax).next()
}
pub fn expr(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NamedFieldDef {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for NamedFieldDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NAMED_FIELD_DEF => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::VisibilityOwner for NamedFieldDef {}
impl ast::NameOwner for NamedFieldDef {}
impl ast::AttrsOwner for NamedFieldDef {}
impl ast::DocCommentsOwner for NamedFieldDef {}
impl ast::TypeAscriptionOwner for NamedFieldDef {}
impl NamedFieldDef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NamedFieldDefList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for NamedFieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NAMED_FIELD_DEF_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl NamedFieldDefList {
pub fn fields(&self) -> AstChildren<NamedFieldDef> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NamedFieldList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for NamedFieldList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NAMED_FIELD_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl NamedFieldList {
pub fn fields(&self) -> AstChildren<NamedField> {
AstChildren::new(&self.syntax)
}
pub fn spread(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NeverType {
pub(crate) syntax: SyntaxNode,
}
@ -2239,7 +2066,7 @@ pub enum Pat {
BindPat(BindPat),
PlaceholderPat(PlaceholderPat),
PathPat(PathPat),
StructPat(StructPat),
RecordPat(RecordPat),
TupleStructPat(TupleStructPat),
TuplePat(TuplePat),
SlicePat(SlicePat),
@ -2266,9 +2093,9 @@ impl From<PathPat> for Pat {
Pat::PathPat(node)
}
}
impl From<StructPat> for Pat {
fn from(node: StructPat) -> Pat {
Pat::StructPat(node)
impl From<RecordPat> for Pat {
fn from(node: RecordPat) -> Pat {
Pat::RecordPat(node)
}
}
impl From<TupleStructPat> for Pat {
@ -2299,7 +2126,7 @@ impl From<LiteralPat> for Pat {
impl AstNode for Pat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT
REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT
| TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
_ => false,
}
@ -2310,7 +2137,7 @@ impl AstNode for Pat {
BIND_PAT => Pat::BindPat(BindPat { syntax }),
PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
PATH_PAT => Pat::PathPat(PathPat { syntax }),
STRUCT_PAT => Pat::StructPat(StructPat { syntax }),
RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
@ -2326,7 +2153,7 @@ impl AstNode for Pat {
Pat::BindPat(it) => &it.syntax,
Pat::PlaceholderPat(it) => &it.syntax,
Pat::PathPat(it) => &it.syntax,
Pat::StructPat(it) => &it.syntax,
Pat::RecordPat(it) => &it.syntax,
Pat::TupleStructPat(it) => &it.syntax,
Pat::TuplePat(it) => &it.syntax,
Pat::SlicePat(it) => &it.syntax,
@ -2551,62 +2378,6 @@ impl PointerType {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PosFieldDef {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for PosFieldDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
POS_FIELD_DEF => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::VisibilityOwner for PosFieldDef {}
impl ast::AttrsOwner for PosFieldDef {}
impl PosFieldDef {
pub fn type_ref(&self) -> Option<TypeRef> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PosFieldDefList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for PosFieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
POS_FIELD_DEF_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl PosFieldDefList {
pub fn fields(&self) -> AstChildren<PosFieldDef> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PrefixExpr {
pub(crate) syntax: SyntaxNode,
}
@ -2680,6 +2451,239 @@ impl AstNode for RangePat {
}
impl RangePat {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordField {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordField {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordField {
pub fn name_ref(&self) -> Option<NameRef> {
AstChildren::new(&self.syntax).next()
}
pub fn expr(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldDef {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordFieldDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_DEF => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::VisibilityOwner for RecordFieldDef {}
impl ast::NameOwner for RecordFieldDef {}
impl ast::AttrsOwner for RecordFieldDef {}
impl ast::DocCommentsOwner for RecordFieldDef {}
impl ast::TypeAscriptionOwner for RecordFieldDef {}
impl RecordFieldDef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldDefList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordFieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_DEF_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordFieldDefList {
pub fn fields(&self) -> AstChildren<RecordFieldDef> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordFieldList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordFieldList {
pub fn fields(&self) -> AstChildren<RecordField> {
AstChildren::new(&self.syntax)
}
pub fn spread(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldPat {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordFieldPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::NameOwner for RecordFieldPat {}
impl RecordFieldPat {
pub fn pat(&self) -> Option<Pat> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldPatList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordFieldPatList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_PAT_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordFieldPatList {
pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
AstChildren::new(&self.syntax)
}
pub fn bind_pats(&self) -> AstChildren<BindPat> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordLit {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordLit {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_LIT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordLit {
pub fn path(&self) -> Option<Path> {
AstChildren::new(&self.syntax).next()
}
pub fn record_field_list(&self) -> Option<RecordFieldList> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordPat {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for RecordPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordPat {
pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
AstChildren::new(&self.syntax).next()
}
pub fn path(&self) -> Option<Path> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RefExpr {
pub(crate) syntax: SyntaxNode,
}
@ -3018,66 +3022,6 @@ impl ast::AttrsOwner for StructDef {}
impl ast::DocCommentsOwner for StructDef {}
impl StructDef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StructLit {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for StructLit {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRUCT_LIT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl StructLit {
pub fn path(&self) -> Option<Path> {
AstChildren::new(&self.syntax).next()
}
pub fn named_field_list(&self) -> Option<NamedFieldList> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StructPat {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for StructPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRUCT_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl StructPat {
pub fn field_pat_list(&self) -> Option<FieldPatList> {
AstChildren::new(&self.syntax).next()
}
pub fn path(&self) -> Option<Path> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TokenTree {
pub(crate) syntax: SyntaxNode,
}
@ -3212,6 +3156,62 @@ impl TupleExpr {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleFieldDef {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TupleFieldDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_FIELD_DEF => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::VisibilityOwner for TupleFieldDef {}
impl ast::AttrsOwner for TupleFieldDef {}
impl TupleFieldDef {
pub fn type_ref(&self) -> Option<TypeRef> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleFieldDefList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TupleFieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_FIELD_DEF_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl TupleFieldDefList {
pub fn fields(&self) -> AstChildren<TupleFieldDef> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TuplePat {
pub(crate) syntax: SyntaxNode,
}

View file

@ -161,9 +161,9 @@ Grammar(
"BIND_PAT",
"PLACEHOLDER_PAT",
"PATH_PAT",
"STRUCT_PAT",
"FIELD_PAT_LIST",
"FIELD_PAT",
"RECORD_PAT",
"RECORD_FIELD_PAT_LIST",
"RECORD_FIELD_PAT",
"TUPLE_STRUCT_PAT",
"TUPLE_PAT",
"SLICE_PAT",
@ -190,9 +190,9 @@ Grammar(
"MATCH_ARM_LIST",
"MATCH_ARM",
"MATCH_GUARD",
"STRUCT_LIT",
"NAMED_FIELD_LIST",
"NAMED_FIELD",
"RECORD_LIT",
"RECORD_FIELD_LIST",
"RECORD_FIELD",
"TRY_BLOCK_EXPR",
"BOX_EXPR",
@ -216,10 +216,10 @@ Grammar(
"EXTERN_BLOCK",
"EXTERN_ITEM_LIST",
"ENUM_VARIANT",
"NAMED_FIELD_DEF_LIST",
"NAMED_FIELD_DEF",
"POS_FIELD_DEF_LIST",
"POS_FIELD_DEF",
"RECORD_FIELD_DEF_LIST",
"RECORD_FIELD_DEF",
"TUPLE_FIELD_DEF_LIST",
"TUPLE_FIELD_DEF",
"ENUM_VARIANT_LIST",
"ITEM_LIST",
"ATTR",
@ -286,8 +286,8 @@ Grammar(
"DocCommentsOwner"
]
),
"NamedFieldDefList": (collections: [("fields", "NamedFieldDef")]),
"NamedFieldDef": (
"RecordFieldDefList": (collections: [("fields", "RecordFieldDef")]),
"RecordFieldDef": (
traits: [
"VisibilityOwner",
"NameOwner",
@ -296,8 +296,8 @@ Grammar(
"TypeAscriptionOwner"
]
),
"PosFieldDefList": (collections: [("fields", "PosFieldDef")]),
"PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
"TupleFieldDefList": (collections: [("fields", "TupleFieldDef")]),
"TupleFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
"EnumDef": ( traits: [
"VisibilityOwner",
"NameOwner",
@ -461,12 +461,12 @@ Grammar(
traits: [ "AttrsOwner" ]
),
"MatchGuard": (options: ["Expr"]),
"StructLit": (options: ["Path", "NamedFieldList"]),
"NamedFieldList": (
collections: [ ("fields", "NamedField") ],
"RecordLit": (options: ["Path", "RecordFieldList"]),
"RecordFieldList": (
collections: [ ("fields", "RecordField") ],
options: [["spread", "Expr"]]
),
"NamedField": (options: ["NameRef", "Expr"]),
"RecordField": (options: ["NameRef", "Expr"]),
"CallExpr": (
traits: ["ArgListOwner"],
options: [ "Expr" ],
@ -504,7 +504,7 @@ Grammar(
"BlockExpr",
"ReturnExpr",
"MatchExpr",
"StructLit",
"RecordLit",
"CallExpr",
"IndexExpr",
"MethodCallExpr",
@ -529,14 +529,14 @@ Grammar(
),
"PlaceholderPat": (),
"PathPat": ( options: [ "Path" ] ),
"StructPat": ( options: ["FieldPatList", "Path"] ),
"FieldPatList": (
"RecordPat": ( options: ["RecordFieldPatList", "Path"] ),
"RecordFieldPatList": (
collections: [
("field_pats", "FieldPat"),
("record_field_pats", "RecordFieldPat"),
("bind_pats", "BindPat"),
]
),
"FieldPat": (
"RecordFieldPat": (
traits: ["NameOwner"],
options: ["Pat"]
),
@ -555,7 +555,7 @@ Grammar(
"BindPat",
"PlaceholderPat",
"PathPat",
"StructPat",
"RecordPat",
"TupleStructPat",
"TuplePat",
"SlicePat",

View file

@ -145,7 +145,7 @@ fn n_attached_trivias<'a>(
) -> usize {
match kind {
CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF
| MODULE | NAMED_FIELD_DEF => {
| MODULE | RECORD_FIELD_DEF => {
let mut res = 0;
for (i, (kind, text)) in trivias.enumerate() {
match kind {

View file

@ -80,7 +80,7 @@ fn test_local_syntax_ptr() {
use crate::{ast, AstNode, SourceFile};
let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap();
let field = file.syntax().descendants().find_map(ast::NamedFieldDef::cast).unwrap();
let field = file.syntax().descendants().find_map(ast::RecordFieldDef::cast).unwrap();
let ptr = SyntaxNodePtr::new(field.syntax());
let field_syntax = ptr.to_node(file.syntax());
assert_eq!(field.syntax(), &field_syntax);

View file

@ -99,7 +99,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
.visit::<ast::Literal, _>(validate_literal)
.visit::<ast::Block, _>(block::validate_block_node)
.visit::<ast::FieldExpr, _>(|it, errors| validate_numeric_name(it.name_ref(), errors))
.visit::<ast::NamedField, _>(|it, errors| validate_numeric_name(it.name_ref(), errors))
.visit::<ast::RecordField, _>(|it, errors| validate_numeric_name(it.name_ref(), errors))
.accept(&node);
}
errors

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 34)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
NAMED_FIELD_DEF_LIST@[9; 34)
RECORD_FIELD_DEF_LIST@[9; 34)
L_CURLY@[9; 10) "{"
WHITESPACE@[10; 15) "\n "
NAMED_FIELD_DEF@[15; 21)
RECORD_FIELD_DEF@[15; 21)
NAME@[15; 16)
IDENT@[15; 16) "a"
COLON@[16; 17) ":"
@ -19,7 +19,7 @@ SOURCE_FILE@[0; 34)
NAME_REF@[18; 21)
IDENT@[18; 21) "u32"
WHITESPACE@[21; 26) "\n "
NAMED_FIELD_DEF@[26; 32)
RECORD_FIELD_DEF@[26; 32)
NAME@[26; 27)
IDENT@[26; 27) "b"
COLON@[27; 28) ":"

View file

@ -11,7 +11,7 @@ SOURCE_FILE@[0; 21)
NAME@[17; 18)
IDENT@[17; 18) "S"
WHITESPACE@[18; 19) " "
NAMED_FIELD_DEF_LIST@[19; 21)
RECORD_FIELD_DEF_LIST@[19; 21)
L_CURLY@[19; 20) "{"
R_CURLY@[20; 21) "}"
error 0: expected an item

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 40)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
NAMED_FIELD_DEF_LIST@[9; 39)
RECORD_FIELD_DEF_LIST@[9; 39)
L_CURLY@[9; 10) "{"
WHITESPACE@[10; 15) "\n "
NAMED_FIELD_DEF@[15; 21)
RECORD_FIELD_DEF@[15; 21)
NAME@[15; 16)
IDENT@[15; 16) "a"
COLON@[16; 17) ":"
@ -20,7 +20,7 @@ SOURCE_FILE@[0; 40)
IDENT@[18; 21) "i32"
COMMA@[21; 22) ","
WHITESPACE@[22; 27) "\n "
NAMED_FIELD_DEF@[27; 36)
RECORD_FIELD_DEF@[27; 36)
NAME@[27; 28)
IDENT@[27; 28) "b"
COLON@[28; 29) ":"

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 74)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
NAMED_FIELD_DEF_LIST@[9; 73)
RECORD_FIELD_DEF_LIST@[9; 73)
L_CURLY@[9; 10) "{"
WHITESPACE@[10; 15) "\n "
NAMED_FIELD_DEF@[15; 21)
RECORD_FIELD_DEF@[15; 21)
NAME@[15; 16)
IDENT@[15; 16) "f"
COLON@[16; 17) ":"
@ -35,7 +35,7 @@ SOURCE_FILE@[0; 74)
ERROR@[42; 43)
STAR@[42; 43) "*"
WHITESPACE@[43; 48) "\n "
NAMED_FIELD_DEF@[48; 58)
RECORD_FIELD_DEF@[48; 58)
VISIBILITY@[48; 51)
PUB_KW@[48; 51) "pub"
WHITESPACE@[51; 52) " "
@ -50,7 +50,7 @@ SOURCE_FILE@[0; 74)
IDENT@[55; 58) "u32"
COMMA@[58; 59) ","
WHITESPACE@[59; 64) "\n "
NAMED_FIELD_DEF@[64; 70)
RECORD_FIELD_DEF@[64; 70)
NAME@[64; 65)
IDENT@[64; 65) "z"
COLON@[65; 66) ":"

View file

@ -7,10 +7,10 @@ SOURCE_FILE@[0; 86)
WHITESPACE@[10; 11) " "
NAME@[11; 16)
IDENT@[11; 16) "Cache"
POS_FIELD_DEF_LIST@[16; 72)
TUPLE_FIELD_DEF_LIST@[16; 72)
L_PAREN@[16; 17) "("
WHITESPACE@[17; 22) "\n "
POS_FIELD_DEF@[22; 68)
TUPLE_FIELD_DEF@[22; 68)
PATH_TYPE@[22; 68)
PATH@[22; 68)
PATH_SEGMENT@[22; 68)
@ -47,7 +47,7 @@ SOURCE_FILE@[0; 86)
ERROR@[67; 68)
AT@[67; 68) "@"
WHITESPACE@[68; 69) " "
POS_FIELD_DEF@[69; 72)
TUPLE_FIELD_DEF@[69; 72)
PATH_TYPE@[69; 72)
PATH@[69; 72)
PATH_SEGMENT@[69; 72)

View file

@ -75,16 +75,16 @@ SOURCE_FILE@[0; 183)
IDENT@[106; 110) "push"
ARG_LIST@[110; 155)
L_PAREN@[110; 111) "("
STRUCT_LIT@[111; 154)
RECORD_LIT@[111; 154)
PATH@[111; 120)
PATH_SEGMENT@[111; 120)
NAME_REF@[111; 120)
IDENT@[111; 120) "ScopeData"
WHITESPACE@[120; 121) " "
NAMED_FIELD_LIST@[121; 154)
RECORD_FIELD_LIST@[121; 154)
L_CURLY@[121; 122) "{"
WHITESPACE@[122; 123) " "
NAMED_FIELD@[123; 135)
RECORD_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) " "
NAMED_FIELD@[137; 152)
RECORD_FIELD@[137; 152)
NAME_REF@[137; 144)
IDENT@[137; 144) "entries"
COLON@[144; 145) ":"

View file

@ -28,9 +28,9 @@ SOURCE_FILE@[0; 575)
ENUM_VARIANT@[50; 62)
NAME@[50; 54)
IDENT@[50; 54) "Var2"
POS_FIELD_DEF_LIST@[54; 62)
TUPLE_FIELD_DEF_LIST@[54; 62)
L_PAREN@[54; 55) "("
POS_FIELD_DEF@[55; 61)
TUPLE_FIELD_DEF@[55; 61)
PATH_TYPE@[55; 61)
PATH@[55; 61)
PATH_SEGMENT@[55; 61)
@ -43,10 +43,10 @@ SOURCE_FILE@[0; 575)
NAME@[72; 76)
IDENT@[72; 76) "Var3"
WHITESPACE@[76; 77) " "
NAMED_FIELD_DEF_LIST@[77; 145)
RECORD_FIELD_DEF_LIST@[77; 145)
L_CURLY@[77; 78) "{"
WHITESPACE@[78; 91) "\n "
NAMED_FIELD_DEF@[91; 95)
RECORD_FIELD_DEF@[91; 95)
NAME@[91; 94)
IDENT@[91; 94) "abc"
COLON@[94; 95) ":"
@ -108,10 +108,10 @@ SOURCE_FILE@[0; 575)
NAME@[250; 259)
IDENT@[250; 259) "StillFine"
WHITESPACE@[259; 260) " "
NAMED_FIELD_DEF_LIST@[260; 293)
RECORD_FIELD_DEF_LIST@[260; 293)
L_CURLY@[260; 261) "{"
WHITESPACE@[261; 274) "\n "
NAMED_FIELD_DEF@[274; 282)
RECORD_FIELD_DEF@[274; 282)
NAME@[274; 277)
IDENT@[274; 277) "def"
COLON@[277; 278) ":"
@ -147,9 +147,9 @@ SOURCE_FILE@[0; 575)
ENUM_VARIANT@[363; 372)
NAME@[363; 367)
IDENT@[363; 367) "Nope"
POS_FIELD_DEF_LIST@[367; 372)
TUPLE_FIELD_DEF_LIST@[367; 372)
L_PAREN@[367; 368) "("
POS_FIELD_DEF@[368; 371)
TUPLE_FIELD_DEF@[368; 371)
PATH_TYPE@[368; 371)
PATH@[368; 371)
PATH_SEGMENT@[368; 371)

View file

@ -86,7 +86,7 @@ fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(Syntax
fn reparser(node: SyntaxNodeRef) -> Option<fn(&mut Parser)> {
let res = match node.kind() {
BLOCK => grammar::block,
NAMED_FIELD_DEF_LIST => grammar::named_field_def_list,
RECORD_FIELD_DEF_LIST => grammar::record_field_def_list,
_ => return None,
};
Some(res)
@ -138,7 +138,7 @@ fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(Syntax
let res = match node.kind() {
;
let end = u32::from(range.end()) as usize;
text.replaT => grammar::named_field_def_list,
text.replaT => grammar::record_field_def_list,
_ => return None,
};
Some(res)

View file

@ -52,13 +52,13 @@ SOURCE_FILE@[0; 103)
LET_STMT@[58; 78)
LET_KW@[58; 61) "let"
WHITESPACE@[61; 62) " "
STRUCT_PAT@[62; 72)
RECORD_PAT@[62; 72)
PATH@[62; 65)
PATH_SEGMENT@[62; 65)
NAME_REF@[62; 65)
IDENT@[62; 65) "Bar"
WHITESPACE@[65; 66) " "
FIELD_PAT_LIST@[66; 72)
RECORD_FIELD_PAT_LIST@[66; 72)
L_CURLY@[66; 67) "{"
WHITESPACE@[67; 68) " "
DOTDOT@[68; 70) ".."

View file

@ -22,10 +22,10 @@ SOURCE_FILE@[0; 71)
NAME@[27; 28)
IDENT@[27; 28) "S"
WHITESPACE@[28; 29) " "
NAMED_FIELD_DEF_LIST@[29; 49)
RECORD_FIELD_DEF_LIST@[29; 49)
L_CURLY@[29; 30) "{"
WHITESPACE@[30; 31) " "
NAMED_FIELD_DEF@[31; 47)
RECORD_FIELD_DEF@[31; 47)
VISIBILITY@[31; 36)
CRATE_KW@[31; 36) "crate"
WHITESPACE@[36; 37) " "
@ -46,9 +46,9 @@ SOURCE_FILE@[0; 71)
WHITESPACE@[56; 57) " "
NAME@[57; 58)
IDENT@[57; 58) "T"
POS_FIELD_DEF_LIST@[58; 69)
TUPLE_FIELD_DEF_LIST@[58; 69)
L_PAREN@[58; 59) "("
POS_FIELD_DEF@[59; 68)
TUPLE_FIELD_DEF@[59; 68)
VISIBILITY@[59; 64)
CRATE_KW@[59; 64) "crate"
WHITESPACE@[64; 65) " "

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 64)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
NAMED_FIELD_DEF_LIST@[9; 63)
RECORD_FIELD_DEF_LIST@[9; 63)
L_CURLY@[9; 10) "{"
WHITESPACE@[10; 15) "\n "
NAMED_FIELD_DEF@[15; 60)
RECORD_FIELD_DEF@[15; 60)
ATTR@[15; 43)
POUND@[15; 16) "#"
TOKEN_TREE@[16; 43)

View file

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

View file

@ -49,14 +49,14 @@ SOURCE_FILE@[0; 215)
WHITESPACE@[60; 61) " "
R_ANGLE@[61; 62) ">"
WHITESPACE@[62; 63) " "
STRUCT_LIT@[63; 77)
RECORD_LIT@[63; 77)
PATH@[63; 67)
PATH_SEGMENT@[63; 67)
NAME_REF@[63; 67)
IDENT@[63; 67) "Test"
NAMED_FIELD_LIST@[67; 77)
RECORD_FIELD_LIST@[67; 77)
L_CURLY@[67; 68) "{"
NAMED_FIELD@[68; 76)
RECORD_FIELD@[68; 76)
NAME_REF@[68; 73)
IDENT@[68; 73) "field"
COLON@[73; 74) ":"

View file

@ -5,7 +5,7 @@ SOURCE_FILE@[0; 51)
NAME@[6; 9)
IDENT@[6; 9) "Foo"
WHITESPACE@[9; 10) " "
NAMED_FIELD_DEF_LIST@[10; 12)
RECORD_FIELD_DEF_LIST@[10; 12)
L_CURLY@[10; 11) "{"
R_CURLY@[11; 12) "}"
WHITESPACE@[12; 13) "\n"
@ -15,10 +15,10 @@ SOURCE_FILE@[0; 51)
NAME@[19; 22)
IDENT@[19; 22) "Foo"
WHITESPACE@[22; 23) " "
NAMED_FIELD_DEF_LIST@[23; 50)
RECORD_FIELD_DEF_LIST@[23; 50)
L_CURLY@[23; 24) "{"
WHITESPACE@[24; 29) "\n "
NAMED_FIELD_DEF@[29; 35)
RECORD_FIELD_DEF@[29; 35)
NAME@[29; 30)
IDENT@[29; 30) "a"
COLON@[30; 31) ":"
@ -30,7 +30,7 @@ SOURCE_FILE@[0; 51)
IDENT@[32; 35) "i32"
COMMA@[35; 36) ","
WHITESPACE@[36; 41) "\n "
NAMED_FIELD_DEF@[41; 47)
RECORD_FIELD_DEF@[41; 47)
NAME@[41; 42)
IDENT@[41; 42) "b"
COLON@[42; 43) ":"

View file

@ -12,7 +12,7 @@ SOURCE_FILE@[0; 106)
NAME@[19; 22)
IDENT@[19; 22) "Foo"
WHITESPACE@[22; 23) " "
NAMED_FIELD_DEF_LIST@[23; 25)
RECORD_FIELD_DEF_LIST@[23; 25)
L_CURLY@[23; 24) "{"
R_CURLY@[24; 25) "}"
WHITESPACE@[25; 26) "\n"
@ -21,7 +21,7 @@ SOURCE_FILE@[0; 106)
WHITESPACE@[32; 33) " "
NAME@[33; 36)
IDENT@[33; 36) "Foo"
POS_FIELD_DEF_LIST@[36; 38)
TUPLE_FIELD_DEF_LIST@[36; 38)
L_PAREN@[36; 37) "("
R_PAREN@[37; 38) ")"
SEMI@[38; 39) ";"
@ -31,9 +31,9 @@ SOURCE_FILE@[0; 106)
WHITESPACE@[46; 47) " "
NAME@[47; 50)
IDENT@[47; 50) "Foo"
POS_FIELD_DEF_LIST@[50; 65)
TUPLE_FIELD_DEF_LIST@[50; 65)
L_PAREN@[50; 51) "("
POS_FIELD_DEF@[51; 57)
TUPLE_FIELD_DEF@[51; 57)
PATH_TYPE@[51; 57)
PATH@[51; 57)
PATH_SEGMENT@[51; 57)
@ -41,7 +41,7 @@ SOURCE_FILE@[0; 106)
IDENT@[51; 57) "String"
COMMA@[57; 58) ","
WHITESPACE@[58; 59) " "
POS_FIELD_DEF@[59; 64)
TUPLE_FIELD_DEF@[59; 64)
PATH_TYPE@[59; 64)
PATH@[59; 64)
PATH_SEGMENT@[59; 64)
@ -56,10 +56,10 @@ SOURCE_FILE@[0; 106)
NAME@[74; 77)
IDENT@[74; 77) "Foo"
WHITESPACE@[77; 78) " "
NAMED_FIELD_DEF_LIST@[78; 105)
RECORD_FIELD_DEF_LIST@[78; 105)
L_CURLY@[78; 79) "{"
WHITESPACE@[79; 84) "\n "
NAMED_FIELD_DEF@[84; 90)
RECORD_FIELD_DEF@[84; 90)
NAME@[84; 85)
IDENT@[84; 85) "a"
COLON@[85; 86) ":"
@ -71,7 +71,7 @@ SOURCE_FILE@[0; 106)
IDENT@[87; 90) "i32"
COMMA@[90; 91) ","
WHITESPACE@[91; 96) "\n "
NAMED_FIELD_DEF@[96; 102)
RECORD_FIELD_DEF@[96; 102)
NAME@[96; 97)
IDENT@[96; 97) "b"
COLON@[97; 98) ":"

View file

@ -14,13 +14,13 @@ SOURCE_FILE@[0; 119)
LET_STMT@[15; 29)
LET_KW@[15; 18) "let"
WHITESPACE@[18; 19) " "
STRUCT_PAT@[19; 23)
RECORD_PAT@[19; 23)
PATH@[19; 20)
PATH_SEGMENT@[19; 20)
NAME_REF@[19; 20)
IDENT@[19; 20) "S"
WHITESPACE@[20; 21) " "
FIELD_PAT_LIST@[21; 23)
RECORD_FIELD_PAT_LIST@[21; 23)
L_CURLY@[21; 22) "{"
R_CURLY@[22; 23) "}"
WHITESPACE@[23; 24) " "
@ -34,13 +34,13 @@ SOURCE_FILE@[0; 119)
LET_STMT@[34; 62)
LET_KW@[34; 37) "let"
WHITESPACE@[37; 38) " "
STRUCT_PAT@[38; 56)
RECORD_PAT@[38; 56)
PATH@[38; 39)
PATH_SEGMENT@[38; 39)
NAME_REF@[38; 39)
IDENT@[38; 39) "S"
WHITESPACE@[39; 40) " "
FIELD_PAT_LIST@[40; 56)
RECORD_FIELD_PAT_LIST@[40; 56)
L_CURLY@[40; 41) "{"
WHITESPACE@[41; 42) " "
BIND_PAT@[42; 43)
@ -68,16 +68,16 @@ SOURCE_FILE@[0; 119)
LET_STMT@[67; 90)
LET_KW@[67; 70) "let"
WHITESPACE@[70; 71) " "
STRUCT_PAT@[71; 84)
RECORD_PAT@[71; 84)
PATH@[71; 72)
PATH_SEGMENT@[71; 72)
NAME_REF@[71; 72)
IDENT@[71; 72) "S"
WHITESPACE@[72; 73) " "
FIELD_PAT_LIST@[73; 84)
RECORD_FIELD_PAT_LIST@[73; 84)
L_CURLY@[73; 74) "{"
WHITESPACE@[74; 75) " "
FIELD_PAT@[75; 79)
RECORD_FIELD_PAT@[75; 79)
NAME@[75; 76)
IDENT@[75; 76) "h"
COLON@[76; 77) ":"
@ -99,16 +99,16 @@ SOURCE_FILE@[0; 119)
LET_STMT@[95; 116)
LET_KW@[95; 98) "let"
WHITESPACE@[98; 99) " "
STRUCT_PAT@[99; 110)
RECORD_PAT@[99; 110)
PATH@[99; 100)
PATH_SEGMENT@[99; 100)
NAME_REF@[99; 100)
IDENT@[99; 100) "S"
WHITESPACE@[100; 101) " "
FIELD_PAT_LIST@[101; 110)
RECORD_FIELD_PAT_LIST@[101; 110)
L_CURLY@[101; 102) "{"
WHITESPACE@[102; 103) " "
FIELD_PAT@[103; 107)
RECORD_FIELD_PAT@[103; 107)
NAME@[103; 104)
IDENT@[103; 104) "h"
COLON@[104; 105) ":"

View file

@ -10,9 +10,9 @@ SOURCE_FILE@[0; 53)
NAME@[12; 13)
IDENT@[12; 13) "T"
R_ANGLE@[13; 14) ">"
POS_FIELD_DEF_LIST@[14; 17)
TUPLE_FIELD_DEF_LIST@[14; 17)
L_PAREN@[14; 15) "("
POS_FIELD_DEF@[15; 16)
TUPLE_FIELD_DEF@[15; 16)
PATH_TYPE@[15; 16)
PATH@[15; 16)
PATH_SEGMENT@[15; 16)
@ -51,9 +51,9 @@ SOURCE_FILE@[0; 53)
NAME@[46; 47)
IDENT@[46; 47) "T"
R_ANGLE@[47; 48) ">"
POS_FIELD_DEF_LIST@[48; 51)
TUPLE_FIELD_DEF_LIST@[48; 51)
L_PAREN@[48; 49) "("
POS_FIELD_DEF@[49; 50)
TUPLE_FIELD_DEF@[49; 50)
PATH_TYPE@[49; 50)
PATH@[49; 50)
PATH_SEGMENT@[49; 50)

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 60)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
POS_FIELD_DEF_LIST@[9; 58)
TUPLE_FIELD_DEF_LIST@[9; 58)
L_PAREN@[9; 10) "("
WHITESPACE@[10; 15) "\n "
POS_FIELD_DEF@[15; 55)
TUPLE_FIELD_DEF@[15; 55)
ATTR@[15; 43)
POUND@[15; 16) "#"
TOKEN_TREE@[16; 43)

View file

@ -11,16 +11,16 @@ SOURCE_FILE@[0; 46)
BLOCK@[10; 45)
L_CURLY@[10; 11) "{"
WHITESPACE@[11; 16) "\n "
STRUCT_LIT@[16; 43)
RECORD_LIT@[16; 43)
PATH@[16; 17)
PATH_SEGMENT@[16; 17)
NAME_REF@[16; 17)
IDENT@[16; 17) "S"
WHITESPACE@[17; 18) " "
NAMED_FIELD_LIST@[18; 43)
RECORD_FIELD_LIST@[18; 43)
L_CURLY@[18; 19) "{"
WHITESPACE@[19; 20) " "
NAMED_FIELD@[20; 41)
RECORD_FIELD@[20; 41)
ATTR@[20; 32)
POUND@[20; 21) "#"
TOKEN_TREE@[21; 32)

View file

@ -53,7 +53,7 @@ SOURCE_FILE@[0; 111)
NAME@[103; 104)
IDENT@[103; 104) "S"
WHITESPACE@[104; 105) " "
NAMED_FIELD_DEF_LIST@[105; 107)
RECORD_FIELD_DEF_LIST@[105; 107)
L_CURLY@[105; 106) "{"
R_CURLY@[106; 107) "}"
SEMI@[107; 108) ";"

View file

@ -22,14 +22,14 @@ SOURCE_FILE@[0; 52)
WHITESPACE@[23; 24) " "
EQ@[24; 25) "="
WHITESPACE@[25; 26) " "
STRUCT_LIT@[26; 33)
RECORD_LIT@[26; 33)
PATH@[26; 27)
PATH_SEGMENT@[26; 27)
NAME_REF@[26; 27)
IDENT@[26; 27) "F"
NAMED_FIELD_LIST@[27; 33)
RECORD_FIELD_LIST@[27; 33)
L_CURLY@[27; 28) "{"
NAMED_FIELD@[28; 32)
RECORD_FIELD@[28; 32)
NAME_REF@[28; 29)
IDENT@[28; 29) "x"
COLON@[29; 30) ":"

View file

@ -20,10 +20,10 @@ SOURCE_FILE@[0; 32)
IDENT@[12; 16) "Copy"
R_ANGLE@[16; 17) ">"
WHITESPACE@[17; 18) " "
NAMED_FIELD_DEF_LIST@[18; 31)
RECORD_FIELD_DEF_LIST@[18; 31)
L_CURLY@[18; 19) "{"
WHITESPACE@[19; 24) "\n "
NAMED_FIELD_DEF@[24; 28)
RECORD_FIELD_DEF@[24; 28)
NAME@[24; 25)
IDENT@[24; 25) "f"
COLON@[25; 26) ":"

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 25)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
NAMED_FIELD_DEF_LIST@[9; 25)
RECORD_FIELD_DEF_LIST@[9; 25)
L_CURLY@[9; 10) "{"
WHITESPACE@[10; 15) "\n "
NAMED_FIELD_DEF@[15; 23)
RECORD_FIELD_DEF@[15; 23)
NAME@[15; 18)
IDENT@[15; 18) "foo"
COLON@[18; 19) ":"

View file

@ -46,7 +46,7 @@ SOURCE_FILE@[0; 118)
NAME@[59; 60)
IDENT@[59; 60) "S"
WHITESPACE@[60; 61) " "
NAMED_FIELD_DEF_LIST@[61; 63)
RECORD_FIELD_DEF_LIST@[61; 63)
L_CURLY@[61; 62) "{"
R_CURLY@[62; 63) "}"
WHITESPACE@[63; 64) "\n"

View file

@ -12,7 +12,7 @@ SOURCE_FILE@[0; 97)
NAME@[17; 18)
IDENT@[17; 18) "B"
WHITESPACE@[18; 19) " "
NAMED_FIELD_DEF_LIST@[19; 21)
RECORD_FIELD_DEF_LIST@[19; 21)
L_CURLY@[19; 20) "{"
R_CURLY@[20; 21) "}"
WHITESPACE@[21; 22) "\n"
@ -21,7 +21,7 @@ SOURCE_FILE@[0; 97)
WHITESPACE@[28; 29) " "
NAME@[29; 30)
IDENT@[29; 30) "C"
POS_FIELD_DEF_LIST@[30; 32)
TUPLE_FIELD_DEF_LIST@[30; 32)
L_PAREN@[30; 31) "("
R_PAREN@[31; 32) ")"
SEMI@[32; 33) ";"
@ -32,10 +32,10 @@ SOURCE_FILE@[0; 97)
NAME@[42; 43)
IDENT@[42; 43) "D"
WHITESPACE@[43; 44) " "
NAMED_FIELD_DEF_LIST@[44; 74)
RECORD_FIELD_DEF_LIST@[44; 74)
L_CURLY@[44; 45) "{"
WHITESPACE@[45; 50) "\n "
NAMED_FIELD_DEF@[50; 56)
RECORD_FIELD_DEF@[50; 56)
NAME@[50; 51)
IDENT@[50; 51) "a"
COLON@[51; 52) ":"
@ -47,7 +47,7 @@ SOURCE_FILE@[0; 97)
IDENT@[53; 56) "u32"
COMMA@[56; 57) ","
WHITESPACE@[57; 62) "\n "
NAMED_FIELD_DEF@[62; 72)
RECORD_FIELD_DEF@[62; 72)
VISIBILITY@[62; 65)
PUB_KW@[62; 65) "pub"
WHITESPACE@[65; 66) " "
@ -68,9 +68,9 @@ SOURCE_FILE@[0; 97)
WHITESPACE@[82; 83) " "
NAME@[83; 84)
IDENT@[83; 84) "E"
POS_FIELD_DEF_LIST@[84; 95)
TUPLE_FIELD_DEF_LIST@[84; 95)
L_PAREN@[84; 85) "("
POS_FIELD_DEF@[85; 90)
TUPLE_FIELD_DEF@[85; 90)
VISIBILITY@[85; 88)
PUB_KW@[85; 88) "pub"
WHITESPACE@[88; 89) " "
@ -81,7 +81,7 @@ SOURCE_FILE@[0; 97)
IDENT@[89; 90) "x"
COMMA@[90; 91) ","
WHITESPACE@[91; 92) " "
POS_FIELD_DEF@[92; 93)
TUPLE_FIELD_DEF@[92; 93)
PATH_TYPE@[92; 93)
PATH@[92; 93)
PATH_SEGMENT@[92; 93)

View file

@ -23,9 +23,9 @@ SOURCE_FILE@[0; 290)
NAME@[24; 25)
IDENT@[24; 25) "T"
R_ANGLE@[25; 26) ">"
POS_FIELD_DEF_LIST@[26; 31)
TUPLE_FIELD_DEF_LIST@[26; 31)
L_PAREN@[26; 27) "("
POS_FIELD_DEF@[27; 30)
TUPLE_FIELD_DEF@[27; 30)
PATH_TYPE@[27; 30)
PATH@[27; 30)
PATH_SEGMENT@[27; 30)
@ -46,10 +46,10 @@ SOURCE_FILE@[0; 290)
IDENT@[43; 44) "T"
R_ANGLE@[44; 45) ">"
WHITESPACE@[45; 46) " "
NAMED_FIELD_DEF_LIST@[46; 56)
RECORD_FIELD_DEF_LIST@[46; 56)
L_CURLY@[46; 47) "{"
WHITESPACE@[47; 48) " "
NAMED_FIELD_DEF@[48; 54)
RECORD_FIELD_DEF@[48; 54)
NAME@[48; 49)
IDENT@[48; 49) "u"
COLON@[49; 50) ":"

View file

@ -86,10 +86,10 @@ SOURCE_FILE@[0; 182)
NAME@[101; 102)
IDENT@[101; 102) "C"
WHITESPACE@[102; 103) " "
NAMED_FIELD_DEF_LIST@[103; 146)
RECORD_FIELD_DEF_LIST@[103; 146)
L_CURLY@[103; 104) "{"
WHITESPACE@[104; 113) "\n "
NAMED_FIELD_DEF@[113; 119)
RECORD_FIELD_DEF@[113; 119)
NAME@[113; 114)
IDENT@[113; 114) "a"
COLON@[114; 115) ":"
@ -101,7 +101,7 @@ SOURCE_FILE@[0; 182)
IDENT@[116; 119) "u32"
COMMA@[119; 120) ","
WHITESPACE@[120; 129) "\n "
NAMED_FIELD_DEF@[129; 139)
RECORD_FIELD_DEF@[129; 139)
VISIBILITY@[129; 132)
PUB_KW@[129; 132) "pub"
WHITESPACE@[132; 133) " "
@ -123,7 +123,7 @@ SOURCE_FILE@[0; 182)
NAME@[152; 153)
IDENT@[152; 153) "F"
WHITESPACE@[153; 154) " "
NAMED_FIELD_DEF_LIST@[154; 156)
RECORD_FIELD_DEF_LIST@[154; 156)
L_CURLY@[154; 155) "{"
R_CURLY@[155; 156) "}"
COMMA@[156; 157) ","
@ -131,9 +131,9 @@ SOURCE_FILE@[0; 182)
ENUM_VARIANT@[162; 169)
NAME@[162; 163)
IDENT@[162; 163) "D"
POS_FIELD_DEF_LIST@[163; 169)
TUPLE_FIELD_DEF_LIST@[163; 169)
L_PAREN@[163; 164) "("
POS_FIELD_DEF@[164; 167)
TUPLE_FIELD_DEF@[164; 167)
PATH_TYPE@[164; 167)
PATH@[164; 167)
PATH_SEGMENT@[164; 167)
@ -146,7 +146,7 @@ SOURCE_FILE@[0; 182)
ENUM_VARIANT@[175; 178)
NAME@[175; 176)
IDENT@[175; 176) "E"
POS_FIELD_DEF_LIST@[176; 178)
TUPLE_FIELD_DEF_LIST@[176; 178)
L_PAREN@[176; 177) "("
R_PAREN@[177; 178) ")"
COMMA@[178; 179) ","

View file

@ -1564,10 +1564,10 @@ SOURCE_FILE@[0; 3813)
LIFETIME@[2863; 2869) "\'union"
R_ANGLE@[2869; 2870) ">"
WHITESPACE@[2870; 2871) " "
NAMED_FIELD_DEF_LIST@[2871; 2904)
RECORD_FIELD_DEF_LIST@[2871; 2904)
L_CURLY@[2871; 2872) "{"
WHITESPACE@[2872; 2873) " "
NAMED_FIELD_DEF@[2873; 2901)
RECORD_FIELD_DEF@[2873; 2901)
NAME@[2873; 2878)
IDENT@[2873; 2878) "union"
COLON@[2878; 2879) ":"

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 27)
NAME@[7; 8)
IDENT@[7; 8) "S"
WHITESPACE@[8; 9) " "
NAMED_FIELD_DEF_LIST@[9; 27)
RECORD_FIELD_DEF_LIST@[9; 27)
L_CURLY@[9; 10) "{"
WHITESPACE@[10; 15) "\n "
NAMED_FIELD_DEF@[15; 25)
RECORD_FIELD_DEF@[15; 25)
NAME@[15; 20)
IDENT@[15; 20) "r#foo"
COLON@[20; 21) ":"

View file

@ -7,10 +7,10 @@ SOURCE_FILE@[0; 160)
NAME@[69; 73)
IDENT@[69; 73) "Repr"
WHITESPACE@[73; 74) " "
NAMED_FIELD_DEF_LIST@[74; 90)
RECORD_FIELD_DEF_LIST@[74; 90)
L_CURLY@[74; 75) "{"
WHITESPACE@[75; 76) " "
NAMED_FIELD_DEF@[76; 88)
RECORD_FIELD_DEF@[76; 88)
NAME@[76; 79)
IDENT@[76; 79) "raw"
COLON@[79; 80) ":"
@ -46,16 +46,16 @@ SOURCE_FILE@[0; 160)
BIN_EXPR@[107; 135)
INDEX_EXPR@[107; 131)
FIELD_EXPR@[107; 128)
STRUCT_LIT@[107; 124)
RECORD_LIT@[107; 124)
PATH@[107; 111)
PATH_SEGMENT@[107; 111)
NAME_REF@[107; 111)
IDENT@[107; 111) "Repr"
WHITESPACE@[111; 112) " "
NAMED_FIELD_LIST@[112; 124)
RECORD_FIELD_LIST@[112; 124)
L_CURLY@[112; 113) "{"
WHITESPACE@[113; 114) " "
NAMED_FIELD@[114; 122)
RECORD_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)
STRUCT_LIT@[141; 154)
RECORD_LIT@[141; 154)
PATH@[141; 145)
PATH_SEGMENT@[141; 145)
NAME_REF@[141; 145)
IDENT@[141; 145) "Repr"
NAMED_FIELD_LIST@[145; 154)
RECORD_FIELD_LIST@[145; 154)
L_CURLY@[145; 146) "{"
NAMED_FIELD@[146; 153)
RECORD_FIELD@[146; 153)
NAME_REF@[146; 149)
IDENT@[146; 149) "raw"
COLON@[149; 150) ":"

View file

@ -268,9 +268,9 @@ SOURCE_FILE@[0; 395)
ENUM_VARIANT@[356; 365)
NAME@[356; 357)
IDENT@[356; 357) "B"
POS_FIELD_DEF_LIST@[357; 365)
TUPLE_FIELD_DEF_LIST@[357; 365)
L_PAREN@[357; 358) "("
POS_FIELD_DEF@[358; 360)
TUPLE_FIELD_DEF@[358; 360)
PATH_TYPE@[358; 360)
PATH@[358; 360)
PATH_SEGMENT@[358; 360)
@ -278,7 +278,7 @@ SOURCE_FILE@[0; 395)
IDENT@[358; 360) "i8"
COMMA@[360; 361) ","
WHITESPACE@[361; 362) " "
POS_FIELD_DEF@[362; 364)
TUPLE_FIELD_DEF@[362; 364)
PATH_TYPE@[362; 364)
PATH@[362; 364)
PATH_SEGMENT@[362; 364)