Skip to content

Commit 412366f

Browse files
committed
Add diagnostic messages for E0074-E0077
1 parent a7b8f5b commit 412366f

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,63 @@ struct Foo { x: Option<Box<Foo>> }
826826
Now it's possible to create at least one instance of `Foo`: `Foo { x: None }`.
827827
"##,
828828

829+
E0074: r##"
830+
When using the `#[simd]` attribute on a tuple struct, the components of the
831+
tuple struct must all be of a concrete, nongeneric type so the compiler can
832+
reason about how to use SIMD with them. This error will occur if the types
833+
are generic.
834+
835+
```
836+
#[simd]
837+
struct Bad<T>(T, T, T); // This will cause an error
838+
839+
#[simd]
840+
struct Good(u32, u32, u32); // This will not
841+
```
842+
"##,
843+
844+
E0075: r##"
845+
The `#[simd]` attribute can only be applied to non empty tuple structs, because
846+
it doesn't make sense to try to use SIMD operations when there are no values to
847+
operate on.
848+
849+
```
850+
#[simd]
851+
struct Bad; // This will cause an error
852+
853+
#[simd]
854+
struct Good(u32); // This will not
855+
```
856+
"##,
857+
858+
E0076: r##"
859+
When using the `#[simd]` attribute to automatically use SIMD operations in tuple
860+
struct, the types in the struct must all be of the same type, or the compiler
861+
will trigger this error.
862+
863+
```
864+
#[simd]
865+
struct Bad(u16, u32, u32); // This will cause an error
866+
867+
#[simd]
868+
struct Good(u32, u32, u32); // This will not
869+
```
870+
871+
"##,
872+
873+
E0077: r##"
874+
When using the `#[simd]` attribute on a tuple struct, the elements in the tuple
875+
must be machine types so SIMD operations can be applied to them.
876+
877+
```
878+
#[simd]
879+
struct Bad(String); // This will cause an error
880+
881+
#[simd]
882+
struct Good(u32, u32, u32); // This will not
883+
```
884+
"##,
885+
829886
E0081: r##"
830887
Enum discriminants are used to differentiate enum variants stored in memory.
831888
This error indicates that the same value was used for two or more variants,
@@ -2299,10 +2356,6 @@ https://doc.rust-lang.org/std/marker/struct.PhantomData.html
22992356

23002357
register_diagnostics! {
23012358
E0068,
2302-
E0074,
2303-
E0075,
2304-
E0076,
2305-
E0077,
23062359
E0085,
23072360
E0086,
23082361
E0090,

0 commit comments

Comments
 (0)