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

Commit f1c8a7c

Browse files
authored
Unrolled build for rust-lang#140981
Rollup merge of rust-lang#140981 - est31:guard_let_chains_tests, r=petrochenkov Add match guard let chain drop order and scoping tests We have a bunch of tests for if let chain drop order, but those tests don't cover match guard chains to the same depth. This PR adds the following tests: * match guard equivalents of the if let chains tests in the `drop-order-comparisons.rs` test, added by rust-lang#133605. * match guard equivalent of the `mir_let_chains_drop_order.rs` test, added by rust-lang#107251 * match guard equivalent of `temporary-early-drop.rs`, added by rust-lang#133093 The added tests all have variants for 2021 and 2024, showing that the behavior on both editions matches that of if let chains on 2024. tracking issue: rust-lang#51114
2 parents 87b4541 + 7b45c59 commit f1c8a7c

5 files changed

+269
-48
lines changed

tests/ui/drop/drop-order-comparisons.e2021.fixed

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
//@ [e2024] edition: 2024
2525
//@ run-pass
2626

27+
#![feature(if_let_guard)]
2728
#![cfg_attr(e2021, feature(let_chains))]
2829
#![cfg_attr(e2021, warn(rust_2024_compatibility))]
2930

@@ -344,6 +345,25 @@ fn t_if_let_chains_then() {
344345
e.assert(9);
345346
}
346347

348+
#[rustfmt::skip]
349+
fn t_guard_if_let_chains_then() {
350+
let e = Events::new();
351+
_ = match () {
352+
() if e.ok(1).is_ok()
353+
&& let true = e.ok(9).is_ok()
354+
&& let Ok(_v) = e.ok(8)
355+
&& let Ok(_) = e.ok(7)
356+
&& let Ok(_) = e.ok(6).as_ref()
357+
&& e.ok(2).is_ok()
358+
&& let Ok(_v) = e.ok(5)
359+
&& let Ok(_) = e.ok(4).as_ref() => {
360+
e.mark(3);
361+
}
362+
_ => {}
363+
};
364+
e.assert(9);
365+
}
366+
347367
#[cfg(e2021)]
348368
#[rustfmt::skip]
349369
fn t_if_let_nested_else() {
@@ -484,6 +504,25 @@ fn t_if_let_chains_then_else() {
484504
e.assert(9);
485505
}
486506

507+
#[rustfmt::skip]
508+
fn t_guard_if_let_chains_then_else() {
509+
let e = Events::new();
510+
_ = match () {
511+
() if e.ok(1).is_ok()
512+
&& let true = e.ok(8).is_ok()
513+
&& let Ok(_v) = e.ok(7)
514+
&& let Ok(_) = e.ok(6)
515+
&& let Ok(_) = e.ok(5).as_ref()
516+
&& e.ok(2).is_ok()
517+
&& let Ok(_v) = e.ok(4)
518+
&& let Ok(_) = e.err(3) => {}
519+
_ => {
520+
e.mark(9);
521+
}
522+
};
523+
e.assert(9);
524+
}
525+
487526
fn main() {
488527
t_bindings();
489528
t_tuples();
@@ -502,10 +541,12 @@ fn main() {
502541
t_if_let_nested_then();
503542
t_let_else_chained_then();
504543
t_if_let_chains_then();
544+
t_guard_if_let_chains_then();
505545
t_if_let_nested_else();
506546
t_if_let_nested_then_else();
507547
t_let_else_chained_then_else();
508548
t_if_let_chains_then_else();
549+
t_guard_if_let_chains_then_else();
509550
}
510551

511552
// # Test scaffolding

0 commit comments

Comments
 (0)