From 6ef8b57e341f40435425b71ea73436577f2b0347 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 21 May 2019 08:17:47 +0200 Subject: [PATCH] Account for let_chains in collapsible_if ui test cases. --- tests/ui/collapsible_if.fixed | 21 +++++++++++++++++++++ tests/ui/collapsible_if.rs | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/ui/collapsible_if.fixed b/tests/ui/collapsible_if.fixed index 69570c515b6..810fd2e69ea 100644 --- a/tests/ui/collapsible_if.fixed +++ b/tests/ui/collapsible_if.fixed @@ -172,4 +172,25 @@ else { println!("Hello world!"); } } + + // Test behavior wrt. `let_chains`. + // None of the cases below should be collapsed. + fn truth() -> bool { true } + + // Prefix: + if let 0 = 1 { + if truth() {} + } + + // Suffix: + if truth() { + if let 0 = 1 {} + } + + // Midfix: + if truth() { + if let 0 = 1 { + if truth() {} + } + } } diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index 5dac42a3dd9..7b322acae26 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -200,4 +200,25 @@ fn main() { println!("Hello world!"); } } + + // Test behavior wrt. `let_chains`. + // None of the cases below should be collapsed. + fn truth() -> bool { true } + + // Prefix: + if let 0 = 1 { + if truth() {} + } + + // Suffix: + if truth() { + if let 0 = 1 {} + } + + // Midfix: + if truth() { + if let 0 = 1 { + if truth() {} + } + } }