]> git.lizzy.rs Git - rust.git/commitdiff
Test errors
authorgnzlbg <gonzalobg88@gmail.com>
Wed, 25 Sep 2019 11:39:20 +0000 (13:39 +0200)
committergnzlbg <gonzalobg88@gmail.com>
Wed, 25 Sep 2019 11:39:20 +0000 (13:39 +0200)
14 files changed:
src/librustc_mir/interpret/intrinsics.rs
src/test/ui/consts/const-eval/simd/extract-fail0.rs [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/extract-fail0.stderr [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/extract-fail1.rs [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/extract-fail1.stderr [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/extract-fail2.rs [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/extract-fail2.stderr [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/insert-fail0.rs [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/insert-fail0.stderr [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/insert-fail1.rs [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/insert-fail1.stderr [new file with mode: 0644]
src/test/ui/consts/const-eval/simd/insert_extract-fail.rs [deleted file]
src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr [deleted file]
src/test/ui/consts/const-eval/simd/read_fail.rs [deleted file]

index 586611397e34432200e940cdd255ae6043980124..5fc23b4a69ec576d958f7836536d4e6d040c2548 100644 (file)
@@ -241,16 +241,16 @@ pub fn emulate_intrinsic(
             }
             "simd_insert" => {
                 let index = self.read_scalar(args[1])?.to_u32()? as u64;
-                let scalar = self.read_immediate(args[2])?;
+                let scalar = args[2];
                 let input = args[0];
                 let (len, e_ty) = self.read_vector_ty(input);
                 assert!(
                     index < len,
-                    "index `{}` must be in bounds of vector type `{}`: `[0, {})`",
+                    "Index `{}` must be in bounds of vector type `{}`: `[0, {})`",
                     index, e_ty, len
                 );
                 assert_eq!(
-                    args[0].layout, dest.layout,
+                    input.layout, dest.layout,
                     "Return type `{}` must match vector type `{}`",
                     dest.layout.ty, input.layout.ty
                 );
@@ -261,15 +261,13 @@ pub fn emulate_intrinsic(
                 );
 
                 for i in 0..len {
-                    let place = self.place_field(dest, index)?;
-                    if i == index {
-                        self.write_immediate(*scalar, place)?;
+                    let place = self.place_field(dest, i)?;
+                    let value = if i == index {
+                        scalar
                     } else {
-                        self.write_immediate(
-                            *self.read_immediate(self.operand_field(input, index)?)?,
-                            place
-                        )?;
+                        self.operand_field(input, i)?
                     };
+                    self.copy_op(value, place)?;
                 }
             }
             "simd_extract" => {
@@ -277,7 +275,7 @@ pub fn emulate_intrinsic(
                 let (len, e_ty) = self.read_vector_ty(args[0]);
                 assert!(
                     index < len,
-                    "index `{}` must be in bounds of vector type `{}`: `[0, {})`",
+                    "index `{}` is out-of-bounds of vector type `{}` with length `{}`",
                     index, e_ty, len
                 );
                 assert_eq!(
@@ -285,10 +283,7 @@ pub fn emulate_intrinsic(
                     "Return type `{}` must match vector element type `{}`",
                     dest.layout.ty, e_ty
                 );
-                self.write_immediate(
-                    *self.read_immediate(self.operand_field(args[0], index)?)?,
-                    dest
-                )?;
+                self.copy_op(self.operand_field(args[0], index)?, dest)?;
             }
             _ => return Ok(false),
         }
diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.rs b/src/test/ui/consts/const-eval/simd/extract-fail0.rs
new file mode 100644 (file)
index 0000000..d2c313d
--- /dev/null
@@ -0,0 +1,22 @@
+// failure-status: 101
+// rustc-env:RUST_BACKTRACE=0
+#![feature(const_fn)]
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+#![allow(non_camel_case_types)]
+
+#[repr(simd)] struct i8x1(i8);
+
+extern "platform-intrinsic" {
+    fn simd_extract<T, U>(x: T, idx: u32) -> U;
+}
+
+const X: i8x1 = i8x1(42);
+
+const fn extract_wrong_ret() -> i16 {
+    unsafe { simd_extract(X, 0_u32) }
+}
+
+const A: i16 = extract_wrong_ret();
+
+fn main() {}
diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.stderr b/src/test/ui/consts/const-eval/simd/extract-fail0.stderr
new file mode 100644 (file)
index 0000000..5151848
--- /dev/null
@@ -0,0 +1,15 @@
+thread 'rustc' panicked at 'assertion failed: `(left == right)`
+  left: `i8`,
+ right: `i16`: Return type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:281:17
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
+
+error: internal compiler error: unexpected panic
+
+note: the compiler unexpectedly panicked. this is a bug.
+
+note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
+
+note: rustc 1.39.0-dev running on x86_64-apple-darwin
+
+note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
+
diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.rs b/src/test/ui/consts/const-eval/simd/extract-fail1.rs
new file mode 100644 (file)
index 0000000..ddff608
--- /dev/null
@@ -0,0 +1,22 @@
+// failure-status: 101
+// rustc-env:RUST_BACKTRACE=0
+#![feature(const_fn)]
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+#![allow(non_camel_case_types)]
+
+#[repr(simd)] struct i8x1(i8);
+
+extern "platform-intrinsic" {
+    fn simd_extract<T, U>(x: T, idx: u32) -> U;
+}
+
+const X: i8x1 = i8x1(42);
+
+const fn extract_wrong_vec() -> i8 {
+    unsafe { simd_extract(42_i8, 0_u32) }
+}
+
+const B: i8 = extract_wrong_vec();
+
+fn main() {}
diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.stderr b/src/test/ui/consts/const-eval/simd/extract-fail1.stderr
new file mode 100644 (file)
index 0000000..a00d98b
--- /dev/null
@@ -0,0 +1,15 @@
+error: internal compiler error: src/librustc_mir/interpret/operand.rs:346: Type `i8` is not a SIMD vector type
+
+thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
+
+note: the compiler unexpectedly panicked. this is a bug.
+
+note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
+
+note: rustc 1.39.0-dev running on x86_64-apple-darwin
+
+note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.rs b/src/test/ui/consts/const-eval/simd/extract-fail2.rs
new file mode 100644 (file)
index 0000000..e2eb449
--- /dev/null
@@ -0,0 +1,22 @@
+// failure-status: 101
+// rustc-env:RUST_BACKTRACE=0
+#![feature(const_fn)]
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+#![allow(non_camel_case_types)]
+
+#[repr(simd)] struct i8x1(i8);
+
+extern "platform-intrinsic" {
+    fn simd_extract<T, U>(x: T, idx: u32) -> U;
+}
+
+const X: i8x1 = i8x1(42);
+
+const fn extract_wrong_idx() -> i8 {
+    unsafe { simd_extract(X, 1_u32) }
+}
+
+const C: i8 = extract_wrong_idx();
+
+fn main() {}
diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.stderr b/src/test/ui/consts/const-eval/simd/extract-fail2.stderr
new file mode 100644 (file)
index 0000000..5d74e11
--- /dev/null
@@ -0,0 +1,13 @@
+thread 'rustc' panicked at 'index `1` is out-of-bounds of vector type `i8` with length `1`', src/librustc_mir/interpret/intrinsics.rs:276:17
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
+
+error: internal compiler error: unexpected panic
+
+note: the compiler unexpectedly panicked. this is a bug.
+
+note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
+
+note: rustc 1.39.0-dev running on x86_64-apple-darwin
+
+note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
+
diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.rs b/src/test/ui/consts/const-eval/simd/insert-fail0.rs
new file mode 100644 (file)
index 0000000..dca58fb
--- /dev/null
@@ -0,0 +1,22 @@
+// failure-status: 101
+// rustc-env:RUST_BACKTRACE=0
+#![feature(const_fn)]
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+#![allow(non_camel_case_types)]
+
+#[repr(simd)] struct i8x1(i8);
+
+extern "platform-intrinsic" {
+    fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
+}
+
+const X: i8x1 = i8x1(42);
+
+const fn insert_wrong_scalar() -> i8x1 {
+    unsafe { simd_insert(X, 0_u32, 42_i16) }
+}
+
+const D: i8x1 = insert_wrong_scalar();
+
+fn main() {}
diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.stderr b/src/test/ui/consts/const-eval/simd/insert-fail0.stderr
new file mode 100644 (file)
index 0000000..1ea31ec
--- /dev/null
@@ -0,0 +1,15 @@
+thread 'rustc' panicked at 'assertion failed: `(left == right)`
+  left: `i16`,
+ right: `i8`: Scalar type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:257:17
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
+
+error: internal compiler error: unexpected panic
+
+note: the compiler unexpectedly panicked. this is a bug.
+
+note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
+
+note: rustc 1.39.0-dev running on x86_64-apple-darwin
+
+note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
+
diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.rs b/src/test/ui/consts/const-eval/simd/insert-fail1.rs
new file mode 100644 (file)
index 0000000..2a3d79b
--- /dev/null
@@ -0,0 +1,22 @@
+// failure-status: 101
+// rustc-env:RUST_BACKTRACE=0
+#![feature(const_fn)]
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+#![allow(non_camel_case_types)]
+
+#[repr(simd)] struct i8x1(i8);
+
+extern "platform-intrinsic" {
+    fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
+}
+
+const X: i8x1 = i8x1(42);
+
+const fn insert_wrong_idx() -> i8x1 {
+    unsafe { simd_insert(X, 1_u32, 42_i8) }
+}
+
+const E: i8x1 = insert_wrong_idx();
+
+fn main() {}
diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.stderr b/src/test/ui/consts/const-eval/simd/insert-fail1.stderr
new file mode 100644 (file)
index 0000000..38d3782
--- /dev/null
@@ -0,0 +1,13 @@
+thread 'rustc' panicked at 'Index `1` must be in bounds of vector type `i8`: `[0, 1)`', src/librustc_mir/interpret/intrinsics.rs:247:17
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
+
+error: internal compiler error: unexpected panic
+
+note: the compiler unexpectedly panicked. this is a bug.
+
+note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
+
+note: rustc 1.39.0-dev running on x86_64-apple-darwin
+
+note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
+
diff --git a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs
deleted file mode 100644 (file)
index 1d1df8d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#![feature(const_fn)]
-#![feature(repr_simd)]
-#![feature(platform_intrinsics)]
-#![allow(non_camel_case_types)]
-
-#[repr(simd)] struct i8x1(i8);
-
-extern "platform-intrinsic" {
-    fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
-    fn simd_extract<T, U>(x: T, idx: u32) -> U;
-}
-
-const fn foo(x: i8x1) -> i8 {
-    // 42 is a i16 that does not fit in a i8
-    unsafe { simd_insert(x, 0_u32, 42_i16) }.0  //~ ERROR
-}
-
-const fn bar(x: i8x1) -> i16 {
-    // the i8 is not a i16:
-    unsafe { simd_extract(x, 0_u32) }  //~ ERROR
-}
-
-fn main() {
-    const V: i8x1 = i8x1(13);
-    const X: i8 = foo(V);
-    const Y: i16 = bar(V);
-}
diff --git a/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr b/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr
deleted file mode 100644 (file)
index cf4e688..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error: any use of this value will cause an error
-  --> $DIR/insert_extract-fail.rs:14:14
-   |
-LL |     unsafe { simd_insert(x, 0_u32, 42_i16) }.0
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |              |
-   |              Inserting `i16` with size `2` to a vector element place of size `1`
-   |              inside call to `foo` at $DIR/insert_extract-fail.rs:19:19
-...
-LL |     const X: i8 = foo(V);
-   |     ---------------------
-   |
-   = note: `#[deny(const_err)]` on by default
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/consts/const-eval/simd/read_fail.rs b/src/test/ui/consts/const-eval/simd/read_fail.rs
deleted file mode 100644 (file)
index c5109c1..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#![feature(const_fn)]
-#![feature(platform_intrinsics)]
-#![allow(non_camel_case_types)]
-
-extern "platform-intrinsic" {
-    fn simd_extract<T, U>(x: T, idx: u32) -> U;
-}
-
-const fn foo(x: i8) -> i8 {
-    // i8 is not a vector type:
-    unsafe { simd_extract(x, 0_u32) }  //~ ERROR
-}
-
-fn main() {
-    const V: i8 = 13;
-    const X: i8 = foo(V);
-}