diff options
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar.ron | 2 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar/patterns.rs | 6 |
3 files changed, 12 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 2b400b847..999023e3d 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -893,6 +893,8 @@ pub enum ModuleItem<'a> { | |||
893 | ImplItem(ImplItem<'a>), | 893 | ImplItem(ImplItem<'a>), |
894 | UseItem(UseItem<'a>), | 894 | UseItem(UseItem<'a>), |
895 | ExternCrateItem(ExternCrateItem<'a>), | 895 | ExternCrateItem(ExternCrateItem<'a>), |
896 | ConstDef(ConstDef<'a>), | ||
897 | StaticDef(StaticDef<'a>), | ||
896 | } | 898 | } |
897 | 899 | ||
898 | impl<'a> AstNode<'a> for ModuleItem<'a> { | 900 | impl<'a> AstNode<'a> for ModuleItem<'a> { |
@@ -905,6 +907,8 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
905 | IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })), | 907 | IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })), |
906 | USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })), | 908 | USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })), |
907 | EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })), | 909 | EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })), |
910 | CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })), | ||
911 | STATIC_DEF => Some(ModuleItem::StaticDef(StaticDef { syntax })), | ||
908 | _ => None, | 912 | _ => None, |
909 | } | 913 | } |
910 | } | 914 | } |
@@ -917,6 +921,8 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
917 | ModuleItem::ImplItem(inner) => inner.syntax(), | 921 | ModuleItem::ImplItem(inner) => inner.syntax(), |
918 | ModuleItem::UseItem(inner) => inner.syntax(), | 922 | ModuleItem::UseItem(inner) => inner.syntax(), |
919 | ModuleItem::ExternCrateItem(inner) => inner.syntax(), | 923 | ModuleItem::ExternCrateItem(inner) => inner.syntax(), |
924 | ModuleItem::ConstDef(inner) => inner.syntax(), | ||
925 | ModuleItem::StaticDef(inner) => inner.syntax(), | ||
920 | } | 926 | } |
921 | } | 927 | } |
922 | } | 928 | } |
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 8055a4687..f8fa7b694 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron | |||
@@ -334,7 +334,7 @@ Grammar( | |||
334 | ), | 334 | ), |
335 | "ModuleItem": ( | 335 | "ModuleItem": ( |
336 | enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "ImplItem", | 336 | enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "ImplItem", |
337 | "UseItem", "ExternCrateItem" ] | 337 | "UseItem", "ExternCrateItem", "ConstDef", "StaticDef" ] |
338 | ), | 338 | ), |
339 | 339 | ||
340 | "TupleExpr": (), | 340 | "TupleExpr": (), |
diff --git a/crates/libsyntax2/src/grammar/patterns.rs b/crates/libsyntax2/src/grammar/patterns.rs index 114964651..065570b99 100644 --- a/crates/libsyntax2/src/grammar/patterns.rs +++ b/crates/libsyntax2/src/grammar/patterns.rs | |||
@@ -22,6 +22,10 @@ pub(super) fn pattern(p: &mut Parser) { | |||
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | const PAT_RECOVERY_SET: TokenSet = | ||
26 | token_set![LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW]; | ||
27 | |||
28 | |||
25 | fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { | 29 | fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { |
26 | let la0 = p.nth(0); | 30 | let la0 = p.nth(0); |
27 | let la1 = p.nth(1); | 31 | let la1 = p.nth(1); |
@@ -52,7 +56,7 @@ fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { | |||
52 | L_PAREN => tuple_pat(p), | 56 | L_PAREN => tuple_pat(p), |
53 | L_BRACK => slice_pat(p), | 57 | L_BRACK => slice_pat(p), |
54 | _ => { | 58 | _ => { |
55 | p.err_and_bump("expected pattern"); | 59 | p.err_recover("expected pattern", PAT_RECOVERY_SET); |
56 | return None; | 60 | return None; |
57 | } | 61 | } |
58 | }; | 62 | }; |