about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-24 08:55:52 -0800
committerManish Goregaokar <manishsmail@gmail.com>2018-02-24 12:48:02 -0800
commitfc7caed04ed500ee1f4f3c1422b2752b7beafa62 (patch)
treef912fb2a50039478231cd1e6743f33a42263a2ad /src/libsyntax/parse/parser.rs
parent2483d842fb0113a807bd304908e7a0d002e2a1fe (diff)
parent1aad320974786f3abbe6e82a9d96d5594238046b (diff)
downloadrust-fc7caed04ed500ee1f4f3c1422b2752b7beafa62.tar.gz
rust-fc7caed04ed500ee1f4f3c1422b2752b7beafa62.zip
Rollup merge of #48356 - estebank:unsafe-without-braces, r=nikomatsakis
When encountering invalid token after `unsafe`, mention `{`

Fix #37158.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 1a33de84429..efc191f24ac 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -6482,6 +6482,8 @@ impl<'a> Parser<'a> {
             && self.look_ahead(1, |t| *t != token::OpenDelim(token::Brace)) {
             // UNSAFE FUNCTION ITEM
             self.bump(); // `unsafe`
+            // `{` is also expected after `unsafe`, in case of error, include it in the diagnostic
+            self.check(&token::OpenDelim(token::Brace));
             let abi = if self.eat_keyword(keywords::Extern) {
                 self.parse_opt_abi()?.unwrap_or(Abi::C)
             } else {