diff --git a/src/librustc_error_codes/error_codes/E0071.md b/src/librustc_error_codes/error_codes/E0071.md index 768dd0c7a48c2..bc2c03a022082 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 e461d45f30c85..8f7749abab1e5 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, + tail: Option, // 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 f15af8150baaa..969c1ee71313e 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 466e0a96e6b01..f293a2a5772db 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 6ae35a6aa17fe..b14513c6ccf1f 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! ```