Fix fn front matter parsing ICE from invalid code.
This commit fixes an "unreachable code" ICE that results from parsing invalid code where the compiler is expecting the next trait item declaration in the middle of the previous trait item due to extra closing braces.
This commit is contained in:
parent
d6f513ec7d
commit
60c6ed9664
3 changed files with 55 additions and 1 deletions
|
@ -6575,7 +6575,12 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
(respan(self.prev_span, Constness::NotConst), unsafety, abi)
|
||||
};
|
||||
self.expect_keyword(keywords::Fn)?;
|
||||
if !self.eat_keyword(keywords::Fn) {
|
||||
// It is possible for `expect_one_of` to recover given the contents of
|
||||
// `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't
|
||||
// account for this.
|
||||
if !self.expect_one_of(&[], &[])? { unreachable!() }
|
||||
}
|
||||
Ok((constness, unsafety, asyncness, abi))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue