about summary refs log tree commit diff
path: root/tests/ui/half-open-range-patterns
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2023-01-28 20:02:00 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2023-01-28 20:52:01 +0000
commit4bfab39f9b466fa89f85c57a42c1e71a99c6aa4e (patch)
tree2c6debcee80dbbdfa88362a5dcfff6d01152e8e6 /tests/ui/half-open-range-patterns
parentd6f0642827e21a088b0130c84857d84f5433301d (diff)
downloadrust-4bfab39f9b466fa89f85c57a42c1e71a99c6aa4e.tar.gz
rust-4bfab39f9b466fa89f85c57a42c1e71a99c6aa4e.zip
Check for missing space between fat arrow and range pattern
Diffstat (limited to 'tests/ui/half-open-range-patterns')
-rw-r--r--tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.rs8
-rw-r--r--tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.stderr19
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.rs
new file mode 100644
index 00000000000..7ba2b6d857c
--- /dev/null
+++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.rs
@@ -0,0 +1,8 @@
+fn main() {
+    let x = 42;
+    match x {
+        0..=73 => {},
+        74..=> {},   //~ ERROR unexpected `=>` after open range
+                     //~^ ERROR expected one of `=>`, `if`, or `|`, found `>`
+    }
+}
diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.stderr
new file mode 100644
index 00000000000..9ba6d15113c
--- /dev/null
+++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-match-arrow.stderr
@@ -0,0 +1,19 @@
+error: unexpected `=>` after open range
+  --> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:11
+   |
+LL |         74..=> {},
+   |           ^^^
+   |
+help: add a space between the pattern and `=>`
+   |
+LL |         74.. => {},
+   |             +
+
+error: expected one of `=>`, `if`, or `|`, found `>`
+  --> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:14
+   |
+LL |         74..=> {},
+   |              ^ expected one of `=>`, `if`, or `|`
+
+error: aborting due to 2 previous errors
+