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:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs')
-rw-r--r--src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs78
1 files changed, 0 insertions, 78 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
deleted file mode 100644
index 9afb6853b..000000000
--- a/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs
+++ /dev/null
@@ -1,78 +0,0 @@
-// revisions: allowed disallowed
-//[allowed] check-pass
-
-#![feature(if_let_guard, let_chains)]
-#![cfg_attr(allowed, allow(irrefutable_let_patterns))]
-#![cfg_attr(disallowed, deny(irrefutable_let_patterns))]
-
-use std::ops::Range;
-
-fn main() {
- let opt = Some(None..Some(1));
-
- if let first = &opt && let Some(ref second) = first && let None = second.start {}
- //[disallowed]~^ ERROR leading irrefutable pattern in let chain
-
- // No lint as the irrefutable pattern is surrounded by other stuff
- if 4 * 2 == 0 && let first = &opt && let Some(ref second) = first && let None = second.start {}
-
- if let first = &opt && let (a, b) = (1, 2) {}
- //[disallowed]~^ ERROR irrefutable `if let` patterns
-
- if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {}
- //[disallowed]~^ ERROR leading irrefutable pattern in let chain
- //[disallowed]~^^ ERROR trailing irrefutable pattern in let chain
-
- if let Some(ref first) = opt && let second = first && let _third = second {}
- //[disallowed]~^ ERROR trailing irrefutable patterns in let chain
-
- if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {}
- //[disallowed]~^ ERROR leading irrefutable pattern in let chain
-
- if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {}
- //[disallowed]~^ ERROR leading irrefutable pattern in let chain
-
- if let first = &opt && let None = Some(1) {}
- //[disallowed]~^ ERROR leading irrefutable pattern in let chain
-
- if let Some(ref first) = opt
- && let Range { start: local_start, end: _ } = first
- && let None = local_start {
- }
-
- match opt {
- Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {},
- //[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
- && let None = local_start => {},
- _ => {}
- }
-
- 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) {}
- //[disallowed]~^ ERROR irrefutable `while let` patterns
-
- while let Some(ref first) = opt && let second = first && let _third = second {}
- //[disallowed]~^ ERROR trailing irrefutable patterns in let chain
-
- while let Some(ref first) = opt
- && let Range { start: local_start, end: _ } = first
- && let None = local_start {
- }
-}