summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs b/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
index 3d1626e8f..9afb6853b 100644
--- a/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
+++ b/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
@@ -42,18 +42,27 @@ fn main() {
match opt {
Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {},
- //[disallowed]~^ ERROR irrefutable `let` patterns
+ //[disallowed]~^ ERROR irrefutable `if let` guard patterns
_ => {}
}
+ // No error about leading irrefutable patterns: the expr on the rhs might
+ // use the bindings created by the match.
match opt {
Some(ref first) if let Range { start: local_start, end: _ } = first
- //[disallowed]~^ ERROR leading irrefutable pattern in let chain
&& let None = local_start => {},
_ => {}
}
- // No error, despite the prefix being irrefutable
+ match opt {
+ Some(ref first) if let Range { start: Some(_), end: local_end } = first
+ && let v = local_end && let w = v => {},
+ //[disallowed]~^ ERROR trailing irrefutable patterns in let chain
+ _ => {}
+ }
+
+ // No error, despite the prefix being irrefutable: moving out could change the behaviour,
+ // due to possible side effects of the operation.
while let first = &opt && let Some(ref second) = first && let None = second.start {}
while let first = &opt && let (a, b) = (1, 2) {}