Skip to content

Commit 0b3d4a1

Browse files
authored
Rollup merge of rust-lang#66737 - GuillaumeGomez:err-codes-cleanup, r=Dylan-DPC
Error codes cleanup r? @Dylan-DPC
2 parents bf25f8e + 1bd28b1 commit 0b3d4a1

File tree

5 files changed

+39
-50
lines changed

5 files changed

+39
-50
lines changed

Diff for: src/librustc_error_codes/error_codes/E0062.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This error indicates that during an attempt to build a struct or struct-like
2-
enum variant, one of the fields was specified more than once. Erroneous code
3-
example:
1+
A struct's or struct-like enum variant's field was specified more than once.
2+
3+
Erroneous code example:
44

55
```compile_fail,E0062
66
struct Foo {
@@ -15,7 +15,9 @@ fn main() {
1515
}
1616
```
1717

18-
Each field should be specified exactly one time. Example:
18+
This error indicates that during an attempt to build a struct or struct-like
19+
enum variant, one of the fields was specified more than once. Each field should
20+
be specified exactly one time. Example:
1921

2022
```
2123
struct Foo {

Diff for: src/librustc_error_codes/error_codes/E0063.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
This error indicates that during an attempt to build a struct or struct-like
2-
enum variant, one of the fields was not provided. Erroneous code example:
1+
A struct's or struct-like enum variant's field was not provided.
2+
3+
Erroneous code example:
34

45
```compile_fail,E0063
56
struct Foo {

Diff for: src/librustc_error_codes/error_codes/E0067.md

+7-25
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
The left-hand side of a compound assignment expression must be a place
2-
expression. A place expression represents a memory location and includes
3-
item paths (ie, namespaced variables), dereferences, indexing expressions,
4-
and field references.
1+
An invalid left-hand side expression was used on an assignment operation.
52

6-
Let's start with some erroneous code examples:
3+
Erroneous code example:
74

85
```compile_fail,E0067
9-
use std::collections::LinkedList;
10-
11-
// Bad: assignment to non-place expression
12-
LinkedList::new() += 1;
13-
14-
// ...
15-
16-
fn some_func(i: &mut i32) {
17-
i += 12; // Error : '+=' operation cannot be applied on a reference !
18-
}
6+
12 += 1; // error!
197
```
208

21-
And now some working examples:
9+
You need to have a place expression to be able to assign it something. For
10+
example:
2211

2312
```
24-
let mut i : i32 = 0;
25-
26-
i += 12; // Good !
27-
28-
// ...
29-
30-
fn some_func(i: &mut i32) {
31-
*i += 12; // Good !
32-
}
13+
let mut x: i8 = 12;
14+
x += 1; // ok!
3315
```

Diff for: src/librustc_error_codes/error_codes/E0069.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
The compiler found a function whose body contains a `return;` statement but
2-
whose return type is not `()`. An example of this is:
2+
whose return type is not `()`.
3+
4+
Erroneous code example:
35

46
```compile_fail,E0069
57
// error

Diff for: src/librustc_error_codes/error_codes/E0070.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
The left-hand side of an assignment operator must be a place expression. A
2-
place expression represents a memory location and can be a variable (with
3-
optional namespacing), a dereference, an indexing expression or a field
4-
reference.
1+
An assignment operator was used on a non-place expression.
52

6-
More details can be found in the [Expressions] section of the Reference.
7-
8-
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#places-rvalues-and-temporaries
9-
10-
Now, we can go further. Here are some erroneous code examples:
3+
Erroneous code examples:
114

125
```compile_fail,E0070
136
struct SomeStruct {
147
x: i32,
15-
y: i32
8+
y: i32,
169
}
1710
18-
const SOME_CONST : i32 = 12;
11+
const SOME_CONST: i32 = 12;
1912
2013
fn some_other_func() {}
2114
2215
fn some_function() {
23-
SOME_CONST = 14; // error : a constant value cannot be changed!
24-
1 = 3; // error : 1 isn't a valid place!
25-
some_other_func() = 4; // error : we cannot assign value to a function!
26-
SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
27-
// like a variable!
16+
SOME_CONST = 14; // error: a constant value cannot be changed!
17+
1 = 3; // error: 1 isn't a valid place!
18+
some_other_func() = 4; // error: we cannot assign value to a function!
19+
SomeStruct::x = 12; // error: SomeStruct a structure name but it is used
20+
// like a variable!
2821
}
2922
```
3023

24+
The left-hand side of an assignment operator must be a place expression. A
25+
place expression represents a memory location and can be a variable (with
26+
optional namespacing), a dereference, an indexing expression or a field
27+
reference.
28+
29+
More details can be found in the [Expressions] section of the Reference.
30+
31+
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#places-rvalues-and-temporaries
32+
3133
And now let's give working examples:
3234

3335
```
3436
struct SomeStruct {
3537
x: i32,
36-
y: i32
38+
y: i32,
3739
}
38-
let mut s = SomeStruct {x: 0, y: 0};
40+
let mut s = SomeStruct { x: 0, y: 0 };
3941
4042
s.x = 3; // that's good !
4143

0 commit comments

Comments
 (0)