24
24
//@ [e2024] edition: 2024
25
25
//@ run-pass
26
26
27
+ #![feature(if_let_guard)]
27
28
#![cfg_attr(e2021, feature(let_chains))]
28
29
#![cfg_attr(e2021, warn(rust_2024_compatibility))]
29
30
@@ -344,6 +345,25 @@ fn t_if_let_chains_then() {
344
345
e.assert(9);
345
346
}
346
347
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
+
347
367
#[cfg(e2021)]
348
368
#[rustfmt::skip]
349
369
fn t_if_let_nested_else() {
@@ -484,6 +504,25 @@ fn t_if_let_chains_then_else() {
484
504
e.assert(9);
485
505
}
486
506
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
+
487
526
fn main() {
488
527
t_bindings();
489
528
t_tuples();
@@ -502,10 +541,12 @@ fn main() {
502
541
t_if_let_nested_then();
503
542
t_let_else_chained_then();
504
543
t_if_let_chains_then();
544
+ t_guard_if_let_chains_then();
505
545
t_if_let_nested_else();
506
546
t_if_let_nested_then_else();
507
547
t_let_else_chained_then_else();
508
548
t_if_let_chains_then_else();
549
+ t_guard_if_let_chains_then_else();
509
550
}
510
551
511
552
// # Test scaffolding
0 commit comments