about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-07 22:25:14 +0000
committerbors <bors@rust-lang.org>2021-02-07 22:25:14 +0000
commitbb587b1a1737738658d2eaecd4c8c1cab555257a (patch)
treedd6c0c0f7509d6c9d75e817485adb61ecf720c59 /compiler/rustc_error_codes/src
parent9778068cbc1e06cc3685422323ff38a2f397de26 (diff)
parenta4bab7c6fab5a44f989321c1abf4cfc72ebb1d28 (diff)
downloadrust-bb587b1a1737738658d2eaecd4c8c1cab555257a.tar.gz
rust-bb587b1a1737738658d2eaecd4c8c1cab555257a.zip
Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa
Improve SIMD type element count validation

Resolves rust-lang/stdsimd#53.

These changes are motivated by `stdsimd` moving in the direction of const generic vectors, e.g.:
```rust
#[repr(simd)]
struct SimdF32<const N: usize>([f32; N]);
```

This makes a few changes:
* Establishes a maximum SIMD lane count of 2^16 (65536).  This value is arbitrary, but attempts to validate lane count before hitting potential errors in the backend.  It's not clear what LLVM's maximum lane count is, but cranelift's appears to be much less than `usize::MAX`, at least.
* Expands some SIMD intrinsics to support arbitrary lane counts.  This resolves the ICE in the linked issue.
* Attempts to catch invalid-sized vectors during typeck when possible.

Unresolved questions:
* Generic-length vectors can't be validated in typeck and are only validated after monomorphization while computing layout.  This "works", but the errors simply bail out with no context beyond the name of the type.  Should these errors instead return `LayoutError` or otherwise provide context in some way?  As it stands, users of `stdsimd` could trivially produce monomorphization errors by making zero-length vectors.

cc `@bjorn3`
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/E0076.md4
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0077.md2
3 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0074.md b/compiler/rustc_error_codes/src/error_codes/E0074.md
index e25dec7681b..785d6de226d 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);
+struct Bad<T>(T, T, T, T);
 ```
 
 This will not:
@@ -20,5 +20,5 @@ This will not:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32, u32, u32);
+struct Good(u32, u32, u32, u32);
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0076.md b/compiler/rustc_error_codes/src/error_codes/E0076.md
index f293a2a5772..1da8caa9506 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0076.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0076.md
@@ -7,7 +7,7 @@ Erroneous code example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Bad(u16, u32, u32); // error!
+struct Bad(u16, u32, u32 u32); // error!
 ```
 
 When using the `#[simd]` attribute to automatically use SIMD operations in tuple
@@ -20,5 +20,5 @@ Fixed example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32, u32, u32); // ok!
+struct Good(u32, u32, u32, u32); // ok!
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0077.md b/compiler/rustc_error_codes/src/error_codes/E0077.md
index b14513c6ccf..91aa24d1f52 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0077.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0077.md
@@ -19,5 +19,5 @@ Fixed example:
 #![feature(repr_simd)]
 
 #[repr(simd)]
-struct Good(u32, u32, u32); // ok!
+struct Good(u32, u32, u32, u32); // ok!
 ```