Add help message for incorrect pattern syntax
This commit is contained in:
parent
90e019bacd
commit
41f58a7cf6
1 changed files with 10 additions and 1 deletions
|
@ -3432,7 +3432,16 @@ impl<'a> Parser<'a> {
|
||||||
loop {
|
loop {
|
||||||
pats.push(self.parse_pat()?);
|
pats.push(self.parse_pat()?);
|
||||||
if self.check(&token::BinOp(token::Or)) { self.bump();}
|
if self.check(&token::BinOp(token::Or)) { self.bump();}
|
||||||
else { return Ok(pats); }
|
else {
|
||||||
|
// Accidental use of || instead of | inbetween patterns
|
||||||
|
if self.token == token::OrOr {
|
||||||
|
return Err(self.span_fatal_help(
|
||||||
|
self.span, "Unexpected token `||` after pattern",
|
||||||
|
"Did you mean to use `|` to specify multiple patterns instead?"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(pats);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue