about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-08-22 01:28:20 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2024-09-09 19:39:43 -0700
commitd2309c2a9d308ddcd94c0ee8f4d2a01d1bd93560 (patch)
treee3416e0a19bc48dafb5e725654722c460ddb4a52 /compiler/rustc_error_codes/src
parent712463de61c65033a6f333f0a14fbb65e34efc50 (diff)
downloadrust-d2309c2a9d308ddcd94c0ee8f4d2a01d1bd93560.tar.gz
rust-d2309c2a9d308ddcd94c0ee8f4d2a01d1bd93560.zip
Ban non-array SIMD
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0074.md4
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0075.md18
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0076.md10
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0077.md4
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0511.md4
5 files changed, 23 insertions, 17 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0074.md b/compiler/rustc_error_codes/src/error_codes/E0074.md
index 785d6de226d..71d89f5eb60 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0074.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0074.md
@@ -11,7 +11,7 @@ This will cause an error:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Bad<T>(T, T, T, T);
+struct Bad<T>([T; 4]);
 ```
 
 This will not:
@@ -20,5 +20,5 @@ This will not:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32, u32, u32, u32);
+struct Good([u32; 4]);
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0075.md b/compiler/rustc_error_codes/src/error_codes/E0075.md
index 969c1ee7131..b58018eafc3 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0075.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0075.md
@@ -1,6 +1,6 @@
-A `#[simd]` attribute was applied to an empty tuple struct.
+A `#[simd]` attribute was applied to an empty or multi-field struct.
 
-Erroneous code example:
+Erroneous code examples:
 
 ```compile_fail,E0075
 #![feature(repr_simd)]
@@ -9,9 +9,15 @@ Erroneous code example:
 struct Bad; // error!
 ```
 
-The `#[simd]` attribute can only be applied to non empty tuple structs, because
-it doesn't make sense to try to use SIMD operations when there are no values to
-operate on.
+```compile_fail,E0075
+#![feature(repr_simd)]
+
+#[repr(simd)]
+struct Bad([u32; 1], [u32; 1]); // error!
+```
+
+The `#[simd]` attribute can only be applied to a single-field struct, because
+the one field must be the array of values in the vector.
 
 Fixed example:
 
@@ -19,5 +25,5 @@ Fixed example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32); // ok!
+struct Good([u32; 2]); // ok!
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0076.md b/compiler/rustc_error_codes/src/error_codes/E0076.md
index 1da8caa9506..b1943de63e5 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0076.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0076.md
@@ -1,4 +1,4 @@
-All types in a tuple struct aren't the same when using the `#[simd]`
+The type of the field in a tuple struct isn't an array when using the `#[simd]`
 attribute.
 
 Erroneous code example:
@@ -7,12 +7,12 @@ Erroneous code example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Bad(u16, u32, u32 u32); // error!
+struct Bad(u16); // error!
 ```
 
 When using the `#[simd]` attribute to automatically use SIMD operations in tuple
-struct, the types in the struct must all be of the same type, or the compiler
-will trigger this error.
+structs, if you want a single-lane vector then the field must be a 1-element
+array, or the compiler will trigger this error.
 
 Fixed example:
 
@@ -20,5 +20,5 @@ Fixed example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32, u32, u32, u32); // ok!
+struct Good([u16; 1]); // ok!
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0077.md b/compiler/rustc_error_codes/src/error_codes/E0077.md
index 91aa24d1f52..688bfd3e727 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0077.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0077.md
@@ -7,7 +7,7 @@ Erroneous code example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Bad(String); // error!
+struct Bad([String; 2]); // error!
 ```
 
 When using the `#[simd]` attribute on a tuple struct, the elements in the tuple
@@ -19,5 +19,5 @@ Fixed example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32, u32, u32, u32); // ok!
+struct Good([u32; 4]); // ok!
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0511.md b/compiler/rustc_error_codes/src/error_codes/E0511.md
index 681f4e611c3..45ff49bdebb 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0511.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0511.md
@@ -23,11 +23,11 @@ The generic type has to be a SIMD type. Example:
 
 #[repr(simd)]
 #[derive(Copy, Clone)]
-struct i32x2(i32, i32);
+struct i32x2([i32; 2]);
 
 extern "rust-intrinsic" {
     fn simd_add<T>(a: T, b: T) -> T;
 }
 
-unsafe { simd_add(i32x2(0, 0), i32x2(1, 2)); } // ok!
+unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
 ```