Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8b36196

Browse files
Add if let test case
1 parent 84a60c3 commit 8b36196

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tests/ui/replace_consts.fixed

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,21 @@ fn good() {
7676
{ let foo = u64::max_value(); };
7777
{ let foo = u128::max_value(); };
7878

79-
let _ = match 42 {
79+
let x = 42;
80+
81+
let _ = match x {
8082
std::i8::MIN => -1,
8183
1..=std::i8::MAX => 1,
8284
_ => 0
8385
};
86+
87+
let _ = if let std::i8::MIN = x {
88+
-1
89+
} else if let 1..=std::i8::MAX = x {
90+
1
91+
} else {
92+
0
93+
};
8494
}
8595

8696
fn main() {

tests/ui/replace_consts.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,21 @@ fn good() {
7676
{ let foo = u64::max_value(); };
7777
{ let foo = u128::max_value(); };
7878

79-
let _ = match 42 {
79+
let x = 42;
80+
81+
let _ = match x {
8082
std::i8::MIN => -1,
8183
1..=std::i8::MAX => 1,
8284
_ => 0
8385
};
86+
87+
let _ = if let std::i8::MIN = x {
88+
-1
89+
} else if let 1..=std::i8::MAX = x {
90+
1
91+
} else {
92+
0
93+
};
8494
}
8595

8696
fn main() {

0 commit comments

Comments
 (0)