Skip to content

Commit 524a7af

Browse files
committed
Rollup merge of rust-lang#59201 - lambda:remove-repr-simd-isize-usize-restriction, r=alexcrichton
Remove restriction on isize/usize in repr(simd) As discussed in rust-lang#55078, there's no known reason for this restriction. It's unlikely that repr(simd) will be stabilized in its current form, but might as well remove some restrictions on it. This removes the branch in `is_machine` which returns false for these types. `is_machine` is only used for the repr(simd) type validation check.
2 parents 0b2c348 + 5303c1b commit 524a7af

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

src/librustc/ty/sty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
19111911

19121912
pub fn is_machine(&self) -> bool {
19131913
match self.sty {
1914-
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => false,
19151914
Int(..) | Uint(..) | Float(..) => true,
19161915
_ => false,
19171916
}

src/test/run-pass/simd/simd-size-align.rs

+32
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ fn main() {
3737
check::<f32x6>();
3838
check::<f32x7>();
3939
check::<f32x8>();
40+
41+
check::<usizex2>();
42+
check::<usizex3>();
43+
check::<usizex4>();
44+
check::<usizex5>();
45+
check::<usizex6>();
46+
check::<usizex7>();
47+
check::<usizex8>();
48+
49+
check::<isizex2>();
50+
check::<isizex3>();
51+
check::<isizex4>();
52+
check::<isizex5>();
53+
check::<isizex6>();
54+
check::<isizex7>();
55+
check::<isizex8>();
4056
}
4157

4258
#[repr(simd)] struct u8x2(u8, u8);
@@ -62,3 +78,19 @@ fn main() {
6278
#[repr(simd)] struct f32x6(f32, f32, f32, f32, f32, f32);
6379
#[repr(simd)] struct f32x7(f32, f32, f32, f32, f32, f32, f32);
6480
#[repr(simd)] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32);
81+
82+
#[repr(simd)] struct usizex2(usize, usize);
83+
#[repr(simd)] struct usizex3(usize, usize, usize);
84+
#[repr(simd)] struct usizex4(usize, usize, usize, usize);
85+
#[repr(simd)] struct usizex5(usize, usize, usize, usize, usize);
86+
#[repr(simd)] struct usizex6(usize, usize, usize, usize, usize, usize);
87+
#[repr(simd)] struct usizex7(usize, usize, usize, usize, usize, usize, usize);
88+
#[repr(simd)] struct usizex8(usize, usize, usize, usize, usize, usize, usize, usize);
89+
90+
#[repr(simd)] struct isizex2(isize, isize);
91+
#[repr(simd)] struct isizex3(isize, isize, isize);
92+
#[repr(simd)] struct isizex4(isize, isize, isize, isize);
93+
#[repr(simd)] struct isizex5(isize, isize, isize, isize, isize);
94+
#[repr(simd)] struct isizex6(isize, isize, isize, isize, isize, isize);
95+
#[repr(simd)] struct isizex7(isize, isize, isize, isize, isize, isize, isize);
96+
#[repr(simd)] struct isizex8(isize, isize, isize, isize, isize, isize, isize, isize);

src/test/ui/simd-type.rs

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@ struct empty; //~ ERROR SIMD vector cannot be empty
77
#[repr(simd)]
88
struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous
99

10-
#[repr(simd)]
11-
struct int4(isize, isize, isize, isize); //~ ERROR SIMD vector element type should be machine type
12-
1310
fn main() {}

src/test/ui/simd-type.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ error[E0076]: SIMD vector should be homogeneous
1010
LL | struct i64f64(i64, f64);
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type
1212

13-
error[E0077]: SIMD vector element type should be machine type
14-
--> $DIR/simd-type.rs:11:1
15-
|
16-
LL | struct int4(isize, isize, isize, isize);
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18-
19-
error: aborting due to 3 previous errors
13+
error: aborting due to 2 previous errors
2014

21-
Some errors occurred: E0075, E0076, E0077.
15+
Some errors occurred: E0075, E0076.
2216
For more information about an error, try `rustc --explain E0075`.

0 commit comments

Comments
 (0)