Skip to content

Commit e6239bb

Browse files
committed
Add some more tests
1 parent f0bbd2b commit e6239bb

File tree

2 files changed

+296
-27
lines changed

2 files changed

+296
-27
lines changed

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

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,49 @@
55
#![allow(non_camel_case_types)]
66

77
#[repr(simd)] struct i8x1(i8);
8+
#[repr(simd)] struct u16x2(u16, u16);
9+
#[repr(simd)] struct f32x3(f32, f32, f32);
810

911
extern "platform-intrinsic" {
1012
fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
1113
fn simd_extract<T, U>(x: T, idx: u32) -> U;
1214
}
1315

14-
const fn foo(x: i8x1) -> i8 {
15-
unsafe { simd_insert(x, 0_u32, 42_i8) }.0
16-
}
17-
1816
fn main() {
19-
const V: i8x1 = i8x1(13);
20-
const X: i8 = foo(V);
21-
const Y: i8 = unsafe { simd_extract(V, 0) };
22-
assert_eq!(X, 42);
23-
assert_eq!(Y, 13);
17+
{
18+
const U: i8x1 = i8x1(13);
19+
const V: i8x1 = unsafe { simd_insert(U, 0_u32, 42_i8) };
20+
const X0: i8 = V.0;
21+
const Y0: i8 = unsafe { simd_extract(V, 0) };
22+
assert_eq!(X0, 42);
23+
assert_eq!(Y0, 42);
24+
}
25+
{
26+
const U: u16x2 = u16x2(13, 14);
27+
const V: u16x2 = unsafe { simd_insert(U, 1_u32, 42_u16) };
28+
const X0: u16 = V.0;
29+
const X1: u16 = V.1;
30+
const Y0: u16 = unsafe { simd_extract(V, 0) };
31+
const Y1: u16 = unsafe { simd_extract(V, 1) };
32+
assert_eq!(X0, 13);
33+
assert_eq!(X1, 42);
34+
assert_eq!(Y0, 13);
35+
assert_eq!(Y1, 42);
36+
}
37+
{
38+
const U: f32x3 = f32x3(13., 14., 15.);
39+
const V: f32x3 = unsafe { simd_insert(U, 1_u32, 42_f32) };
40+
const X0: f32 = V.0;
41+
const X1: f32 = V.1;
42+
const X2: f32 = V.2;
43+
const Y0: f32 = unsafe { simd_extract(V, 0) };
44+
const Y1: f32 = unsafe { simd_extract(V, 1) };
45+
const Y2: f32 = unsafe { simd_extract(V, 2) };
46+
assert_eq!(X0, 13.);
47+
assert_eq!(X1, 42.);
48+
assert_eq!(X2, 15.);
49+
assert_eq!(Y0, 13.);
50+
assert_eq!(Y1, 42.);
51+
assert_eq!(Y2, 15.);
52+
}
2453
}
Lines changed: 258 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,288 @@
11
warning: skipping const checks
2-
--> $DIR/insert_extract.rs:22:5
2+
--> $DIR/insert_extract.rs:22:9
33
|
4-
LL | assert_eq!(X, 42);
5-
| ^^^^^^^^^^^^^^^^^^
4+
LL | assert_eq!(X0, 42);
5+
| ^^^^^^^^^^^^^^^^^^^
66
|
77
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
88

99
warning: skipping const checks
10-
--> $DIR/insert_extract.rs:22:5
10+
--> $DIR/insert_extract.rs:22:9
1111
|
12-
LL | assert_eq!(X, 42);
13-
| ^^^^^^^^^^^^^^^^^^
12+
LL | assert_eq!(X0, 42);
13+
| ^^^^^^^^^^^^^^^^^^^
1414
|
1515
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1616

1717
warning: skipping const checks
18-
--> $DIR/insert_extract.rs:22:5
18+
--> $DIR/insert_extract.rs:22:9
1919
|
20-
LL | assert_eq!(X, 42);
21-
| ^^^^^^^^^^^^^^^^^^
20+
LL | assert_eq!(X0, 42);
21+
| ^^^^^^^^^^^^^^^^^^^
2222
|
2323
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2424

2525
warning: skipping const checks
26-
--> $DIR/insert_extract.rs:23:5
26+
--> $DIR/insert_extract.rs:23:9
2727
|
28-
LL | assert_eq!(Y, 13);
29-
| ^^^^^^^^^^^^^^^^^^
28+
LL | assert_eq!(Y0, 42);
29+
| ^^^^^^^^^^^^^^^^^^^
3030
|
3131
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
3232

3333
warning: skipping const checks
34-
--> $DIR/insert_extract.rs:23:5
34+
--> $DIR/insert_extract.rs:23:9
3535
|
36-
LL | assert_eq!(Y, 13);
37-
| ^^^^^^^^^^^^^^^^^^
36+
LL | assert_eq!(Y0, 42);
37+
| ^^^^^^^^^^^^^^^^^^^
3838
|
3939
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
4040

4141
warning: skipping const checks
42-
--> $DIR/insert_extract.rs:23:5
42+
--> $DIR/insert_extract.rs:23:9
4343
|
44-
LL | assert_eq!(Y, 13);
45-
| ^^^^^^^^^^^^^^^^^^
44+
LL | assert_eq!(Y0, 42);
45+
| ^^^^^^^^^^^^^^^^^^^
46+
|
47+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
48+
49+
warning: skipping const checks
50+
--> $DIR/insert_extract.rs:32:9
51+
|
52+
LL | assert_eq!(X0, 13);
53+
| ^^^^^^^^^^^^^^^^^^^
54+
|
55+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
56+
57+
warning: skipping const checks
58+
--> $DIR/insert_extract.rs:32:9
59+
|
60+
LL | assert_eq!(X0, 13);
61+
| ^^^^^^^^^^^^^^^^^^^
62+
|
63+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
64+
65+
warning: skipping const checks
66+
--> $DIR/insert_extract.rs:32:9
67+
|
68+
LL | assert_eq!(X0, 13);
69+
| ^^^^^^^^^^^^^^^^^^^
70+
|
71+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
72+
73+
warning: skipping const checks
74+
--> $DIR/insert_extract.rs:33:9
75+
|
76+
LL | assert_eq!(X1, 42);
77+
| ^^^^^^^^^^^^^^^^^^^
78+
|
79+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
80+
81+
warning: skipping const checks
82+
--> $DIR/insert_extract.rs:33:9
83+
|
84+
LL | assert_eq!(X1, 42);
85+
| ^^^^^^^^^^^^^^^^^^^
86+
|
87+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
88+
89+
warning: skipping const checks
90+
--> $DIR/insert_extract.rs:33:9
91+
|
92+
LL | assert_eq!(X1, 42);
93+
| ^^^^^^^^^^^^^^^^^^^
94+
|
95+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
96+
97+
warning: skipping const checks
98+
--> $DIR/insert_extract.rs:34:9
99+
|
100+
LL | assert_eq!(Y0, 13);
101+
| ^^^^^^^^^^^^^^^^^^^
102+
|
103+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
104+
105+
warning: skipping const checks
106+
--> $DIR/insert_extract.rs:34:9
107+
|
108+
LL | assert_eq!(Y0, 13);
109+
| ^^^^^^^^^^^^^^^^^^^
110+
|
111+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
112+
113+
warning: skipping const checks
114+
--> $DIR/insert_extract.rs:34:9
115+
|
116+
LL | assert_eq!(Y0, 13);
117+
| ^^^^^^^^^^^^^^^^^^^
118+
|
119+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
120+
121+
warning: skipping const checks
122+
--> $DIR/insert_extract.rs:35:9
123+
|
124+
LL | assert_eq!(Y1, 42);
125+
| ^^^^^^^^^^^^^^^^^^^
126+
|
127+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
128+
129+
warning: skipping const checks
130+
--> $DIR/insert_extract.rs:35:9
131+
|
132+
LL | assert_eq!(Y1, 42);
133+
| ^^^^^^^^^^^^^^^^^^^
134+
|
135+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
136+
137+
warning: skipping const checks
138+
--> $DIR/insert_extract.rs:35:9
139+
|
140+
LL | assert_eq!(Y1, 42);
141+
| ^^^^^^^^^^^^^^^^^^^
142+
|
143+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
144+
145+
warning: skipping const checks
146+
--> $DIR/insert_extract.rs:46:9
147+
|
148+
LL | assert_eq!(X0, 13.);
149+
| ^^^^^^^^^^^^^^^^^^^^
150+
|
151+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
152+
153+
warning: skipping const checks
154+
--> $DIR/insert_extract.rs:46:9
155+
|
156+
LL | assert_eq!(X0, 13.);
157+
| ^^^^^^^^^^^^^^^^^^^^
158+
|
159+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
160+
161+
warning: skipping const checks
162+
--> $DIR/insert_extract.rs:46:9
163+
|
164+
LL | assert_eq!(X0, 13.);
165+
| ^^^^^^^^^^^^^^^^^^^^
166+
|
167+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
168+
169+
warning: skipping const checks
170+
--> $DIR/insert_extract.rs:47:9
171+
|
172+
LL | assert_eq!(X1, 42.);
173+
| ^^^^^^^^^^^^^^^^^^^^
174+
|
175+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
176+
177+
warning: skipping const checks
178+
--> $DIR/insert_extract.rs:47:9
179+
|
180+
LL | assert_eq!(X1, 42.);
181+
| ^^^^^^^^^^^^^^^^^^^^
182+
|
183+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
184+
185+
warning: skipping const checks
186+
--> $DIR/insert_extract.rs:47:9
187+
|
188+
LL | assert_eq!(X1, 42.);
189+
| ^^^^^^^^^^^^^^^^^^^^
190+
|
191+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
192+
193+
warning: skipping const checks
194+
--> $DIR/insert_extract.rs:48:9
195+
|
196+
LL | assert_eq!(X2, 15.);
197+
| ^^^^^^^^^^^^^^^^^^^^
198+
|
199+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
200+
201+
warning: skipping const checks
202+
--> $DIR/insert_extract.rs:48:9
203+
|
204+
LL | assert_eq!(X2, 15.);
205+
| ^^^^^^^^^^^^^^^^^^^^
206+
|
207+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
208+
209+
warning: skipping const checks
210+
--> $DIR/insert_extract.rs:48:9
211+
|
212+
LL | assert_eq!(X2, 15.);
213+
| ^^^^^^^^^^^^^^^^^^^^
214+
|
215+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
216+
217+
warning: skipping const checks
218+
--> $DIR/insert_extract.rs:49:9
219+
|
220+
LL | assert_eq!(Y0, 13.);
221+
| ^^^^^^^^^^^^^^^^^^^^
222+
|
223+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
224+
225+
warning: skipping const checks
226+
--> $DIR/insert_extract.rs:49:9
227+
|
228+
LL | assert_eq!(Y0, 13.);
229+
| ^^^^^^^^^^^^^^^^^^^^
230+
|
231+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
232+
233+
warning: skipping const checks
234+
--> $DIR/insert_extract.rs:49:9
235+
|
236+
LL | assert_eq!(Y0, 13.);
237+
| ^^^^^^^^^^^^^^^^^^^^
238+
|
239+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
240+
241+
warning: skipping const checks
242+
--> $DIR/insert_extract.rs:50:9
243+
|
244+
LL | assert_eq!(Y1, 42.);
245+
| ^^^^^^^^^^^^^^^^^^^^
246+
|
247+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
248+
249+
warning: skipping const checks
250+
--> $DIR/insert_extract.rs:50:9
251+
|
252+
LL | assert_eq!(Y1, 42.);
253+
| ^^^^^^^^^^^^^^^^^^^^
254+
|
255+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
256+
257+
warning: skipping const checks
258+
--> $DIR/insert_extract.rs:50:9
259+
|
260+
LL | assert_eq!(Y1, 42.);
261+
| ^^^^^^^^^^^^^^^^^^^^
262+
|
263+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
264+
265+
warning: skipping const checks
266+
--> $DIR/insert_extract.rs:51:9
267+
|
268+
LL | assert_eq!(Y2, 15.);
269+
| ^^^^^^^^^^^^^^^^^^^^
270+
|
271+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
272+
273+
warning: skipping const checks
274+
--> $DIR/insert_extract.rs:51:9
275+
|
276+
LL | assert_eq!(Y2, 15.);
277+
| ^^^^^^^^^^^^^^^^^^^^
278+
|
279+
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
280+
281+
warning: skipping const checks
282+
--> $DIR/insert_extract.rs:51:9
283+
|
284+
LL | assert_eq!(Y2, 15.);
285+
| ^^^^^^^^^^^^^^^^^^^^
46286
|
47287
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
48288

0 commit comments

Comments
 (0)