Skip to content

Commit e74a268

Browse files
committed
Test errors
1 parent 5976674 commit e74a268

14 files changed

+191
-75
lines changed

src/librustc_mir/interpret/intrinsics.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
241241
}
242242
"simd_insert" => {
243243
let index = self.read_scalar(args[1])?.to_u32()? as u64;
244-
let scalar = self.read_immediate(args[2])?;
244+
let scalar = args[2];
245245
let input = args[0];
246246
let (len, e_ty) = self.read_vector_ty(input);
247247
assert!(
248248
index < len,
249-
"index `{}` must be in bounds of vector type `{}`: `[0, {})`",
249+
"Index `{}` must be in bounds of vector type `{}`: `[0, {})`",
250250
index, e_ty, len
251251
);
252252
assert_eq!(
253-
args[0].layout, dest.layout,
253+
input.layout, dest.layout,
254254
"Return type `{}` must match vector type `{}`",
255255
dest.layout.ty, input.layout.ty
256256
);
@@ -261,34 +261,29 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
261261
);
262262

263263
for i in 0..len {
264-
let place = self.place_field(dest, index)?;
265-
if i == index {
266-
self.write_immediate(*scalar, place)?;
264+
let place = self.place_field(dest, i)?;
265+
let value = if i == index {
266+
scalar
267267
} else {
268-
self.write_immediate(
269-
*self.read_immediate(self.operand_field(input, index)?)?,
270-
place
271-
)?;
268+
self.operand_field(input, i)?
272269
};
270+
self.copy_op(value, place)?;
273271
}
274272
}
275273
"simd_extract" => {
276274
let index = self.read_scalar(args[1])?.to_u32()? as _;
277275
let (len, e_ty) = self.read_vector_ty(args[0]);
278276
assert!(
279277
index < len,
280-
"index `{}` must be in bounds of vector type `{}`: `[0, {})`",
278+
"index `{}` is out-of-bounds of vector type `{}` with length `{}`",
281279
index, e_ty, len
282280
);
283281
assert_eq!(
284282
e_ty, dest.layout.ty,
285283
"Return type `{}` must match vector element type `{}`",
286284
dest.layout.ty, e_ty
287285
);
288-
self.write_immediate(
289-
*self.read_immediate(self.operand_field(args[0], index)?)?,
290-
dest
291-
)?;
286+
self.copy_op(self.operand_field(args[0], index)?, dest)?;
292287
}
293288
_ => return Ok(false),
294289
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// failure-status: 101
2+
// rustc-env:RUST_BACKTRACE=0
3+
#![feature(const_fn)]
4+
#![feature(repr_simd)]
5+
#![feature(platform_intrinsics)]
6+
#![allow(non_camel_case_types)]
7+
8+
#[repr(simd)] struct i8x1(i8);
9+
10+
extern "platform-intrinsic" {
11+
fn simd_extract<T, U>(x: T, idx: u32) -> U;
12+
}
13+
14+
const X: i8x1 = i8x1(42);
15+
16+
const fn extract_wrong_ret() -> i16 {
17+
unsafe { simd_extract(X, 0_u32) }
18+
}
19+
20+
const A: i16 = extract_wrong_ret();
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
thread 'rustc' panicked at 'assertion failed: `(left == right)`
2+
left: `i8`,
3+
right: `i16`: Return type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:281:17
4+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
5+
6+
error: internal compiler error: unexpected panic
7+
8+
note: the compiler unexpectedly panicked. this is a bug.
9+
10+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
11+
12+
note: rustc 1.39.0-dev running on x86_64-apple-darwin
13+
14+
note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// failure-status: 101
2+
// rustc-env:RUST_BACKTRACE=0
3+
#![feature(const_fn)]
4+
#![feature(repr_simd)]
5+
#![feature(platform_intrinsics)]
6+
#![allow(non_camel_case_types)]
7+
8+
#[repr(simd)] struct i8x1(i8);
9+
10+
extern "platform-intrinsic" {
11+
fn simd_extract<T, U>(x: T, idx: u32) -> U;
12+
}
13+
14+
const X: i8x1 = i8x1(42);
15+
16+
const fn extract_wrong_vec() -> i8 {
17+
unsafe { simd_extract(42_i8, 0_u32) }
18+
}
19+
20+
const B: i8 = extract_wrong_vec();
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: internal compiler error: src/librustc_mir/interpret/operand.rs:346: Type `i8` is not a SIMD vector type
2+
3+
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
4+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
5+
6+
note: the compiler unexpectedly panicked. this is a bug.
7+
8+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
9+
10+
note: rustc 1.39.0-dev running on x86_64-apple-darwin
11+
12+
note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
13+
14+
error: aborting due to previous error
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// failure-status: 101
2+
// rustc-env:RUST_BACKTRACE=0
3+
#![feature(const_fn)]
4+
#![feature(repr_simd)]
5+
#![feature(platform_intrinsics)]
6+
#![allow(non_camel_case_types)]
7+
8+
#[repr(simd)] struct i8x1(i8);
9+
10+
extern "platform-intrinsic" {
11+
fn simd_extract<T, U>(x: T, idx: u32) -> U;
12+
}
13+
14+
const X: i8x1 = i8x1(42);
15+
16+
const fn extract_wrong_idx() -> i8 {
17+
unsafe { simd_extract(X, 1_u32) }
18+
}
19+
20+
const C: i8 = extract_wrong_idx();
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
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
2+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
3+
4+
error: internal compiler error: unexpected panic
5+
6+
note: the compiler unexpectedly panicked. this is a bug.
7+
8+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
9+
10+
note: rustc 1.39.0-dev running on x86_64-apple-darwin
11+
12+
note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// failure-status: 101
2+
// rustc-env:RUST_BACKTRACE=0
3+
#![feature(const_fn)]
4+
#![feature(repr_simd)]
5+
#![feature(platform_intrinsics)]
6+
#![allow(non_camel_case_types)]
7+
8+
#[repr(simd)] struct i8x1(i8);
9+
10+
extern "platform-intrinsic" {
11+
fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
12+
}
13+
14+
const X: i8x1 = i8x1(42);
15+
16+
const fn insert_wrong_scalar() -> i8x1 {
17+
unsafe { simd_insert(X, 0_u32, 42_i16) }
18+
}
19+
20+
const D: i8x1 = insert_wrong_scalar();
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
thread 'rustc' panicked at 'assertion failed: `(left == right)`
2+
left: `i16`,
3+
right: `i8`: Scalar type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:257:17
4+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
5+
6+
error: internal compiler error: unexpected panic
7+
8+
note: the compiler unexpectedly panicked. this is a bug.
9+
10+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
11+
12+
note: rustc 1.39.0-dev running on x86_64-apple-darwin
13+
14+
note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// failure-status: 101
2+
// rustc-env:RUST_BACKTRACE=0
3+
#![feature(const_fn)]
4+
#![feature(repr_simd)]
5+
#![feature(platform_intrinsics)]
6+
#![allow(non_camel_case_types)]
7+
8+
#[repr(simd)] struct i8x1(i8);
9+
10+
extern "platform-intrinsic" {
11+
fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
12+
}
13+
14+
const X: i8x1 = i8x1(42);
15+
16+
const fn insert_wrong_idx() -> i8x1 {
17+
unsafe { simd_insert(X, 1_u32, 42_i8) }
18+
}
19+
20+
const E: i8x1 = insert_wrong_idx();
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
thread 'rustc' panicked at 'Index `1` must be in bounds of vector type `i8`: `[0, 1)`', src/librustc_mir/interpret/intrinsics.rs:247:17
2+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
3+
4+
error: internal compiler error: unexpected panic
5+
6+
note: the compiler unexpectedly panicked. this is a bug.
7+
8+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
9+
10+
note: rustc 1.39.0-dev running on x86_64-apple-darwin
11+
12+
note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
13+

src/test/ui/consts/const-eval/simd/insert_extract-fail.rs

-27
This file was deleted.

src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr

-16
This file was deleted.

src/test/ui/consts/const-eval/simd/read_fail.rs

-17
This file was deleted.

0 commit comments

Comments
 (0)