summaryrefslogtreecommitdiffstats
path: root/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.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 /tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.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 'tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs')
-rw-r--r--tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs
new file mode 100644
index 000000000..6567c8cc6
--- /dev/null
+++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs
@@ -0,0 +1,24 @@
+// Test `X...` and `X..=` range patterns not being allowed syntactically.
+// FIXME(Centril): perhaps these should be semantic restrictions.
+
+fn main() {}
+
+#[cfg(FALSE)]
+fn foo() {
+ if let 0... = 1 {} //~ ERROR inclusive range with no end
+ if let 0..= = 1 {} //~ ERROR inclusive range with no end
+ const X: u8 = 0;
+ if let X... = 1 {} //~ ERROR inclusive range with no end
+ if let X..= = 1 {} //~ ERROR inclusive range with no end
+}
+
+fn bar() {
+ macro_rules! mac {
+ ($e:expr) => {
+ let $e...; //~ ERROR inclusive range with no end
+ let $e..=; //~ ERROR inclusive range with no end
+ }
+ }
+
+ mac!(0);
+}