diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-11-27 15:28:48 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-27 15:28:48 -0600 |
| commit | ae49770918af86a3eac0471461190ce40545ac30 (patch) | |
| tree | 1cfce8a314e0740cf66dedf8f1a8c36df2c177be /src/librustc_error_codes/error_codes | |
| parent | 4c51d58de0330fad032dbc3924eb46ca6b4c5131 (diff) | |
| parent | d05a914b24c7506f4fa3c11af5c26bf809c901b7 (diff) | |
| download | rust-ae49770918af86a3eac0471461190ce40545ac30.tar.gz rust-ae49770918af86a3eac0471461190ce40545ac30.zip | |
Rollup merge of #66774 - GuillaumeGomez:cleanup-err-codes-2, r=Dylan-DPC
Clean up error codes r? @Dylan-DPC
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0071.md | 8 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0072.md | 21 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0075.md | 16 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0076.md | 17 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0077.md | 15 |
5 files changed, 44 insertions, 33 deletions
diff --git a/src/librustc_error_codes/error_codes/E0071.md b/src/librustc_error_codes/error_codes/E0071.md index 768dd0c7a48..bc2c03a0220 100644 --- a/src/librustc_error_codes/error_codes/E0071.md +++ b/src/librustc_error_codes/error_codes/E0071.md @@ -1,5 +1,5 @@ -You tried to use structure-literal syntax to create an item that is -not a structure or enum variant. +A structure-literal syntax was used to create an item that is not a structure +or enum variant. Example of erroneous code: @@ -9,8 +9,8 @@ let t = U32 { value: 4 }; // error: expected struct, variant or union type, // found builtin type `u32` ``` -To fix this, ensure that the name was correctly spelled, and that -the correct form of initializer was used. +To fix this, ensure that the name was correctly spelled, and that the correct +form of initializer was used. For example, the code above can be fixed to: diff --git a/src/librustc_error_codes/error_codes/E0072.md b/src/librustc_error_codes/error_codes/E0072.md index e461d45f30c..8f7749abab1 100644 --- a/src/librustc_error_codes/error_codes/E0072.md +++ b/src/librustc_error_codes/error_codes/E0072.md @@ -1,20 +1,23 @@ -When defining a recursive struct or enum, any use of the type being defined -from inside the definition must occur behind a pointer (like `Box` or `&`). -This is because structs and enums must have a well-defined size, and without -the pointer, the size of the type would need to be unbounded. +A recursive type has infinite size because it doesn't have an indirection. -Consider the following erroneous definition of a type for a list of bytes: +Erroneous code example: ```compile_fail,E0072 -// error, invalid recursive struct type struct ListNode { head: u8, - tail: Option<ListNode>, + tail: Option<ListNode>, // error: no indirection here so impossible to + // compute the type's size } ``` -This type cannot have a well-defined size, because it needs to be arbitrarily -large (since we would be able to nest `ListNode`s to any depth). Specifically, +When defining a recursive struct or enum, any use of the type being defined +from inside the definition must occur behind a pointer (like `Box`, `&` or +`Rc`). This is because structs and enums must have a well-defined size, and +without the pointer, the size of the type would need to be unbounded. + +In the example, the type cannot have a well-defined size, because it needs to be +arbitrarily large (since we would be able to nest `ListNode`s to any depth). +Specifically, ```plain size of `ListNode` = 1 byte for `head` diff --git a/src/librustc_error_codes/error_codes/E0075.md b/src/librustc_error_codes/error_codes/E0075.md index f15af8150ba..969c1ee7131 100644 --- a/src/librustc_error_codes/error_codes/E0075.md +++ b/src/librustc_error_codes/error_codes/E0075.md @@ -1,21 +1,23 @@ -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. +A `#[simd]` attribute was applied to an empty tuple struct. -This will cause an error: +Erroneous code example: ```compile_fail,E0075 #![feature(repr_simd)] #[repr(simd)] -struct Bad; +struct Bad; // error! ``` -This will not: +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. + +Fixed example: ``` #![feature(repr_simd)] #[repr(simd)] -struct Good(u32); +struct Good(u32); // ok! ``` diff --git a/src/librustc_error_codes/error_codes/E0076.md b/src/librustc_error_codes/error_codes/E0076.md index 466e0a96e6b..f293a2a5772 100644 --- a/src/librustc_error_codes/error_codes/E0076.md +++ b/src/librustc_error_codes/error_codes/E0076.md @@ -1,21 +1,24 @@ -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. +All types in a tuple struct aren't the same when using the `#[simd]` +attribute. -This will cause an error: +Erroneous code example: ```compile_fail,E0076 #![feature(repr_simd)] #[repr(simd)] -struct Bad(u16, u32, u32); +struct Bad(u16, u32, u32); // error! ``` -This will not: +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. + +Fixed example: ``` #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32); +struct Good(u32, u32, u32); // ok! ``` diff --git a/src/librustc_error_codes/error_codes/E0077.md b/src/librustc_error_codes/error_codes/E0077.md index 6ae35a6aa17..b14513c6ccf 100644 --- a/src/librustc_error_codes/error_codes/E0077.md +++ b/src/librustc_error_codes/error_codes/E0077.md @@ -1,20 +1,23 @@ -When using the `#[simd]` attribute on a tuple struct, the elements in the tuple -must be machine types so SIMD operations can be applied to them. +A tuple struct's element isn't a machine type when using the `#[simd]` +attribute. -This will cause an error: +Erroneous code example: ```compile_fail,E0077 #![feature(repr_simd)] #[repr(simd)] -struct Bad(String); +struct Bad(String); // error! ``` -This will not: +When using the `#[simd]` attribute on a tuple struct, the elements in the tuple +must be machine types so SIMD operations can be applied to them. + +Fixed example: ``` #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32); +struct Good(u32, u32, u32); // ok! ``` |
