Make the "extra if in let...else block" hint a suggestion
This commit is contained in:
parent
f55b0022db
commit
e905b93706
@ -351,7 +351,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(parse_extra_if_in_let_else)]
|
||||
#[suggestion(parse_extra_if_in_let_else, applicability = "maybe-incorrect", code = "")]
|
||||
pub(crate) struct IfExpressionLetSomeSub {
|
||||
#[primary_span]
|
||||
pub if_span: Span,
|
||||
|
@ -2281,7 +2281,7 @@ fn parse_if_after_cond(&mut self, lo: Span, mut cond: P<Expr>) -> PResult<'a, P<
|
||||
block
|
||||
} else {
|
||||
let let_else_sub = matches!(cond.kind, ExprKind::Let(..))
|
||||
.then(|| IfExpressionLetSomeSub { if_span: lo });
|
||||
.then(|| IfExpressionLetSomeSub { if_span: lo.until(cond_span) });
|
||||
|
||||
self.sess.emit_err(IfExpressionMissingThenBlock {
|
||||
if_span: lo,
|
||||
|
@ -10,10 +10,10 @@ help: add a block here
|
||||
LL | if let Some(y) = x else {
|
||||
| ^
|
||||
help: remove the `if` if you meant to write a `let...else` statement
|
||||
--> $DIR/accidental-if.rs:3:5
|
||||
|
|
||||
LL | if let Some(y) = x else {
|
||||
| ^^
|
||||
LL - if let Some(y) = x else {
|
||||
LL + let Some(y) = x else {
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -38,10 +38,10 @@ help: add a block here
|
||||
LL | if let Some(n) = opt else {
|
||||
| ^
|
||||
help: remove the `if` if you meant to write a `let...else` statement
|
||||
--> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:24:5
|
||||
|
|
||||
LL | if let Some(n) = opt else {
|
||||
| ^^
|
||||
LL - if let Some(n) = opt else {
|
||||
LL + let Some(n) = opt else {
|
||||
|
|
||||
|
||||
error: this `if` expression is missing a block after the condition
|
||||
--> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:28:5
|
||||
|
Loading…
Reference in New Issue
Block a user