Skip to content

Commit 86dc7b7

Browse files
committed
Auto merge of #121549 - matthiaskrgr:rollup-1hvu3lb, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #121435 (Account for RPITIT in E0310 explicit lifetime constraint suggestion) - #121490 (Rustdoc: include crate name in links for local primitives) - #121520 (delay cloning of iterator items) - #121522 (check that simd_insert/extract indices are in-bounds) - #121531 (Ignore less tests in debug builds) - #121539 (compiler/rustc_target/src/spec/base/apple/tests.rs: Avoid unnecessary large move) - #121542 (update stdarch) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f00f27a + 058b4b1 commit 86dc7b7

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/shims/intrinsics/simd.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
563563
let right_idx = src_index.checked_sub(left_len).unwrap();
564564
this.read_immediate(&this.project_index(&right, right_idx)?)?
565565
} else {
566-
span_bug!(
567-
this.cur_span(),
568-
"simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}",
566+
throw_ub_format!(
567+
"`simd_shuffle_generic` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
569568
);
570569
};
571570
this.write_immediate(*val, &dest)?;
@@ -604,9 +603,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
604603
let right_idx = src_index.checked_sub(left_len).unwrap();
605604
this.read_immediate(&this.project_index(&right, right_idx)?)?
606605
} else {
607-
span_bug!(
608-
this.cur_span(),
609-
"simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}",
606+
throw_ub_format!(
607+
"`simd_shuffle` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
610608
);
611609
};
612610
this.write_immediate(*val, &dest)?;

tests/fail/intrinsics/simd-extract.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(portable_simd, core_intrinsics)]
2+
use std::simd::*;
3+
4+
fn main() {
5+
let v = i32x4::splat(0);
6+
let _x: i32 = unsafe { std::intrinsics::simd::simd_extract(v, 4) };
7+
//~^ERROR: index 4 is out-of-bounds
8+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `simd_extract` index 4 is out-of-bounds of vector with length 4
2+
--> $DIR/simd-extract.rs:LL:CC
3+
|
4+
LL | let _x: i32 = unsafe { std::intrinsics::simd::simd_extract(v, 4) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `simd_extract` index 4 is out-of-bounds of vector with length 4
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/simd-extract.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

0 commit comments

Comments
 (0)