diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/nll/match-guards-always-borrow.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/nll/match-guards-always-borrow.rs')
-rw-r--r-- | src/test/ui/nll/match-guards-always-borrow.rs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/test/ui/nll/match-guards-always-borrow.rs b/src/test/ui/nll/match-guards-always-borrow.rs deleted file mode 100644 index 87dba187b..000000000 --- a/src/test/ui/nll/match-guards-always-borrow.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Here is arielb1's basic example from rust-lang/rust#27282 -// that AST borrowck is flummoxed by: - -fn should_reject_destructive_mutate_in_guard() { - match Some(&4) { - None => {}, - ref mut foo if { - (|| { let bar = foo; bar.take() })(); - //~^ ERROR cannot move out of `foo` in pattern guard [E0507] - false } => { }, - Some(s) => std::process::exit(*s), - } -} - -// Here below is a case that needs to keep working: we only use the -// binding via immutable-borrow in the guard, and we mutate in the arm -// body. -fn allow_mutate_in_arm_body() { - match Some(&4) { - None => {}, - ref mut foo if foo.is_some() && false => { foo.take(); () } - Some(s) => std::process::exit(*s), - } -} - -// Here below is a case that needs to keep working: we only use the -// binding via immutable-borrow in the guard, and we move into the arm -// body. -fn allow_move_into_arm_body() { - match Some(&4) { - None => {}, - mut foo if foo.is_some() && false => { foo.take(); () } - Some(s) => std::process::exit(*s), - } -} - -fn main() { - should_reject_destructive_mutate_in_guard(); - allow_mutate_in_arm_body(); - allow_move_into_arm_body(); -} |