-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scalable SIMD tests for disallowing scalable types in types.
Tests to ensure that scalable SIMD types can't exist in struct, union, enum variants and compound types. This also changes the well formed checking of types to improve the error message when scalable SIMD types are included. The previous implementation would also allow a scalable SIMD type as the last element within a struct in some cases which we currently don't want to allow.
- Loading branch information
1 parent
cf3864a
commit 6321f69
Showing
11 changed files
with
155 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
A scalable SIMD type was used in a context where they cannot exist. Scalable | ||
SIMD types exist in a place that is somewhere between `Sized` and `Unsized` | ||
therefore have restrictions on the uses. A scalable SIMD type can't exist in any | ||
of the following: | ||
|
||
* Struct | ||
* Enum variant | ||
* Union | ||
* Compound type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -535,6 +535,7 @@ E0795: 0795, | |
E0796: 0796, | ||
E0797: 0797, | ||
E0798: 0798, | ||
E0799: 0799, | ||
); | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![feature(repr_simd, repr_scalable)] | ||
|
||
#[repr(simd, scalable(4))] | ||
pub struct ScalableSimdFloat { | ||
_ty: [f32] | ||
} | ||
|
||
fn main() { | ||
let x: [ScalableSimdFloat; 2]; //~ ERROR E0277 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0277]: the size for values of type `[f32]` cannot be known at compilation time | ||
--> $DIR/disallow-array.rs:9:12 | ||
| | ||
LL | let x: [ScalableSimdFloat; 2]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: within `ScalableSimdFloat`, the trait `Sized` is not implemented for `[f32]`, which is required by `ScalableSimdFloat: Sized` | ||
note: required because it appears within the type `ScalableSimdFloat` | ||
--> $DIR/disallow-array.rs:4:12 | ||
| | ||
LL | pub struct ScalableSimdFloat { | ||
| ^^^^^^^^^^^^^^^^^ | ||
= note: slice and array elements must have `Sized` type | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![feature(repr_simd, repr_scalable)] | ||
|
||
#[repr(simd, scalable(4))] | ||
pub struct ScalableSimdFloat { | ||
_ty: [f32] | ||
} | ||
|
||
pub enum Invalid { | ||
Scalable(ScalableSimdFloat), //~ ERROR E0799 | ||
Int(i32), | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0799]: Scalable simd types cannot exist within enum variants | ||
--> $DIR/disallow-enum.rs:9:14 | ||
| | ||
LL | Scalable(ScalableSimdFloat), | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0799`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(repr_simd, repr_scalable)] | ||
|
||
#[repr(simd, scalable(4))] | ||
pub struct ScalableSimdFloat { | ||
_ty: [f32] | ||
} | ||
|
||
pub struct Invalid { | ||
x: ScalableSimdFloat, //~ ERROR E0799 | ||
last: i32, | ||
} | ||
|
||
#[repr(transparent)] | ||
struct Wrap(ScalableSimdFloat); //~ ERROR E0799 | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0799]: Scalable simd types cannot exist within a struct | ||
--> $DIR/disallow-struct.rs:9:8 | ||
| | ||
LL | x: ScalableSimdFloat, | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0799]: Scalable simd types cannot exist within a struct | ||
--> $DIR/disallow-struct.rs:14:13 | ||
| | ||
LL | struct Wrap(ScalableSimdFloat); | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0799`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![feature(repr_simd, repr_scalable)] | ||
|
||
#[repr(simd, scalable(4))] | ||
pub struct ScalableSimdFloat { | ||
_ty: [f32] | ||
} | ||
|
||
pub union Invalid { | ||
x: ScalableSimdFloat, //~ ERROR E0799 | ||
other: i32, | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0799]: Scalable simd types cannot exist within a union | ||
--> $DIR/disallow-union.rs:9:8 | ||
| | ||
LL | x: ScalableSimdFloat, | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0799`. |