diff options
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/grammar/items/mod.rs | 7 | ||||
-rw-r--r-- | crates/libsyntax2/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/libsyntax2/src/parser_api.rs | 4 |
3 files changed, 11 insertions, 4 deletions
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs index 32d0778c4..a285892df 100644 --- a/crates/libsyntax2/src/grammar/items/mod.rs +++ b/crates/libsyntax2/src/grammar/items/mod.rs | |||
@@ -43,7 +43,12 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF | |||
43 | m.abandon(p); | 43 | m.abandon(p); |
44 | if p.at(L_CURLY) { | 44 | if p.at(L_CURLY) { |
45 | error_block(p, "expected an item"); | 45 | error_block(p, "expected an item"); |
46 | } else if !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) { | 46 | } else if p.at(R_CURLY) && !stop_on_r_curly { |
47 | let e = p.start(); | ||
48 | p.error("unmatched `}`"); | ||
49 | p.bump(); | ||
50 | e.complete(p, ERROR); | ||
51 | } else if !p.at(EOF) && !p.at(R_CURLY) { | ||
47 | p.err_and_bump("expected an item"); | 52 | p.err_and_bump("expected an item"); |
48 | } else { | 53 | } else { |
49 | p.error("expected an item"); | 54 | p.error("expected an item"); |
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs index 9ba9970c9..93057dd6a 100644 --- a/crates/libsyntax2/src/lib.rs +++ b/crates/libsyntax2/src/lib.rs | |||
@@ -127,12 +127,12 @@ fn validate_block_structure(root: SyntaxNodeRef) { | |||
127 | assert_eq!( | 127 | assert_eq!( |
128 | node.parent(), | 128 | node.parent(), |
129 | pair.parent(), | 129 | pair.parent(), |
130 | "unpaired curleys:\n{}", | 130 | "\nunpaired curleys:\n{}", |
131 | utils::dump_tree(root), | 131 | utils::dump_tree(root), |
132 | ); | 132 | ); |
133 | assert!( | 133 | assert!( |
134 | node.next_sibling().is_none() && pair.prev_sibling().is_none(), | 134 | node.next_sibling().is_none() && pair.prev_sibling().is_none(), |
135 | "floating curlys at {:?}\nfile:\n{}\nerror:\n{}\n", | 135 | "\nfloating curlys at {:?}\nfile:\n{}\nerror:\n{}\n", |
136 | node, | 136 | node, |
137 | root.text(), | 137 | root.text(), |
138 | node.text(), | 138 | node.text(), |
diff --git a/crates/libsyntax2/src/parser_api.rs b/crates/libsyntax2/src/parser_api.rs index bb34fe973..0a3b29b70 100644 --- a/crates/libsyntax2/src/parser_api.rs +++ b/crates/libsyntax2/src/parser_api.rs | |||
@@ -141,7 +141,9 @@ impl<'t> Parser<'t> { | |||
141 | pub(crate) fn err_and_bump(&mut self, message: &str) { | 141 | pub(crate) fn err_and_bump(&mut self, message: &str) { |
142 | let m = self.start(); | 142 | let m = self.start(); |
143 | self.error(message); | 143 | self.error(message); |
144 | self.bump(); | 144 | if !self.at(SyntaxKind::L_CURLY) && !self.at(SyntaxKind::R_CURLY) { |
145 | self.bump(); | ||
146 | } | ||
145 | m.complete(self, ERROR); | 147 | m.complete(self, ERROR); |
146 | } | 148 | } |
147 | } | 149 | } |