Skip to content

Commit ae49770

Browse files
authored
Rollup merge of #66774 - GuillaumeGomez:cleanup-err-codes-2, r=Dylan-DPC
Clean up error codes r? @Dylan-DPC
2 parents 4c51d58 + d05a914 commit ae49770

File tree

5 files changed

+44
-33
lines changed

5 files changed

+44
-33
lines changed

src/librustc_error_codes/error_codes/E0071.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
You tried to use structure-literal syntax to create an item that is
2-
not a structure or enum variant.
1+
A structure-literal syntax was used to create an item that is not a structure
2+
or enum variant.
33

44
Example of erroneous code:
55

@@ -9,8 +9,8 @@ let t = U32 { value: 4 }; // error: expected struct, variant or union type,
99
// found builtin type `u32`
1010
```
1111

12-
To fix this, ensure that the name was correctly spelled, and that
13-
the correct form of initializer was used.
12+
To fix this, ensure that the name was correctly spelled, and that the correct
13+
form of initializer was used.
1414

1515
For example, the code above can be fixed to:
1616

src/librustc_error_codes/error_codes/E0072.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
When defining a recursive struct or enum, any use of the type being defined
2-
from inside the definition must occur behind a pointer (like `Box` or `&`).
3-
This is because structs and enums must have a well-defined size, and without
4-
the pointer, the size of the type would need to be unbounded.
1+
A recursive type has infinite size because it doesn't have an indirection.
52

6-
Consider the following erroneous definition of a type for a list of bytes:
3+
Erroneous code example:
74

85
```compile_fail,E0072
9-
// error, invalid recursive struct type
106
struct ListNode {
117
head: u8,
12-
tail: Option<ListNode>,
8+
tail: Option<ListNode>, // error: no indirection here so impossible to
9+
// compute the type's size
1310
}
1411
```
1512

16-
This type cannot have a well-defined size, because it needs to be arbitrarily
17-
large (since we would be able to nest `ListNode`s to any depth). Specifically,
13+
When defining a recursive struct or enum, any use of the type being defined
14+
from inside the definition must occur behind a pointer (like `Box`, `&` or
15+
`Rc`). This is because structs and enums must have a well-defined size, and
16+
without the pointer, the size of the type would need to be unbounded.
17+
18+
In the example, the type cannot have a well-defined size, because it needs to be
19+
arbitrarily large (since we would be able to nest `ListNode`s to any depth).
20+
Specifically,
1821

1922
```plain
2023
size of `ListNode` = 1 byte for `head`
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
The `#[simd]` attribute can only be applied to non empty tuple structs, because
2-
it doesn't make sense to try to use SIMD operations when there are no values to
3-
operate on.
1+
A `#[simd]` attribute was applied to an empty tuple struct.
42

5-
This will cause an error:
3+
Erroneous code example:
64

75
```compile_fail,E0075
86
#![feature(repr_simd)]
97
108
#[repr(simd)]
11-
struct Bad;
9+
struct Bad; // error!
1210
```
1311

14-
This will not:
12+
The `#[simd]` attribute can only be applied to non empty tuple structs, because
13+
it doesn't make sense to try to use SIMD operations when there are no values to
14+
operate on.
15+
16+
Fixed example:
1517

1618
```
1719
#![feature(repr_simd)]
1820
1921
#[repr(simd)]
20-
struct Good(u32);
22+
struct Good(u32); // ok!
2123
```
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
When using the `#[simd]` attribute to automatically use SIMD operations in tuple
2-
struct, the types in the struct must all be of the same type, or the compiler
3-
will trigger this error.
1+
All types in a tuple struct aren't the same when using the `#[simd]`
2+
attribute.
43

5-
This will cause an error:
4+
Erroneous code example:
65

76
```compile_fail,E0076
87
#![feature(repr_simd)]
98
109
#[repr(simd)]
11-
struct Bad(u16, u32, u32);
10+
struct Bad(u16, u32, u32); // error!
1211
```
1312

14-
This will not:
13+
When using the `#[simd]` attribute to automatically use SIMD operations in tuple
14+
struct, the types in the struct must all be of the same type, or the compiler
15+
will trigger this error.
16+
17+
Fixed example:
1518

1619
```
1720
#![feature(repr_simd)]
1821
1922
#[repr(simd)]
20-
struct Good(u32, u32, u32);
23+
struct Good(u32, u32, u32); // ok!
2124
```
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
When using the `#[simd]` attribute on a tuple struct, the elements in the tuple
2-
must be machine types so SIMD operations can be applied to them.
1+
A tuple struct's element isn't a machine type when using the `#[simd]`
2+
attribute.
33

4-
This will cause an error:
4+
Erroneous code example:
55

66
```compile_fail,E0077
77
#![feature(repr_simd)]
88
99
#[repr(simd)]
10-
struct Bad(String);
10+
struct Bad(String); // error!
1111
```
1212

13-
This will not:
13+
When using the `#[simd]` attribute on a tuple struct, the elements in the tuple
14+
must be machine types so SIMD operations can be applied to them.
15+
16+
Fixed example:
1417

1518
```
1619
#![feature(repr_simd)]
1720
1821
#[repr(simd)]
19-
struct Good(u32, u32, u32);
22+
struct Good(u32, u32, u32); // ok!
2023
```

0 commit comments

Comments
 (0)