Skip to content

Commit

Permalink
Remove restriction on isize/usize in repr(simd)
Browse files Browse the repository at this point in the history
As discussed in #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.
  • Loading branch information
lambda committed Mar 15, 2019
1 parent bc44841 commit 5303c1b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {

pub fn is_machine(&self) -> bool {
match self.sty {
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => false,
Int(..) | Uint(..) | Float(..) => true,
_ => false,
}
Expand Down
32 changes: 32 additions & 0 deletions src/test/run-pass/simd/simd-size-align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ fn main() {
check::<f32x6>();
check::<f32x7>();
check::<f32x8>();

check::<usizex2>();
check::<usizex3>();
check::<usizex4>();
check::<usizex5>();
check::<usizex6>();
check::<usizex7>();
check::<usizex8>();

check::<isizex2>();
check::<isizex3>();
check::<isizex4>();
check::<isizex5>();
check::<isizex6>();
check::<isizex7>();
check::<isizex8>();
}

#[repr(simd)] struct u8x2(u8, u8);
Expand All @@ -62,3 +78,19 @@ fn main() {
#[repr(simd)] struct f32x6(f32, f32, f32, f32, f32, f32);
#[repr(simd)] struct f32x7(f32, f32, f32, f32, f32, f32, f32);
#[repr(simd)] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32);

#[repr(simd)] struct usizex2(usize, usize);
#[repr(simd)] struct usizex3(usize, usize, usize);
#[repr(simd)] struct usizex4(usize, usize, usize, usize);
#[repr(simd)] struct usizex5(usize, usize, usize, usize, usize);
#[repr(simd)] struct usizex6(usize, usize, usize, usize, usize, usize);
#[repr(simd)] struct usizex7(usize, usize, usize, usize, usize, usize, usize);
#[repr(simd)] struct usizex8(usize, usize, usize, usize, usize, usize, usize, usize);

#[repr(simd)] struct isizex2(isize, isize);
#[repr(simd)] struct isizex3(isize, isize, isize);
#[repr(simd)] struct isizex4(isize, isize, isize, isize);
#[repr(simd)] struct isizex5(isize, isize, isize, isize, isize);
#[repr(simd)] struct isizex6(isize, isize, isize, isize, isize, isize);
#[repr(simd)] struct isizex7(isize, isize, isize, isize, isize, isize, isize);
#[repr(simd)] struct isizex8(isize, isize, isize, isize, isize, isize, isize, isize);
3 changes: 0 additions & 3 deletions src/test/ui/simd-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ struct empty; //~ ERROR SIMD vector cannot be empty
#[repr(simd)]
struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous

#[repr(simd)]
struct int4(isize, isize, isize, isize); //~ ERROR SIMD vector element type should be machine type

fn main() {}
10 changes: 2 additions & 8 deletions src/test/ui/simd-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ error[E0076]: SIMD vector should be homogeneous
LL | struct i64f64(i64, f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type

error[E0077]: SIMD vector element type should be machine type
--> $DIR/simd-type.rs:11:1
|
LL | struct int4(isize, isize, isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

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

0 comments on commit 5303c1b

Please sign in to comment.