1
Fork 0

Disallow an arm without a body (except for never patterns)

Parsing now accepts a match arm without a body, so we must make sure to
only accept that if the pattern is a never pattern.
This commit is contained in:
Nadrieril 2023-11-27 01:53:05 +01:00
parent 0bfebc6105
commit a2dcb3a6d9
9 changed files with 128 additions and 12 deletions

View file

@ -659,8 +659,8 @@ impl Pat {
matches!(self.kind, PatKind::Rest)
}
/// Could this be a never pattern? I.e. is it a never pattern modulo macro invocations that
/// might return never patterns?
/// Whether this could be a never pattern, taking into account that a macro invocation can
/// return a never pattern. Used to inform errors during parsing.
pub fn could_be_never_pattern(&self) -> bool {
let mut could_be_never_pattern = false;
self.walk(&mut |pat| match &pat.kind {