about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/codegen/integer-overflow.rs26
-rw-r--r--src/test/ui/issues/issue-72373.rs9
-rw-r--r--src/test/ui/issues/issue-72373.stderr13
-rw-r--r--src/test/ui/json-short.stderr5
4 files changed, 51 insertions, 2 deletions
diff --git a/src/test/codegen/integer-overflow.rs b/src/test/codegen/integer-overflow.rs
new file mode 100644
index 00000000000..183de56db96
--- /dev/null
+++ b/src/test/codegen/integer-overflow.rs
@@ -0,0 +1,26 @@
+// no-system-llvm
+// compile-flags: -O -C overflow-checks=on
+
+#![crate_type = "lib"]
+
+
+pub struct S1<'a> {
+    data: &'a [u8],
+    position: usize,
+}
+
+// CHECK-LABEL: @slice_no_index_order
+#[no_mangle]
+pub fn slice_no_index_order<'a>(s: &'a mut S1, n: usize) -> &'a [u8] {
+    // CHECK-NOT: slice_index_order_fail
+    let d = &s.data[s.position..s.position+n];
+    s.position += n;
+    return d;
+}
+
+// CHECK-LABEL: @test_check
+#[no_mangle]
+pub fn test_check<'a>(s: &'a mut S1, x: usize, y: usize) -> &'a [u8] {
+    // CHECK: slice_index_order_fail
+    &s.data[x..y]
+}
diff --git a/src/test/ui/issues/issue-72373.rs b/src/test/ui/issues/issue-72373.rs
new file mode 100644
index 00000000000..4da6061c27f
--- /dev/null
+++ b/src/test/ui/issues/issue-72373.rs
@@ -0,0 +1,9 @@
+fn foo(c: &[u32], n: u32) -> u32 {
+    match *c {
+        [h, ..] if h > n => 0,
+        [h, ..] if h == n => 1,
+        [h, ref ts..] => foo(c, n - h) + foo(ts, n),
+        //~^ ERROR expected one of `,`, `@`, `]`, or `|`, found `..`
+        [] => 0,
+    }
+}
diff --git a/src/test/ui/issues/issue-72373.stderr b/src/test/ui/issues/issue-72373.stderr
new file mode 100644
index 00000000000..dfde8624814
--- /dev/null
+++ b/src/test/ui/issues/issue-72373.stderr
@@ -0,0 +1,13 @@
+error: expected one of `,`, `@`, `]`, or `|`, found `..`
+  --> $DIR/issue-72373.rs:5:19
+   |
+LL |         [h, ref ts..] => foo(c, n - h) + foo(ts, n),
+   |                   ^^ expected one of `,`, `@`, `]`, or `|`
+   |
+help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@`
+   |
+LL |         [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n),
+   |                    ^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/json-short.stderr b/src/test/ui/json-short.stderr
index 60c2582b11e..3bd85b083d0 100644
--- a/src/test/ui/json-short.stderr
+++ b/src/test/ui/json-short.stderr
@@ -1,5 +1,6 @@
-{"message":"`main` function not found in crate `json_short`","code":{"code":"E0601","explanation":"No `main` function was found in a binary crate. To fix this error, add a
-`main` function. For example:
+{"message":"`main` function not found in crate `json_short`","code":{"code":"E0601","explanation":"No `main` function was found in a binary crate.
+
+To fix this error, add a `main` function:
 
 ```
 fn main() {