-
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.
add a canary test for complex repr(simd)
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
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
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,40 @@ | ||
// Figuring out the size of a vector type that depends on traits doesn't ICE | ||
|
||
#![allow(dead_code)] | ||
|
||
// pretty-expanded FIXME #23616 | ||
|
||
#![feature(repr_simd, platform_intrinsics, const_generics)] | ||
#![allow(non_camel_case_types, incomplete_features)] | ||
|
||
pub trait Simd { | ||
type Lane: Clone + Copy; | ||
const SIZE: usize; | ||
} | ||
|
||
pub struct i32x4; | ||
impl Simd for i32x4 { | ||
type Lane = i32; | ||
const SIZE: usize = 4; | ||
} | ||
|
||
#[repr(simd)] | ||
#[derive(Copy, Clone)] | ||
pub struct T<S: Simd>([S::Lane; S::SIZE]); //~ ERROR constant expression depends on a generic parameter | ||
|
||
extern "platform-intrinsic" { | ||
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; | ||
fn simd_extract<T, E>(x: T, idx: u32) -> E; | ||
} | ||
|
||
pub fn main() { | ||
let mut t = T::<i32x4>([0; 4]); | ||
unsafe { | ||
for i in 0_i32..4 { | ||
t = simd_insert(t, i as u32, i); | ||
} | ||
for i in 0_i32..4 { | ||
assert_eq!(i, simd_extract(t, i as u32)); | ||
} | ||
} | ||
} |
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 @@ | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/simd-array-trait.rs:23:23 | ||
| | ||
LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: aborting due to previous error | ||
|