diff options
38 files changed, 145 insertions, 139 deletions
diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index 52e24af6c..12018fc6a 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs | |||
@@ -240,7 +240,7 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> { | |||
240 | Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 240 | Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
241 | Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 241 | Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
242 | Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 242 | Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
243 | Expr::RecordLit(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 243 | Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
244 | Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 244 | Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
245 | Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 245 | Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
246 | Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 246 | Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs index 098adf078..b925a2884 100644 --- a/crates/ra_assists/src/handlers/extract_variable.rs +++ b/crates/ra_assists/src/handlers/extract_variable.rs | |||
@@ -45,7 +45,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
45 | target, | 45 | target, |
46 | move |edit| { | 46 | move |edit| { |
47 | let field_shorthand = | 47 | let field_shorthand = |
48 | match to_extract.syntax().parent().and_then(ast::RecordField::cast) { | 48 | match to_extract.syntax().parent().and_then(ast::RecordExprField::cast) { |
49 | Some(field) => field.name_ref(), | 49 | Some(field) => field.name_ref(), |
50 | None => None, | 50 | None => None, |
51 | }; | 51 | }; |
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 1d3ed3c6a..1aefa79cc 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O | |||
82 | } | 82 | } |
83 | 83 | ||
84 | fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 84 | fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
85 | let record_field: ast::RecordField = ctx.find_node_at_offset()?; | 85 | let record_field: ast::RecordExprField = ctx.find_node_at_offset()?; |
86 | let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; | 86 | let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; |
87 | 87 | ||
88 | let current_module = ctx.sema.scope(record_field.syntax()).module()?; | 88 | let current_module = ctx.sema.scope(record_field.syntax()).module()?; |
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index 2ac1c56cf..120250e79 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs | |||
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
23 | // ``` | 23 | // ``` |
24 | // | 24 | // |
25 | pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 25 | pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
26 | reorder::<ast::RecordLit>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) | 26 | reorder::<ast::RecordExpr>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) |
27 | } | 27 | } |
28 | 28 | ||
29 | fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 29 | fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
@@ -56,7 +56,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
56 | 56 | ||
57 | fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { | 57 | fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { |
58 | match node.kind() { | 58 | match node.kind() { |
59 | RECORD_LIT => vec![RECORD_FIELD], | 59 | RECORD_EXPR => vec![RECORD_EXPR_FIELD], |
60 | RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], | 60 | RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], |
61 | _ => vec![], | 61 | _ => vec![], |
62 | } | 62 | } |
@@ -65,7 +65,7 @@ fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { | |||
65 | fn get_field_name(node: &SyntaxNode) -> String { | 65 | fn get_field_name(node: &SyntaxNode) -> String { |
66 | let res = match_ast! { | 66 | let res = match_ast! { |
67 | match node { | 67 | match node { |
68 | ast::RecordField(field) => field.field_name().map(|it| it.to_string()), | 68 | ast::RecordExprField(field) => field.field_name().map(|it| it.to_string()), |
69 | ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), | 69 | ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), |
70 | _ => None, | 70 | _ => None, |
71 | } | 71 | } |
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 054405966..a654c618f 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -209,7 +209,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
209 | self.imp.resolve_field(field) | 209 | self.imp.resolve_field(field) |
210 | } | 210 | } |
211 | 211 | ||
212 | pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { | 212 | pub fn resolve_record_field( |
213 | &self, | ||
214 | field: &ast::RecordExprField, | ||
215 | ) -> Option<(Field, Option<Local>)> { | ||
213 | self.imp.resolve_record_field(field) | 216 | self.imp.resolve_record_field(field) |
214 | } | 217 | } |
215 | 218 | ||
@@ -225,7 +228,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
225 | self.imp.resolve_path(path) | 228 | self.imp.resolve_path(path) |
226 | } | 229 | } |
227 | 230 | ||
228 | pub fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantDef> { | 231 | pub fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantDef> { |
229 | self.imp.resolve_variant(record_lit).map(VariantDef::from) | 232 | self.imp.resolve_variant(record_lit).map(VariantDef::from) |
230 | } | 233 | } |
231 | 234 | ||
@@ -240,7 +243,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
240 | // FIXME: use this instead? | 243 | // FIXME: use this instead? |
241 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; | 244 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; |
242 | 245 | ||
243 | pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { | 246 | pub fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> { |
244 | self.imp.record_literal_missing_fields(literal) | 247 | self.imp.record_literal_missing_fields(literal) |
245 | } | 248 | } |
246 | 249 | ||
@@ -422,7 +425,7 @@ impl<'db> SemanticsImpl<'db> { | |||
422 | self.analyze(field.syntax()).resolve_field(self.db, field) | 425 | self.analyze(field.syntax()).resolve_field(self.db, field) |
423 | } | 426 | } |
424 | 427 | ||
425 | fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { | 428 | fn resolve_record_field(&self, field: &ast::RecordExprField) -> Option<(Field, Option<Local>)> { |
426 | self.analyze(field.syntax()).resolve_record_field(self.db, field) | 429 | self.analyze(field.syntax()).resolve_record_field(self.db, field) |
427 | } | 430 | } |
428 | 431 | ||
@@ -440,7 +443,7 @@ impl<'db> SemanticsImpl<'db> { | |||
440 | self.analyze(path.syntax()).resolve_path(self.db, path) | 443 | self.analyze(path.syntax()).resolve_path(self.db, path) |
441 | } | 444 | } |
442 | 445 | ||
443 | fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantId> { | 446 | fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantId> { |
444 | self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) | 447 | self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) |
445 | } | 448 | } |
446 | 449 | ||
@@ -453,7 +456,7 @@ impl<'db> SemanticsImpl<'db> { | |||
453 | self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) | 456 | self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) |
454 | } | 457 | } |
455 | 458 | ||
456 | fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { | 459 | fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> { |
457 | self.analyze(literal.syntax()) | 460 | self.analyze(literal.syntax()) |
458 | .record_literal_missing_fields(self.db, literal) | 461 | .record_literal_missing_fields(self.db, literal) |
459 | .unwrap_or_default() | 462 | .unwrap_or_default() |
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 86a47a9e5..8f438bba0 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs | |||
@@ -159,7 +159,7 @@ impl SourceAnalyzer { | |||
159 | pub(crate) fn resolve_record_field( | 159 | pub(crate) fn resolve_record_field( |
160 | &self, | 160 | &self, |
161 | db: &dyn HirDatabase, | 161 | db: &dyn HirDatabase, |
162 | field: &ast::RecordField, | 162 | field: &ast::RecordExprField, |
163 | ) -> Option<(Field, Option<Local>)> { | 163 | ) -> Option<(Field, Option<Local>)> { |
164 | let expr = field.expr()?; | 164 | let expr = field.expr()?; |
165 | let expr_id = self.expr_id(db, &expr)?; | 165 | let expr_id = self.expr_id(db, &expr)?; |
@@ -246,7 +246,7 @@ impl SourceAnalyzer { | |||
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordLit::cast) { | 249 | if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordExpr::cast) { |
250 | let expr_id = self.expr_id(db, &rec_lit.into())?; | 250 | let expr_id = self.expr_id(db, &rec_lit.into())?; |
251 | if let Some(VariantId::EnumVariantId(variant)) = | 251 | if let Some(VariantId::EnumVariantId(variant)) = |
252 | self.infer.as_ref()?.variant_resolution_for_expr(expr_id) | 252 | self.infer.as_ref()?.variant_resolution_for_expr(expr_id) |
@@ -284,7 +284,7 @@ impl SourceAnalyzer { | |||
284 | pub(crate) fn record_literal_missing_fields( | 284 | pub(crate) fn record_literal_missing_fields( |
285 | &self, | 285 | &self, |
286 | db: &dyn HirDatabase, | 286 | db: &dyn HirDatabase, |
287 | literal: &ast::RecordLit, | 287 | literal: &ast::RecordExpr, |
288 | ) -> Option<Vec<(Field, Type)>> { | 288 | ) -> Option<Vec<(Field, Type)>> { |
289 | let krate = self.resolver.krate()?; | 289 | let krate = self.resolver.krate()?; |
290 | let body = self.body.as_ref()?; | 290 | let body = self.body.as_ref()?; |
@@ -358,7 +358,7 @@ impl SourceAnalyzer { | |||
358 | pub(crate) fn resolve_variant( | 358 | pub(crate) fn resolve_variant( |
359 | &self, | 359 | &self, |
360 | db: &dyn HirDatabase, | 360 | db: &dyn HirDatabase, |
361 | record_lit: ast::RecordLit, | 361 | record_lit: ast::RecordExpr, |
362 | ) -> Option<VariantId> { | 362 | ) -> Option<VariantId> { |
363 | let infer = self.infer.as_ref()?; | 363 | let infer = self.infer.as_ref()?; |
364 | let expr_id = self.expr_id(db, &record_lit.into())?; | 364 | let expr_id = self.expr_id(db, &record_lit.into())?; |
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 2fe04db2b..d5f18b920 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -216,7 +216,7 @@ pub struct BodySourceMap { | |||
216 | expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>, | 216 | expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>, |
217 | pat_map: FxHashMap<PatSource, PatId>, | 217 | pat_map: FxHashMap<PatSource, PatId>, |
218 | pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>, | 218 | pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>, |
219 | field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordField>>>, | 219 | field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordExprField>>>, |
220 | expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, | 220 | expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, |
221 | } | 221 | } |
222 | 222 | ||
@@ -314,7 +314,7 @@ impl BodySourceMap { | |||
314 | self.pat_map.get(&src).cloned() | 314 | self.pat_map.get(&src).cloned() |
315 | } | 315 | } |
316 | 316 | ||
317 | pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordField>> { | 317 | pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordExprField>> { |
318 | self.field_map[&(expr, field)].clone() | 318 | self.field_map[&(expr, field)].clone() |
319 | } | 319 | } |
320 | } | 320 | } |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index f463997e7..576342af9 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -379,10 +379,10 @@ impl ExprCollector<'_> { | |||
379 | let expr = e.expr().map(|e| self.collect_expr(e)); | 379 | let expr = e.expr().map(|e| self.collect_expr(e)); |
380 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) | 380 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) |
381 | } | 381 | } |
382 | ast::Expr::RecordLit(e) => { | 382 | ast::Expr::RecordExpr(e) => { |
383 | let path = e.path().and_then(|path| self.expander.parse_path(path)); | 383 | let path = e.path().and_then(|path| self.expander.parse_path(path)); |
384 | let mut field_ptrs = Vec::new(); | 384 | let mut field_ptrs = Vec::new(); |
385 | let record_lit = if let Some(nfl) = e.record_field_list() { | 385 | let record_lit = if let Some(nfl) = e.record_expr_field_list() { |
386 | let fields = nfl | 386 | let fields = nfl |
387 | .fields() | 387 | .fields() |
388 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) | 388 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) |
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index e0ad1567f..41df66696 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -386,7 +386,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind { | |||
386 | MATCH_EXPR => FragmentKind::Expr, | 386 | MATCH_EXPR => FragmentKind::Expr, |
387 | MATCH_ARM => FragmentKind::Expr, | 387 | MATCH_ARM => FragmentKind::Expr, |
388 | MATCH_GUARD => FragmentKind::Expr, | 388 | MATCH_GUARD => FragmentKind::Expr, |
389 | RECORD_FIELD => FragmentKind::Expr, | 389 | RECORD_EXPR_FIELD => FragmentKind::Expr, |
390 | CALL_EXPR => FragmentKind::Expr, | 390 | CALL_EXPR => FragmentKind::Expr, |
391 | INDEX_EXPR => FragmentKind::Expr, | 391 | INDEX_EXPR => FragmentKind::Expr, |
392 | METHOD_CALL_EXPR => FragmentKind::Expr, | 392 | METHOD_CALL_EXPR => FragmentKind::Expr, |
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 885abbaf2..f210c305a 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs | |||
@@ -29,7 +29,7 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag | |||
29 | #[derive(Debug)] | 29 | #[derive(Debug)] |
30 | pub struct NoSuchField { | 30 | pub struct NoSuchField { |
31 | pub file: HirFileId, | 31 | pub file: HirFileId, |
32 | pub field: AstPtr<ast::RecordField>, | 32 | pub field: AstPtr<ast::RecordExprField>, |
33 | } | 33 | } |
34 | 34 | ||
35 | impl Diagnostic for NoSuchField { | 35 | impl Diagnostic for NoSuchField { |
@@ -47,19 +47,19 @@ impl Diagnostic for NoSuchField { | |||
47 | } | 47 | } |
48 | 48 | ||
49 | impl AstDiagnostic for NoSuchField { | 49 | impl AstDiagnostic for NoSuchField { |
50 | type AST = ast::RecordField; | 50 | type AST = ast::RecordExprField; |
51 | 51 | ||
52 | fn ast(&self, db: &dyn AstDatabase) -> Self::AST { | 52 | fn ast(&self, db: &dyn AstDatabase) -> Self::AST { |
53 | let root = db.parse_or_expand(self.source().file_id).unwrap(); | 53 | let root = db.parse_or_expand(self.source().file_id).unwrap(); |
54 | let node = self.source().value.to_node(&root); | 54 | let node = self.source().value.to_node(&root); |
55 | ast::RecordField::cast(node).unwrap() | 55 | ast::RecordExprField::cast(node).unwrap() |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | #[derive(Debug)] | 59 | #[derive(Debug)] |
60 | pub struct MissingFields { | 60 | pub struct MissingFields { |
61 | pub file: HirFileId, | 61 | pub file: HirFileId, |
62 | pub field_list: AstPtr<ast::RecordFieldList>, | 62 | pub field_list: AstPtr<ast::RecordExprFieldList>, |
63 | pub missed_fields: Vec<Name>, | 63 | pub missed_fields: Vec<Name>, |
64 | } | 64 | } |
65 | 65 | ||
@@ -80,12 +80,12 @@ impl Diagnostic for MissingFields { | |||
80 | } | 80 | } |
81 | 81 | ||
82 | impl AstDiagnostic for MissingFields { | 82 | impl AstDiagnostic for MissingFields { |
83 | type AST = ast::RecordFieldList; | 83 | type AST = ast::RecordExprFieldList; |
84 | 84 | ||
85 | fn ast(&self, db: &dyn AstDatabase) -> Self::AST { | 85 | fn ast(&self, db: &dyn AstDatabase) -> Self::AST { |
86 | let root = db.parse_or_expand(self.source().file_id).unwrap(); | 86 | let root = db.parse_or_expand(self.source().file_id).unwrap(); |
87 | let node = self.source().value.to_node(&root); | 87 | let node = self.source().value.to_node(&root); |
88 | ast::RecordFieldList::cast(node).unwrap() | 88 | ast::RecordExprFieldList::cast(node).unwrap() |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs index fd930eab1..f0e0f2988 100644 --- a/crates/ra_hir_ty/src/diagnostics/expr.rs +++ b/crates/ra_hir_ty/src/diagnostics/expr.rs | |||
@@ -100,8 +100,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
100 | 100 | ||
101 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 101 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
102 | let root = source_ptr.file_syntax(db.upcast()); | 102 | let root = source_ptr.file_syntax(db.upcast()); |
103 | if let ast::Expr::RecordLit(record_lit) = &source_ptr.value.to_node(&root) { | 103 | if let ast::Expr::RecordExpr(record_lit) = &source_ptr.value.to_node(&root) { |
104 | if let Some(field_list) = record_lit.record_field_list() { | 104 | if let Some(field_list) = record_lit.record_expr_field_list() { |
105 | let variant_data = variant_data(db.upcast(), variant_def); | 105 | let variant_data = variant_data(db.upcast(), variant_def); |
106 | let missed_fields = missed_fields | 106 | let missed_fields = missed_fields |
107 | .into_iter() | 107 | .into_iter() |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 221d7847e..c8704eb3e 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -37,9 +37,9 @@ pub(crate) struct CompletionContext<'a> { | |||
37 | pub(super) name_ref_syntax: Option<ast::NameRef>, | 37 | pub(super) name_ref_syntax: Option<ast::NameRef>, |
38 | pub(super) function_syntax: Option<ast::Fn>, | 38 | pub(super) function_syntax: Option<ast::Fn>, |
39 | pub(super) use_item_syntax: Option<ast::Use>, | 39 | pub(super) use_item_syntax: Option<ast::Use>, |
40 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 40 | pub(super) record_lit_syntax: Option<ast::RecordExpr>, |
41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, | 41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, |
42 | pub(super) record_field_syntax: Option<ast::RecordField>, | 42 | pub(super) record_field_syntax: Option<ast::RecordExprField>, |
43 | pub(super) impl_def: Option<ast::ImplDef>, | 43 | pub(super) impl_def: Option<ast::ImplDef>, |
44 | /// FIXME: `ActiveParameter` is string-based, which is very very wrong | 44 | /// FIXME: `ActiveParameter` is string-based, which is very very wrong |
45 | pub(super) active_parameter: Option<ActiveParameter>, | 45 | pub(super) active_parameter: Option<ActiveParameter>, |
@@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> { | |||
316 | self.name_ref_syntax = | 316 | self.name_ref_syntax = |
317 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); | 317 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); |
318 | let name_range = name_ref.syntax().text_range(); | 318 | let name_range = name_ref.syntax().text_range(); |
319 | if ast::RecordField::for_field_name(&name_ref).is_some() { | 319 | if ast::RecordExprField::for_field_name(&name_ref).is_some() { |
320 | self.record_lit_syntax = | 320 | self.record_lit_syntax = |
321 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | 321 | self.sema.find_node_at_offset_with_macros(&original_file, offset); |
322 | } | 322 | } |
@@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> { | |||
357 | .take_while(|it| { | 357 | .take_while(|it| { |
358 | it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR | 358 | it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR |
359 | }) | 359 | }) |
360 | .find_map(ast::RecordField::cast); | 360 | .find_map(ast::RecordExprField::cast); |
361 | 361 | ||
362 | let parent = match name_ref.syntax().parent() { | 362 | let parent = match name_ref.syntax().parent() { |
363 | Some(it) => it, | 363 | Some(it) => it, |
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 897177d05..efbb00d6d 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs | |||
@@ -146,7 +146,7 @@ fn missing_struct_field_fix( | |||
146 | ) -> Option<Fix> { | 146 | ) -> Option<Fix> { |
147 | let record_expr = sema.ast(d); | 147 | let record_expr = sema.ast(d); |
148 | 148 | ||
149 | let record_lit = ast::RecordLit::cast(record_expr.syntax().parent()?.parent()?)?; | 149 | let record_lit = ast::RecordExpr::cast(record_expr.syntax().parent()?.parent()?)?; |
150 | let def_id = sema.resolve_variant(record_lit)?; | 150 | let def_id = sema.resolve_variant(record_lit)?; |
151 | let module; | 151 | let module; |
152 | let def_file_id; | 152 | let def_file_id; |
@@ -263,8 +263,8 @@ fn check_struct_shorthand_initialization( | |||
263 | file_id: FileId, | 263 | file_id: FileId, |
264 | node: &SyntaxNode, | 264 | node: &SyntaxNode, |
265 | ) -> Option<()> { | 265 | ) -> Option<()> { |
266 | let record_lit = ast::RecordLit::cast(node.clone())?; | 266 | let record_lit = ast::RecordExpr::cast(node.clone())?; |
267 | let record_field_list = record_lit.record_field_list()?; | 267 | let record_field_list = record_lit.record_expr_field_list()?; |
268 | for record_field in record_field_list.fields() { | 268 | for record_field in record_field_list.fields() { |
269 | if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) { | 269 | if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) { |
270 | let field_name = name_ref.syntax().text().to_string(); | 270 | let field_name = name_ref.syntax().text().to_string(); |
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index b1c4561c1..597a7d82f 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs | |||
@@ -41,7 +41,7 @@ fn try_extend_selection( | |||
41 | MATCH_ARM_LIST, | 41 | MATCH_ARM_LIST, |
42 | RECORD_FIELD_DEF_LIST, | 42 | RECORD_FIELD_DEF_LIST, |
43 | TUPLE_FIELD_DEF_LIST, | 43 | TUPLE_FIELD_DEF_LIST, |
44 | RECORD_FIELD_LIST, | 44 | RECORD_EXPR_FIELD_LIST, |
45 | ENUM_VARIANT_LIST, | 45 | ENUM_VARIANT_LIST, |
46 | USE_TREE_LIST, | 46 | USE_TREE_LIST, |
47 | GENERIC_PARAM_LIST, | 47 | GENERIC_PARAM_LIST, |
diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs index bad079146..972505450 100644 --- a/crates/ra_ide/src/folding_ranges.rs +++ b/crates/ra_ide/src/folding_ranges.rs | |||
@@ -87,7 +87,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { | |||
87 | ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), | 87 | ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), |
88 | RECORD_FIELD_DEF_LIST | 88 | RECORD_FIELD_DEF_LIST |
89 | | RECORD_FIELD_PAT_LIST | 89 | | RECORD_FIELD_PAT_LIST |
90 | | RECORD_FIELD_LIST | 90 | | RECORD_EXPR_FIELD_LIST |
91 | | ITEM_LIST | 91 | | ITEM_LIST |
92 | | EXTERN_ITEM_LIST | 92 | | EXTERN_ITEM_LIST |
93 | | USE_TREE_LIST | 93 | | USE_TREE_LIST |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index f2e4f7ee5..714ba6bd9 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -96,7 +96,7 @@ fn get_chaining_hints( | |||
96 | return None; | 96 | return None; |
97 | } | 97 | } |
98 | 98 | ||
99 | if matches!(expr, ast::Expr::RecordLit(_)) { | 99 | if matches!(expr, ast::Expr::RecordExpr(_)) { |
100 | return None; | 100 | return None; |
101 | } | 101 | } |
102 | 102 | ||
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 0e73a8932..6ea7f173b 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -236,7 +236,7 @@ pub fn classify_name_ref( | |||
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | if let Some(record_field) = ast::RecordField::for_field_name(name_ref) { | 239 | if let Some(record_field) = ast::RecordExprField::for_field_name(name_ref) { |
240 | if let Some((field, local)) = sema.resolve_record_field(&record_field) { | 240 | if let Some((field, local)) = sema.resolve_record_field(&record_field) { |
241 | let field = Definition::Field(field); | 241 | let field = Definition::Field(field); |
242 | let res = match local { | 242 | let res = match local { |
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index a7cae37b0..0b862b449 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs | |||
@@ -315,7 +315,7 @@ fn is_record_lit_name_ref(name_ref: &ast::NameRef) -> bool { | |||
315 | name_ref | 315 | name_ref |
316 | .syntax() | 316 | .syntax() |
317 | .ancestors() | 317 | .ancestors() |
318 | .find_map(ast::RecordLit::cast) | 318 | .find_map(ast::RecordExpr::cast) |
319 | .and_then(|l| l.path()) | 319 | .and_then(|l| l.path()) |
320 | .and_then(|p| p.segment()) | 320 | .and_then(|p| p.segment()) |
321 | .map(|p| p.name_ref().as_ref() == Some(name_ref)) | 321 | .map(|p| p.name_ref().as_ref() == Some(name_ref)) |
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 7dfac2813..3610e7392 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -143,7 +143,7 @@ pub(crate) fn reparser( | |||
143 | let res = match node { | 143 | let res = match node { |
144 | BLOCK_EXPR => expressions::block_expr, | 144 | BLOCK_EXPR => expressions::block_expr, |
145 | RECORD_FIELD_DEF_LIST => items::record_field_def_list, | 145 | RECORD_FIELD_DEF_LIST => items::record_field_def_list, |
146 | RECORD_FIELD_LIST => items::record_field_list, | 146 | RECORD_EXPR_FIELD_LIST => items::record_field_list, |
147 | ENUM_VARIANT_LIST => items::enum_variant_list, | 147 | ENUM_VARIANT_LIST => items::enum_variant_list, |
148 | MATCH_ARM_LIST => items::match_arm_list, | 148 | MATCH_ARM_LIST => items::match_arm_list, |
149 | USE_TREE_LIST => items::use_tree_list, | 149 | USE_TREE_LIST => items::use_tree_list, |
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 6e72eea66..e1c25a838 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -587,7 +587,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { | |||
587 | match p.current() { | 587 | match p.current() { |
588 | T!['{'] if !r.forbid_structs => { | 588 | T!['{'] if !r.forbid_structs => { |
589 | record_field_list(p); | 589 | record_field_list(p); |
590 | (m.complete(p, RECORD_LIT), BlockLike::NotBlock) | 590 | (m.complete(p, RECORD_EXPR), BlockLike::NotBlock) |
591 | } | 591 | } |
592 | T![!] if !p.at(T![!=]) => { | 592 | T![!] if !p.at(T![!=]) => { |
593 | let block_like = items::macro_call_after_excl(p); | 593 | let block_like = items::macro_call_after_excl(p); |
@@ -627,7 +627,7 @@ pub(crate) fn record_field_list(p: &mut Parser) { | |||
627 | p.expect(T![:]); | 627 | p.expect(T![:]); |
628 | } | 628 | } |
629 | expr(p); | 629 | expr(p); |
630 | m.complete(p, RECORD_FIELD); | 630 | m.complete(p, RECORD_EXPR_FIELD); |
631 | } | 631 | } |
632 | T![.] if p.at(T![..]) => { | 632 | T![.] if p.at(T![..]) => { |
633 | m.abandon(p); | 633 | m.abandon(p); |
@@ -648,5 +648,5 @@ pub(crate) fn record_field_list(p: &mut Parser) { | |||
648 | } | 648 | } |
649 | } | 649 | } |
650 | p.expect(T!['}']); | 650 | p.expect(T!['}']); |
651 | m.complete(p, RECORD_FIELD_LIST); | 651 | m.complete(p, RECORD_EXPR_FIELD_LIST); |
652 | } | 652 | } |
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index b83690865..ac79786ff 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -188,9 +188,9 @@ pub enum SyntaxKind { | |||
188 | MATCH_ARM_LIST, | 188 | MATCH_ARM_LIST, |
189 | MATCH_ARM, | 189 | MATCH_ARM, |
190 | MATCH_GUARD, | 190 | MATCH_GUARD, |
191 | RECORD_LIT, | 191 | RECORD_EXPR, |
192 | RECORD_FIELD_LIST, | 192 | RECORD_EXPR_FIELD_LIST, |
193 | RECORD_FIELD, | 193 | RECORD_EXPR_FIELD, |
194 | EFFECT_EXPR, | 194 | EFFECT_EXPR, |
195 | BOX_EXPR, | 195 | BOX_EXPR, |
196 | CALL_EXPR, | 196 | CALL_EXPR, |
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs index c1b66748e..74e15c631 100644 --- a/crates/ra_ssr/src/matching.rs +++ b/crates/ra_ssr/src/matching.rs | |||
@@ -209,7 +209,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { | |||
209 | // Some kinds of nodes have special handling. For everything else, we fall back to default | 209 | // Some kinds of nodes have special handling. For everything else, we fall back to default |
210 | // matching. | 210 | // matching. |
211 | match code.kind() { | 211 | match code.kind() { |
212 | SyntaxKind::RECORD_FIELD_LIST => { | 212 | SyntaxKind::RECORD_EXPR_FIELD_LIST => { |
213 | self.attempt_match_record_field_list(phase, pattern, code) | 213 | self.attempt_match_record_field_list(phase, pattern, code) |
214 | } | 214 | } |
215 | SyntaxKind::TOKEN_TREE => self.attempt_match_token_tree(phase, pattern, code), | 215 | SyntaxKind::TOKEN_TREE => self.attempt_match_token_tree(phase, pattern, code), |
@@ -399,7 +399,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { | |||
399 | // Build a map keyed by field name. | 399 | // Build a map keyed by field name. |
400 | let mut fields_by_name = FxHashMap::default(); | 400 | let mut fields_by_name = FxHashMap::default(); |
401 | for child in code.children() { | 401 | for child in code.children() { |
402 | if let Some(record) = ast::RecordField::cast(child.clone()) { | 402 | if let Some(record) = ast::RecordExprField::cast(child.clone()) { |
403 | if let Some(name) = record.field_name() { | 403 | if let Some(name) = record.field_name() { |
404 | fields_by_name.insert(name.text().clone(), child.clone()); | 404 | fields_by_name.insert(name.text().clone(), child.clone()); |
405 | } | 405 | } |
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 0110300af..8d3e42f25 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -116,18 +116,18 @@ impl ast::AssocItemList { | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | impl ast::RecordFieldList { | 119 | impl ast::RecordExprFieldList { |
120 | #[must_use] | 120 | #[must_use] |
121 | pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { | 121 | pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList { |
122 | self.insert_field(InsertPosition::Last, field) | 122 | self.insert_field(InsertPosition::Last, field) |
123 | } | 123 | } |
124 | 124 | ||
125 | #[must_use] | 125 | #[must_use] |
126 | pub fn insert_field( | 126 | pub fn insert_field( |
127 | &self, | 127 | &self, |
128 | position: InsertPosition<&'_ ast::RecordField>, | 128 | position: InsertPosition<&'_ ast::RecordExprField>, |
129 | field: &ast::RecordField, | 129 | field: &ast::RecordExprField, |
130 | ) -> ast::RecordFieldList { | 130 | ) -> ast::RecordExprFieldList { |
131 | let is_multiline = self.syntax().text().contains_char('\n'); | 131 | let is_multiline = self.syntax().text().contains_char('\n'); |
132 | let ws; | 132 | let ws; |
133 | let space = if is_multiline { | 133 | let space = if is_multiline { |
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs index 8692b9bb5..365f94287 100644 --- a/crates/ra_syntax/src/ast/expr_ext.rs +++ b/crates/ra_syntax/src/ast/expr_ext.rs | |||
@@ -412,8 +412,8 @@ fn test_literal_with_attr() { | |||
412 | assert_eq!(lit.token().text(), r#""Hello""#); | 412 | assert_eq!(lit.token().text(), r#""Hello""#); |
413 | } | 413 | } |
414 | 414 | ||
415 | impl ast::RecordField { | 415 | impl ast::RecordExprField { |
416 | pub fn parent_record_lit(&self) -> ast::RecordLit { | 416 | pub fn parent_record_lit(&self) -> ast::RecordExpr { |
417 | self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() | 417 | self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap() |
418 | } | 418 | } |
419 | } | 419 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index efe0cbe3a..9f9c06e50 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -909,30 +909,32 @@ impl MatchGuard { | |||
909 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 909 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
910 | } | 910 | } |
911 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 911 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
912 | pub struct RecordLit { | 912 | pub struct RecordExpr { |
913 | pub(crate) syntax: SyntaxNode, | 913 | pub(crate) syntax: SyntaxNode, |
914 | } | 914 | } |
915 | impl RecordLit { | 915 | impl RecordExpr { |
916 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 916 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
917 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } | 917 | pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> { |
918 | support::child(&self.syntax) | ||
919 | } | ||
918 | } | 920 | } |
919 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 921 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
920 | pub struct RecordFieldList { | 922 | pub struct RecordExprFieldList { |
921 | pub(crate) syntax: SyntaxNode, | 923 | pub(crate) syntax: SyntaxNode, |
922 | } | 924 | } |
923 | impl RecordFieldList { | 925 | impl RecordExprFieldList { |
924 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | 926 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
925 | pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } | 927 | pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) } |
926 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } | 928 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } |
927 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } | 929 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } |
928 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 930 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
929 | } | 931 | } |
930 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 932 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
931 | pub struct RecordField { | 933 | pub struct RecordExprField { |
932 | pub(crate) syntax: SyntaxNode, | 934 | pub(crate) syntax: SyntaxNode, |
933 | } | 935 | } |
934 | impl ast::AttrsOwner for RecordField {} | 936 | impl ast::AttrsOwner for RecordExprField {} |
935 | impl RecordField { | 937 | impl RecordExprField { |
936 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 938 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
937 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 939 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
938 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 940 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
@@ -1345,7 +1347,7 @@ pub enum Expr { | |||
1345 | BlockExpr(BlockExpr), | 1347 | BlockExpr(BlockExpr), |
1346 | ReturnExpr(ReturnExpr), | 1348 | ReturnExpr(ReturnExpr), |
1347 | MatchExpr(MatchExpr), | 1349 | MatchExpr(MatchExpr), |
1348 | RecordLit(RecordLit), | 1350 | RecordExpr(RecordExpr), |
1349 | CallExpr(CallExpr), | 1351 | CallExpr(CallExpr), |
1350 | IndexExpr(IndexExpr), | 1352 | IndexExpr(IndexExpr), |
1351 | MethodCallExpr(MethodCallExpr), | 1353 | MethodCallExpr(MethodCallExpr), |
@@ -2357,8 +2359,8 @@ impl AstNode for MatchGuard { | |||
2357 | } | 2359 | } |
2358 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2360 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2359 | } | 2361 | } |
2360 | impl AstNode for RecordLit { | 2362 | impl AstNode for RecordExpr { |
2361 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } | 2363 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR } |
2362 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2364 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2363 | if Self::can_cast(syntax.kind()) { | 2365 | if Self::can_cast(syntax.kind()) { |
2364 | Some(Self { syntax }) | 2366 | Some(Self { syntax }) |
@@ -2368,8 +2370,8 @@ impl AstNode for RecordLit { | |||
2368 | } | 2370 | } |
2369 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2371 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2370 | } | 2372 | } |
2371 | impl AstNode for RecordFieldList { | 2373 | impl AstNode for RecordExprFieldList { |
2372 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } | 2374 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } |
2373 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2375 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2374 | if Self::can_cast(syntax.kind()) { | 2376 | if Self::can_cast(syntax.kind()) { |
2375 | Some(Self { syntax }) | 2377 | Some(Self { syntax }) |
@@ -2379,8 +2381,8 @@ impl AstNode for RecordFieldList { | |||
2379 | } | 2381 | } |
2380 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2382 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2381 | } | 2383 | } |
2382 | impl AstNode for RecordField { | 2384 | impl AstNode for RecordExprField { |
2383 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } | 2385 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD } |
2384 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2386 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2385 | if Self::can_cast(syntax.kind()) { | 2387 | if Self::can_cast(syntax.kind()) { |
2386 | Some(Self { syntax }) | 2388 | Some(Self { syntax }) |
@@ -3119,8 +3121,8 @@ impl From<ReturnExpr> for Expr { | |||
3119 | impl From<MatchExpr> for Expr { | 3121 | impl From<MatchExpr> for Expr { |
3120 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } | 3122 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } |
3121 | } | 3123 | } |
3122 | impl From<RecordLit> for Expr { | 3124 | impl From<RecordExpr> for Expr { |
3123 | fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) } | 3125 | fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) } |
3124 | } | 3126 | } |
3125 | impl From<CallExpr> for Expr { | 3127 | impl From<CallExpr> for Expr { |
3126 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } | 3128 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } |
@@ -3172,7 +3174,7 @@ impl AstNode for Expr { | |||
3172 | match kind { | 3174 | match kind { |
3173 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | 3175 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR |
3174 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | 3176 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL |
3175 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR | 3177 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_EXPR | CALL_EXPR | INDEX_EXPR |
3176 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR | 3178 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR |
3177 | | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { | 3179 | | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { |
3178 | true | 3180 | true |
@@ -3197,7 +3199,7 @@ impl AstNode for Expr { | |||
3197 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | 3199 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), |
3198 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | 3200 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), |
3199 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | 3201 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), |
3200 | RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), | 3202 | RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }), |
3201 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | 3203 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), |
3202 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | 3204 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), |
3203 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | 3205 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), |
@@ -3234,7 +3236,7 @@ impl AstNode for Expr { | |||
3234 | Expr::BlockExpr(it) => &it.syntax, | 3236 | Expr::BlockExpr(it) => &it.syntax, |
3235 | Expr::ReturnExpr(it) => &it.syntax, | 3237 | Expr::ReturnExpr(it) => &it.syntax, |
3236 | Expr::MatchExpr(it) => &it.syntax, | 3238 | Expr::MatchExpr(it) => &it.syntax, |
3237 | Expr::RecordLit(it) => &it.syntax, | 3239 | Expr::RecordExpr(it) => &it.syntax, |
3238 | Expr::CallExpr(it) => &it.syntax, | 3240 | Expr::CallExpr(it) => &it.syntax, |
3239 | Expr::IndexExpr(it) => &it.syntax, | 3241 | Expr::IndexExpr(it) => &it.syntax, |
3240 | Expr::MethodCallExpr(it) => &it.syntax, | 3242 | Expr::MethodCallExpr(it) => &it.syntax, |
@@ -3893,17 +3895,17 @@ impl std::fmt::Display for MatchGuard { | |||
3893 | std::fmt::Display::fmt(self.syntax(), f) | 3895 | std::fmt::Display::fmt(self.syntax(), f) |
3894 | } | 3896 | } |
3895 | } | 3897 | } |
3896 | impl std::fmt::Display for RecordLit { | 3898 | impl std::fmt::Display for RecordExpr { |
3897 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3899 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3898 | std::fmt::Display::fmt(self.syntax(), f) | 3900 | std::fmt::Display::fmt(self.syntax(), f) |
3899 | } | 3901 | } |
3900 | } | 3902 | } |
3901 | impl std::fmt::Display for RecordFieldList { | 3903 | impl std::fmt::Display for RecordExprFieldList { |
3902 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3904 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3903 | std::fmt::Display::fmt(self.syntax(), f) | 3905 | std::fmt::Display::fmt(self.syntax(), f) |
3904 | } | 3906 | } |
3905 | } | 3907 | } |
3906 | impl std::fmt::Display for RecordField { | 3908 | impl std::fmt::Display for RecordExprField { |
3907 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3909 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3908 | std::fmt::Display::fmt(self.syntax(), f) | 3910 | std::fmt::Display::fmt(self.syntax(), f) |
3909 | } | 3911 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 4759f23a5..183ec4481 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -64,13 +64,13 @@ pub fn use_item(use_tree: ast::UseTree) -> ast::Use { | |||
64 | ast_from_text(&format!("use {};", use_tree)) | 64 | ast_from_text(&format!("use {};", use_tree)) |
65 | } | 65 | } |
66 | 66 | ||
67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { | 67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField { |
68 | return match expr { | 68 | return match expr { |
69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), | 69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), |
70 | None => from_text(&name.to_string()), | 70 | None => from_text(&name.to_string()), |
71 | }; | 71 | }; |
72 | 72 | ||
73 | fn from_text(text: &str) -> ast::RecordField { | 73 | fn from_text(text: &str) -> ast::RecordExprField { |
74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) | 74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) |
75 | } | 75 | } |
76 | } | 76 | } |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index a7a301d6b..8c7457e32 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -189,11 +189,11 @@ impl ast::StructDef { | |||
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | impl ast::RecordField { | 192 | impl ast::RecordExprField { |
193 | pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> { | 193 | pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> { |
194 | let candidate = | 194 | let candidate = |
195 | field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| { | 195 | field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| { |
196 | field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast) | 196 | field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast) |
197 | })?; | 197 | })?; |
198 | if candidate.field_name().as_ref() == Some(field_name) { | 198 | if candidate.field_name().as_ref() == Some(field_name) { |
199 | Some(candidate) | 199 | Some(candidate) |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 6a2749381..5b4e14676 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -91,7 +91,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> { | |||
91 | ast::Literal(it) => validate_literal(it, &mut errors), | 91 | ast::Literal(it) => validate_literal(it, &mut errors), |
92 | ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), | 92 | ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), |
93 | ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), | 93 | ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), |
94 | ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), | 94 | ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), &mut errors), |
95 | ast::Visibility(it) => validate_visibility(it, &mut errors), | 95 | ast::Visibility(it) => validate_visibility(it, &mut errors), |
96 | ast::RangeExpr(it) => validate_range_expr(it, &mut errors), | 96 | ast::RangeExpr(it) => validate_range_expr(it, &mut errors), |
97 | ast::PathSegment(it) => validate_path_keywords(it, &mut errors), | 97 | ast::PathSegment(it) => validate_path_keywords(it, &mut errors), |
diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast index ce43ddf45..1ce5f188f 100644 --- a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast +++ b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast | |||
@@ -75,16 +75,16 @@ [email protected] | |||
75 | [email protected] "push" | 75 | [email protected] "push" |
76 | [email protected] | 76 | [email protected] |
77 | [email protected] "(" | 77 | [email protected] "(" |
78 | RECORD_LIT@111..154 | 78 | RECORD_EXPR@111..154 |
79 | [email protected] | 79 | [email protected] |
80 | [email protected] | 80 | [email protected] |
81 | [email protected] | 81 | [email protected] |
82 | [email protected] "ScopeData" | 82 | [email protected] "ScopeData" |
83 | [email protected] " " | 83 | [email protected] " " |
84 | [email protected] | 84 | RECORD_EXPR_[email protected] |
85 | [email protected] "{" | 85 | [email protected] "{" |
86 | [email protected] " " | 86 | [email protected] " " |
87 | [email protected] | 87 | RECORD_EXPR_[email protected] |
88 | [email protected] | 88 | [email protected] |
89 | [email protected] "parent" | 89 | [email protected] "parent" |
90 | [email protected] ":" | 90 | [email protected] ":" |
@@ -96,7 +96,7 @@ [email protected] | |||
96 | [email protected] "None" | 96 | [email protected] "None" |
97 | [email protected] "," | 97 | [email protected] "," |
98 | [email protected] " " | 98 | [email protected] " " |
99 | [email protected] | 99 | RECORD_EXPR_[email protected] |
100 | [email protected] | 100 | [email protected] |
101 | [email protected] "entries" | 101 | [email protected] "entries" |
102 | [email protected] ":" | 102 | [email protected] ":" |
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast b/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast index 6753c3fe7..a81c442c0 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast +++ b/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast | |||
@@ -11,16 +11,16 @@ [email protected] | |||
11 | [email protected] | 11 | [email protected] |
12 | [email protected] "{" | 12 | [email protected] "{" |
13 | [email protected] "\n " | 13 | [email protected] "\n " |
14 | RECORD_LIT@16..42 | 14 | RECORD_EXPR@16..42 |
15 | [email protected] | 15 | [email protected] |
16 | [email protected] | 16 | [email protected] |
17 | [email protected] | 17 | [email protected] |
18 | [email protected] "S" | 18 | [email protected] "S" |
19 | [email protected] " " | 19 | [email protected] " " |
20 | [email protected] | 20 | RECORD_EXPR_[email protected] |
21 | [email protected] "{" | 21 | [email protected] "{" |
22 | [email protected] " " | 22 | [email protected] " " |
23 | [email protected] | 23 | RECORD_EXPR_[email protected] |
24 | [email protected] | 24 | [email protected] |
25 | [email protected] "field" | 25 | [email protected] "field" |
26 | [email protected] " " | 26 | [email protected] " " |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast b/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast index b0aa73b7d..a9ae1aa59 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast | |||
@@ -12,28 +12,28 @@ [email protected] | |||
12 | [email protected] "{" | 12 | [email protected] "{" |
13 | [email protected] "\n " | 13 | [email protected] "\n " |
14 | [email protected] | 14 | [email protected] |
15 | RECORD_LIT@15..19 | 15 | RECORD_EXPR@15..19 |
16 | [email protected] | 16 | [email protected] |
17 | [email protected] | 17 | [email protected] |
18 | [email protected] | 18 | [email protected] |
19 | [email protected] "S" | 19 | [email protected] "S" |
20 | [email protected] " " | 20 | [email protected] " " |
21 | [email protected] | 21 | RECORD_EXPR_[email protected] |
22 | [email protected] "{" | 22 | [email protected] "{" |
23 | [email protected] "}" | 23 | [email protected] "}" |
24 | [email protected] ";" | 24 | [email protected] ";" |
25 | [email protected] "\n " | 25 | [email protected] "\n " |
26 | [email protected] | 26 | [email protected] |
27 | RECORD_LIT@25..40 | 27 | RECORD_EXPR@25..40 |
28 | [email protected] | 28 | [email protected] |
29 | [email protected] | 29 | [email protected] |
30 | [email protected] | 30 | [email protected] |
31 | [email protected] "S" | 31 | [email protected] "S" |
32 | [email protected] " " | 32 | [email protected] " " |
33 | [email protected] | 33 | RECORD_EXPR_[email protected] |
34 | [email protected] "{" | 34 | [email protected] "{" |
35 | [email protected] " " | 35 | [email protected] " " |
36 | [email protected] | 36 | RECORD_EXPR_[email protected] |
37 | [email protected] | 37 | [email protected] |
38 | [email protected] | 38 | [email protected] |
39 | [email protected] | 39 | [email protected] |
@@ -41,7 +41,7 @@ [email protected] | |||
41 | [email protected] "x" | 41 | [email protected] "x" |
42 | [email protected] "," | 42 | [email protected] "," |
43 | [email protected] " " | 43 | [email protected] " " |
44 | [email protected] | 44 | RECORD_EXPR_[email protected] |
45 | [email protected] | 45 | [email protected] |
46 | [email protected] "y" | 46 | [email protected] "y" |
47 | [email protected] ":" | 47 | [email protected] ":" |
@@ -54,16 +54,16 @@ [email protected] | |||
54 | [email protected] ";" | 54 | [email protected] ";" |
55 | [email protected] "\n " | 55 | [email protected] "\n " |
56 | [email protected] | 56 | [email protected] |
57 | RECORD_LIT@46..82 | 57 | RECORD_EXPR@46..82 |
58 | [email protected] | 58 | [email protected] |
59 | [email protected] | 59 | [email protected] |
60 | [email protected] | 60 | [email protected] |
61 | [email protected] "S" | 61 | [email protected] "S" |
62 | [email protected] " " | 62 | [email protected] " " |
63 | [email protected] | 63 | RECORD_EXPR_[email protected] |
64 | [email protected] "{" | 64 | [email protected] "{" |
65 | [email protected] " " | 65 | [email protected] " " |
66 | [email protected] | 66 | RECORD_EXPR_[email protected] |
67 | [email protected] | 67 | [email protected] |
68 | [email protected] | 68 | [email protected] |
69 | [email protected] | 69 | [email protected] |
@@ -71,7 +71,7 @@ [email protected] | |||
71 | [email protected] "x" | 71 | [email protected] "x" |
72 | [email protected] "," | 72 | [email protected] "," |
73 | [email protected] " " | 73 | [email protected] " " |
74 | [email protected] | 74 | RECORD_EXPR_[email protected] |
75 | [email protected] | 75 | [email protected] |
76 | [email protected] "y" | 76 | [email protected] "y" |
77 | [email protected] ":" | 77 | [email protected] ":" |
@@ -100,16 +100,16 @@ [email protected] | |||
100 | [email protected] ";" | 100 | [email protected] ";" |
101 | [email protected] "\n " | 101 | [email protected] "\n " |
102 | [email protected] | 102 | [email protected] |
103 | RECORD_LIT@88..108 | 103 | RECORD_EXPR@88..108 |
104 | [email protected] | 104 | [email protected] |
105 | [email protected] | 105 | [email protected] |
106 | [email protected] | 106 | [email protected] |
107 | [email protected] "TupleStruct" | 107 | [email protected] "TupleStruct" |
108 | [email protected] " " | 108 | [email protected] " " |
109 | [email protected] | 109 | RECORD_EXPR_[email protected] |
110 | [email protected] "{" | 110 | [email protected] "{" |
111 | [email protected] " " | 111 | [email protected] " " |
112 | [email protected] | 112 | RECORD_EXPR_[email protected] |
113 | [email protected] | 113 | [email protected] |
114 | [email protected] "0" | 114 | [email protected] "0" |
115 | [email protected] ":" | 115 | [email protected] ":" |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast index d2279877b..37ca478e6 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast | |||
@@ -49,14 +49,14 @@ [email protected] | |||
49 | [email protected] " " | 49 | [email protected] " " |
50 | [email protected] ">" | 50 | [email protected] ">" |
51 | [email protected] " " | 51 | [email protected] " " |
52 | RECORD_LIT@63..77 | 52 | RECORD_EXPR@63..77 |
53 | [email protected] | 53 | [email protected] |
54 | [email protected] | 54 | [email protected] |
55 | [email protected] | 55 | [email protected] |
56 | [email protected] "Test" | 56 | [email protected] "Test" |
57 | [email protected] | 57 | RECORD_EXPR_[email protected] |
58 | [email protected] "{" | 58 | [email protected] "{" |
59 | [email protected] | 59 | RECORD_EXPR_[email protected] |
60 | [email protected] | 60 | [email protected] |
61 | [email protected] "field" | 61 | [email protected] "field" |
62 | [email protected] ":" | 62 | [email protected] ":" |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast index d6926425c..673d396ee 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast | |||
@@ -72,13 +72,13 @@ [email protected] | |||
72 | [email protected] | 72 | [email protected] |
73 | [email protected] "{" | 73 | [email protected] "{" |
74 | [email protected] " " | 74 | [email protected] " " |
75 | RECORD_LIT@84..88 | 75 | RECORD_EXPR@84..88 |
76 | [email protected] | 76 | [email protected] |
77 | [email protected] | 77 | [email protected] |
78 | [email protected] | 78 | [email protected] |
79 | [email protected] "S" | 79 | [email protected] "S" |
80 | [email protected] " " | 80 | [email protected] " " |
81 | [email protected] | 81 | RECORD_EXPR_[email protected] |
82 | [email protected] "{" | 82 | [email protected] "{" |
83 | [email protected] "}" | 83 | [email protected] "}" |
84 | [email protected] " " | 84 | [email protected] " " |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast index 20979cef3..54ea2c7c6 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast | |||
@@ -11,16 +11,16 @@ [email protected] | |||
11 | [email protected] | 11 | [email protected] |
12 | [email protected] "{" | 12 | [email protected] "{" |
13 | [email protected] "\n " | 13 | [email protected] "\n " |
14 | RECORD_LIT@16..43 | 14 | RECORD_EXPR@16..43 |
15 | [email protected] | 15 | [email protected] |
16 | [email protected] | 16 | [email protected] |
17 | [email protected] | 17 | [email protected] |
18 | [email protected] "S" | 18 | [email protected] "S" |
19 | [email protected] " " | 19 | [email protected] " " |
20 | [email protected] | 20 | RECORD_EXPR_[email protected] |
21 | [email protected] "{" | 21 | [email protected] "{" |
22 | [email protected] " " | 22 | [email protected] " " |
23 | [email protected] | 23 | RECORD_EXPR_[email protected] |
24 | [email protected] | 24 | [email protected] |
25 | [email protected] "#" | 25 | [email protected] "#" |
26 | [email protected] "[" | 26 | [email protected] "[" |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast index a03139ab5..a7f87c020 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast | |||
@@ -22,14 +22,14 @@ [email protected] | |||
22 | [email protected] " " | 22 | [email protected] " " |
23 | [email protected] "=" | 23 | [email protected] "=" |
24 | [email protected] " " | 24 | [email protected] " " |
25 | RECORD_LIT@26..33 | 25 | RECORD_EXPR@26..33 |
26 | [email protected] | 26 | [email protected] |
27 | [email protected] | 27 | [email protected] |
28 | [email protected] | 28 | [email protected] |
29 | [email protected] "F" | 29 | [email protected] "F" |
30 | [email protected] | 30 | RECORD_EXPR_[email protected] |
31 | [email protected] "{" | 31 | [email protected] "{" |
32 | [email protected] | 32 | RECORD_EXPR_[email protected] |
33 | [email protected] | 33 | [email protected] |
34 | [email protected] "x" | 34 | [email protected] "x" |
35 | [email protected] ":" | 35 | [email protected] ":" |
diff --git a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast b/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast index 22eb22e3c..1c5545b6d 100644 --- a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast +++ b/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast | |||
@@ -46,16 +46,16 @@ [email protected] | |||
46 | [email protected] | 46 | [email protected] |
47 | [email protected] | 47 | [email protected] |
48 | [email protected] | 48 | [email protected] |
49 | RECORD_LIT@107..124 | 49 | RECORD_EXPR@107..124 |
50 | [email protected] | 50 | [email protected] |
51 | [email protected] | 51 | [email protected] |
52 | [email protected] | 52 | [email protected] |
53 | [email protected] "Repr" | 53 | [email protected] "Repr" |
54 | [email protected] " " | 54 | [email protected] " " |
55 | [email protected] | 55 | RECORD_EXPR_[email protected] |
56 | [email protected] "{" | 56 | [email protected] "{" |
57 | [email protected] " " | 57 | [email protected] " " |
58 | [email protected] | 58 | RECORD_EXPR_[email protected] |
59 | [email protected] | 59 | [email protected] |
60 | [email protected] "raw" | 60 | [email protected] "raw" |
61 | [email protected] ":" | 61 | [email protected] ":" |
@@ -83,14 +83,14 @@ [email protected] | |||
83 | [email protected] "\n " | 83 | [email protected] "\n " |
84 | [email protected] | 84 | [email protected] |
85 | [email protected] | 85 | [email protected] |
86 | RECORD_LIT@141..154 | 86 | RECORD_EXPR@141..154 |
87 | [email protected] | 87 | [email protected] |
88 | [email protected] | 88 | [email protected] |
89 | [email protected] | 89 | [email protected] |
90 | [email protected] "Repr" | 90 | [email protected] "Repr" |
91 | [email protected] | 91 | RECORD_EXPR_[email protected] |
92 | [email protected] "{" | 92 | [email protected] "{" |
93 | [email protected] | 93 | RECORD_EXPR_[email protected] |
94 | [email protected] | 94 | [email protected] |
95 | [email protected] "raw" | 95 | [email protected] "raw" |
96 | [email protected] ":" | 96 | [email protected] ":" |
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index b81985851..38709c63e 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -159,9 +159,9 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { | |||
159 | "MATCH_ARM_LIST", | 159 | "MATCH_ARM_LIST", |
160 | "MATCH_ARM", | 160 | "MATCH_ARM", |
161 | "MATCH_GUARD", | 161 | "MATCH_GUARD", |
162 | "RECORD_LIT", | 162 | "RECORD_EXPR", |
163 | "RECORD_FIELD_LIST", | 163 | "RECORD_EXPR_FIELD_LIST", |
164 | "RECORD_FIELD", | 164 | "RECORD_EXPR_FIELD", |
165 | "EFFECT_EXPR", | 165 | "EFFECT_EXPR", |
166 | "BOX_EXPR", | 166 | "BOX_EXPR", |
167 | // postfix | 167 | // postfix |
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 833ffd9e0..49b2c9ff8 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram | |||
@@ -82,10 +82,6 @@ StructDef = | |||
82 | | TupleFieldDefList WhereClause? ';' | 82 | | TupleFieldDefList WhereClause? ';' |
83 | ) | 83 | ) |
84 | 84 | ||
85 | UnionDef = | ||
86 | Attr* Visibility? 'union' Name GenericParamList? WhereClause? | ||
87 | RecordFieldDefList | ||
88 | |||
89 | RecordFieldDefList = | 85 | RecordFieldDefList = |
90 | '{' fields:RecordFieldDef* '}' | 86 | '{' fields:RecordFieldDef* '}' |
91 | 87 | ||
@@ -102,6 +98,11 @@ FieldDefList = | |||
102 | RecordFieldDefList | 98 | RecordFieldDefList |
103 | | TupleFieldDefList | 99 | | TupleFieldDefList |
104 | 100 | ||
101 | |||
102 | UnionDef = | ||
103 | Attr* Visibility? 'union' Name GenericParamList? WhereClause? | ||
104 | RecordFieldDefList | ||
105 | |||
105 | EnumDef = | 106 | EnumDef = |
106 | Attr* Visibility? 'enum' Name GenericParamList? WhereClause? | 107 | Attr* Visibility? 'enum' Name GenericParamList? WhereClause? |
107 | variant_list:EnumVariantList | 108 | variant_list:EnumVariantList |
@@ -284,16 +285,16 @@ MatchArm = | |||
284 | MatchGuard = | 285 | MatchGuard = |
285 | 'if' Expr | 286 | 'if' Expr |
286 | 287 | ||
287 | RecordLit = | 288 | RecordExpr = |
288 | Path RecordFieldList | 289 | Path RecordExprFieldList |
289 | 290 | ||
290 | RecordFieldList = | 291 | RecordExprFieldList = |
291 | '{' | 292 | '{' |
292 | fields:RecordField* | 293 | fields:RecordExprField* |
293 | ('..' spread:Expr)? | 294 | ('..' spread:Expr)? |
294 | '}' | 295 | '}' |
295 | 296 | ||
296 | RecordField = | 297 | RecordExprField = |
297 | Attr* NameRef (':' Expr)? | 298 | Attr* NameRef (':' Expr)? |
298 | 299 | ||
299 | OrPat = | 300 | OrPat = |
@@ -522,7 +523,7 @@ Expr = | |||
522 | | BlockExpr | 523 | | BlockExpr |
523 | | ReturnExpr | 524 | | ReturnExpr |
524 | | MatchExpr | 525 | | MatchExpr |
525 | | RecordLit | 526 | | RecordExpr |
526 | | CallExpr | 527 | | CallExpr |
527 | | IndexExpr | 528 | | IndexExpr |
528 | | MethodCallExpr | 529 | | MethodCallExpr |