When encountering invalid token after unsafe, mention {

This commit is contained in:
Esteban Küber 2018-02-19 10:07:45 -08:00
parent 1670a532dd
commit 1aad320974
3 changed files with 28 additions and 0 deletions

View file

@ -6469,6 +6469,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 {