2024-02-16 14:02:50 -06:00
|
|
|
//@ run-rustfix
|
2024-01-29 14:34:29 -06:00
|
|
|
enum Enum {
|
|
|
|
Variant(i32),
|
|
|
|
}
|
|
|
|
struct Struct(i32);
|
|
|
|
|
|
|
|
fn foo(x: Enum) -> i32 {
|
|
|
|
if let Enum::Variant(value) = x { //~ ERROR `if` may be missing an `else` clause
|
|
|
|
value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn bar(x: Enum) -> i32 {
|
|
|
|
if let Enum::Variant(value) = x { //~ ERROR `if` may be missing an `else` clause
|
|
|
|
let x = value + 1;
|
|
|
|
x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn baz(x: Struct) -> i32 {
|
|
|
|
if let Struct(value) = x { //~ ERROR `if` may be missing an `else` clause
|
|
|
|
let x = value + 1;
|
|
|
|
x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn main() {
|
|
|
|
let _ = foo(Enum::Variant(42));
|
|
|
|
let _ = bar(Enum::Variant(42));
|
|
|
|
let _ = baz(Struct(42));
|
|
|
|
}
|