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]
349369fn 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+
487526fn 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