Skip to content

Add match guard let chain drop order and scoping tests #140981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/ui/drop/drop-order-comparisons.e2021.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//@ [e2024] edition: 2024
//@ run-pass

#![feature(if_let_guard)]
#![cfg_attr(e2021, feature(let_chains))]
#![cfg_attr(e2021, warn(rust_2024_compatibility))]

Expand Down Expand Up @@ -344,6 +345,25 @@ fn t_if_let_chains_then() {
e.assert(9);
}

#[rustfmt::skip]
fn t_guard_if_let_chains_then() {
let e = Events::new();
_ = match () {
() if e.ok(1).is_ok()
&& let true = e.ok(9).is_ok()
&& let Ok(_v) = e.ok(8)
&& let Ok(_) = e.ok(7)
&& let Ok(_) = e.ok(6).as_ref()
&& e.ok(2).is_ok()
&& let Ok(_v) = e.ok(5)
&& let Ok(_) = e.ok(4).as_ref() => {
e.mark(3);
}
_ => {}
};
e.assert(9);
}

#[cfg(e2021)]
#[rustfmt::skip]
fn t_if_let_nested_else() {
Expand Down Expand Up @@ -484,6 +504,25 @@ fn t_if_let_chains_then_else() {
e.assert(9);
}

#[rustfmt::skip]
fn t_guard_if_let_chains_then_else() {
let e = Events::new();
_ = match () {
() if e.ok(1).is_ok()
&& let true = e.ok(8).is_ok()
&& let Ok(_v) = e.ok(7)
&& let Ok(_) = e.ok(6)
&& let Ok(_) = e.ok(5).as_ref()
&& e.ok(2).is_ok()
&& let Ok(_v) = e.ok(4)
&& let Ok(_) = e.err(3) => {}
_ => {
e.mark(9);
}
};
e.assert(9);
}

fn main() {
t_bindings();
t_tuples();
Expand All @@ -502,10 +541,12 @@ fn main() {
t_if_let_nested_then();
t_let_else_chained_then();
t_if_let_chains_then();
t_guard_if_let_chains_then();
t_if_let_nested_else();
t_if_let_nested_then_else();
t_let_else_chained_then_else();
t_if_let_chains_then_else();
t_guard_if_let_chains_then_else();
}

// # Test scaffolding
Expand Down
Loading
Loading