File tree 1 file changed +14
-13
lines changed
src/rust-2018/the-compiler 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -8,42 +8,43 @@ error message system was created.
8
8
9
9
For example, here's some code that produces an error:
10
10
11
- ``` rust,ignore
11
+ ``` rust,compile_fail
12
12
fn main() {
13
13
let mut x = 5;
14
-
15
14
let y = &x;
16
-
17
15
x += 1;
16
+ println!("{} {}", x, y);
18
17
}
19
18
```
20
19
21
20
Here's the error in Rust 1.11:
22
21
23
22
``` text
24
- foo.rs:6 :5: 6 :11 error: cannot assign to `x` because it is borrowed [E0506]
25
- foo.rs:6 x += 1;
23
+ foo.rs:4 :5: 4 :11 error: cannot assign to `x` because it is borrowed [E0506]
24
+ foo.rs:4 x += 1;
26
25
^~~~~~
27
- foo.rs:4 :14: 4 :15 note: borrow of `x` occurs here
28
- foo.rs:4 let y = &x;
26
+ foo.rs:3 :14: 3 :15 note: borrow of `x` occurs here
27
+ foo.rs:3 let y = &x;
29
28
^
30
- foo.rs:6:5: 6:11 help: run `rustc --explain E0506` to see a detailed explanation
29
+ foo.rs:4:5: 4:11 help: run `rustc --explain E0506` to see a detailed explanation
30
+ error: aborting due to previous error
31
31
```
32
32
33
33
Here's the error in Rust 1.28:
34
34
35
35
``` text
36
36
error[E0506]: cannot assign to `x` because it is borrowed
37
- --> foo.rs:6 :5
37
+ --> foo.rs:4 :5
38
38
|
39
- 4 | let y = &x;
39
+ 3 | let y = &x;
40
40
| - borrow of `x` occurs here
41
- 5 |
42
- 6 | x += 1;
41
+ 4 | x += 1;
43
42
| ^^^^^^ assignment to borrowed `x` occurs here
44
43
45
44
error: aborting due to previous error
45
+
46
+ For more information about this error, try `rustc --explain E0506`.
46
47
```
47
48
48
49
This error isn't terribly different, but shows off how the format has changed. It shows
49
- off your code in context, rather than just showing the text of the lines themselves.
50
+ off your code in context, rather than just showing the text of the lines themselves.
You can’t perform that action at this time.
0 commit comments