suggest using else when '_' is used for exhaustive enums (#16583)
This commit is contained in:
@@ -10791,6 +10791,13 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
|
||||
"'_' prong here",
|
||||
.{},
|
||||
);
|
||||
try sema.errNote(
|
||||
block,
|
||||
src,
|
||||
msg,
|
||||
"consider using 'else'",
|
||||
.{},
|
||||
);
|
||||
break :msg msg;
|
||||
};
|
||||
return sema.failWithOwnedErrorMsg(msg);
|
||||
|
||||
@@ -17,3 +17,4 @@ pub export fn entry() void {
|
||||
//
|
||||
// :7:5: error: '_' prong only allowed when switching on non-exhaustive enums
|
||||
// :10:11: note: '_' prong here
|
||||
// :7:5: note: consider using 'else'
|
||||
|
||||
@@ -40,3 +40,4 @@ pub export fn entry3() void {
|
||||
// :19:5: error: switch on non-exhaustive enum must include 'else' or '_' prong
|
||||
// :26:5: error: '_' prong only allowed when switching on non-exhaustive enums
|
||||
// :29:11: note: '_' prong here
|
||||
// :26:5: note: consider using 'else'
|
||||
|
||||
Reference in New Issue
Block a user