Skip to content

Commit b4a5f3b

Browse files
committed
Test #[rustc_simd_monomorphize_lane_limit] cross-crate
1 parent 61ad7c6 commit b4a5f3b

File tree

6 files changed

+31
-24
lines changed

6 files changed

+31
-24
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![feature(rustc_attrs, repr_simd)]
2+
3+
#[repr(simd, packed)]
4+
#[rustc_simd_monomorphize_lane_limit = "8"]
5+
pub struct Simd<T, const N: usize>(pub [T; N]);
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#![feature(rustc_attrs, repr_simd)]
2-
31
//@ build-fail
2+
//@ aux-crate:simd=simd-lane-limit.rs
3+
4+
extern crate simd;
45

5-
#[repr(simd, packed)]
6-
#[rustc_simd_monomorphize_lane_limit = "4"]
7-
struct V<T, const N: usize>([T; N]);
6+
use simd::Simd;
87

98
fn main() {
10-
let _a: V<i32, 6> = V([0; 6]); //~ ERROR the SIMD type `V<i32, 6>` has more elements than the limit 4
9+
// test non-power-of-two, since #[repr(simd, packed)] has unusual layout
10+
let _x: Simd<i32, 24> = Simd([0; 24]);
11+
//~^ ERROR the SIMD type `simd::Simd<i32, 24>` has more elements than the limit 8
1112
}

tests/ui/simd/simd-lane-limit-err-npow2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error: the SIMD type `V<i32, 6>` has more elements than the limit 4
1+
error: the SIMD type `simd::Simd<i32, 24>` has more elements than the limit 8
22
--> $DIR/simd-lane-limit-err-npow2.rs:10:9
33
|
4-
LL | let _a: V<i32, 6> = V([0; 6]);
4+
LL | let _x: Simd<i32, 24> = Simd([0; 24]);
55
| ^^
66

77
error: aborting due to 1 previous error
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#![feature(rustc_attrs, repr_simd)]
2-
31
//@ build-fail
2+
//@ aux-crate:simd=simd-lane-limit.rs
3+
4+
extern crate simd;
45

5-
#[repr(simd, packed)]
6-
#[rustc_simd_monomorphize_lane_limit = "4"]
7-
struct V<T, const N: usize>([T; N]);
6+
use simd::Simd;
87

98
fn main() {
10-
let _a: V<i32, 8> = V([0; 8]); //~ ERROR the SIMD type `V<i32, 8>` has more elements than the limit 4
9+
let _x: Simd<i32, 16> = Simd([0; 16]);
10+
//~^ ERROR the SIMD type `simd::Simd<i32, 16>` has more elements than the limit 8
1111
}

tests/ui/simd/simd-lane-limit-err.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error: the SIMD type `V<i32, 8>` has more elements than the limit 4
2-
--> $DIR/simd-lane-limit-err.rs:10:9
1+
error: the SIMD type `simd::Simd<i32, 16>` has more elements than the limit 8
2+
--> $DIR/simd-lane-limit-err.rs:9:9
33
|
4-
LL | let _a: V<i32, 8> = V([0; 8]);
4+
LL | let _x: Simd<i32, 16> = Simd([0; 16]);
55
| ^^
66

77
error: aborting due to 1 previous error
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
#![feature(rustc_attrs, repr_simd)]
2-
31
//@ build-pass
2+
//@ aux-crate:simd=simd-lane-limit.rs
43

5-
#[repr(simd, packed)]
6-
#[rustc_simd_monomorphize_lane_limit = "8"]
7-
struct V<T, const N: usize>([T; N]);
4+
extern crate simd;
85

9-
const LANES: usize = 4;
6+
use simd::Simd;
107

118
fn main() {
12-
let _x: V<i32, LANES> = V([0; LANES]);
9+
let _x: Simd<i32, 4> = Simd([0; 4]);
10+
let _y: Simd<i32, 8> = Simd([0; 8]);
11+
12+
// test non-power-of-two, since #[repr(simd, packed)] has unusual layout
13+
let _z: Simd<i32, 6> = Simd([0; 6]);
1314
}

0 commit comments

Comments
 (0)