Fix "missing match arm body" suggestion involving !
Include the match arm guard in the gated span, so that the suggestion to add a body is correct instead of inserting the body before the guard. Make the suggestion verbose. ``` error: `match` arm with no body --> $DIR/feature-gate-never_patterns.rs:43:9 | LL | Some(_) if false, | ^^^^^^^^^^^^^^^^ | help: add a body after the pattern | LL | Some(_) if false => { todo!() }, | ++++++++++++++ ```
This commit is contained in:
parent
dc37ff82e8
commit
a8f8b8de66
5 changed files with 94 additions and 16 deletions
|
@ -3125,10 +3125,11 @@ impl<'a> Parser<'a> {
|
|||
let mut result = if armless {
|
||||
// A pattern without a body, allowed for never patterns.
|
||||
arm_body = None;
|
||||
let span = lo.to(this.prev_token.span);
|
||||
this.expect_one_of(&[exp!(Comma)], &[exp!(CloseBrace)]).map(|x| {
|
||||
// Don't gate twice
|
||||
if !pat.contains_never_pattern() {
|
||||
this.psess.gated_spans.gate(sym::never_patterns, pat.span);
|
||||
this.psess.gated_spans.gate(sym::never_patterns, span);
|
||||
}
|
||||
x
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue