1 // ignore-wasm32-bare compiled with panic=abort by default
2 // Test that StorageDead and Drops are generated properly for bindings in
4 // * The MIR should only contain a single drop of `s` and `t`: at the end
5 // of their respective arms.
6 // * StorageDead and StorageLive statements are correctly matched up on
8 // * The visibility scopes of the match arms should be disjoint, and contain.
9 // all of the bindings for that scope.
10 // * No drop flags are used.
12 // EMIT_MIR rustc.complicated_match.SimplifyCfg-initial.after.mir
13 // EMIT_MIR rustc.complicated_match.ElaborateDrops.after.mir
14 fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 {
16 (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1,
17 (true, b, t) | (false, b, t) => 2,
21 const CASES: &[(bool, bool, bool, i32)] = &[
22 (false, false, false, 2),
23 (false, false, true, 1),
24 (false, true, false, 1),
25 (false, true, true, 2),
26 (true, false, false, 3),
27 (true, false, true, 3),
28 (true, true, false, 3),
29 (true, true, true, 2),
33 for &(cond, items_1, items_2, result) in CASES {
34 assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,);