1
Fork 0

Rollup merge of #48356 - estebank:unsafe-without-braces, r=nikomatsakis

When encountering invalid token after `unsafe`, mention `{`

Fix #37158.
This commit is contained in:
Manish Goregaokar 2018-02-24 08:55:52 -08:00
commit fc7caed04e
3 changed files with 28 additions and 0 deletions

View file

@ -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 {