1
Fork 0

Correctly gate the parsing of match arms without body

This commit is contained in:
Nadrieril 2023-12-12 13:33:39 +01:00
parent 21cce21d8c
commit e274372689
9 changed files with 227 additions and 26 deletions

View file

@ -2918,7 +2918,12 @@ impl<'a> Parser<'a> {
let mut result = if !is_fat_arrow && !is_almost_fat_arrow {
// A pattern without a body, allowed for never patterns.
arm_body = None;
this.expect_one_of(&[token::Comma], &[token::CloseDelim(Delimiter::Brace)])
this.expect_one_of(&[token::Comma], &[token::CloseDelim(Delimiter::Brace)]).map(
|x| {
this.sess.gated_spans.gate(sym::never_patterns, pat.span);
x
},
)
} else {
if let Err(mut err) = this.expect(&token::FatArrow) {
// We might have a `=>` -> `=` or `->` typo (issue #89396).