From 8b36196cb610dea86ba425079584f71d78cc218d Mon Sep 17 00:00:00 2001 From: Krishna Veera Reddy Date: Wed, 1 Jan 2020 23:22:57 -0800 Subject: [PATCH] Add `if let` test case --- tests/ui/replace_consts.fixed | 12 +++++++++++- tests/ui/replace_consts.rs | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/ui/replace_consts.fixed b/tests/ui/replace_consts.fixed index a8b11c8e488..108474408e0 100644 --- a/tests/ui/replace_consts.fixed +++ b/tests/ui/replace_consts.fixed @@ -76,11 +76,21 @@ fn good() { { let foo = u64::max_value(); }; { let foo = u128::max_value(); }; - let _ = match 42 { + let x = 42; + + let _ = match x { std::i8::MIN => -1, 1..=std::i8::MAX => 1, _ => 0 }; + + let _ = if let std::i8::MIN = x { + -1 + } else if let 1..=std::i8::MAX = x { + 1 + } else { + 0 + }; } fn main() { diff --git a/tests/ui/replace_consts.rs b/tests/ui/replace_consts.rs index fff892b79ca..dae3422a35f 100644 --- a/tests/ui/replace_consts.rs +++ b/tests/ui/replace_consts.rs @@ -76,11 +76,21 @@ fn good() { { let foo = u64::max_value(); }; { let foo = u128::max_value(); }; - let _ = match 42 { + let x = 42; + + let _ = match x { std::i8::MIN => -1, 1..=std::i8::MAX => 1, _ => 0 }; + + let _ = if let std::i8::MIN = x { + -1 + } else if let 1..=std::i8::MAX = x { + 1 + } else { + 0 + }; } fn main() {