File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
src/rust-2018/the-compiler Expand file tree Collapse file tree 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.
88
99For example, here's some code that produces an error:
1010
11- ``` rust,ignore
11+ ``` rust,compile_fail
1212fn main() {
1313 let mut x = 5;
14-
1514 let y = &x;
16-
1715 x += 1;
16+ println!("{} {}", x, y);
1817}
1918```
2019
2120Here's the error in Rust 1.11:
2221
2322``` 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;
2625 ^~~~~~
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;
2928 ^
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
3131```
3232
3333Here's the error in Rust 1.28:
3434
3535``` text
3636error[E0506]: cannot assign to `x` because it is borrowed
37- --> foo.rs:6 :5
37+ --> foo.rs:4 :5
3838 |
39- 4 | let y = &x;
39+ 3 | let y = &x;
4040 | - borrow of `x` occurs here
41- 5 |
42- 6 | x += 1;
41+ 4 | x += 1;
4342 | ^^^^^^ assignment to borrowed `x` occurs here
4443
4544error: aborting due to previous error
45+
46+ For more information about this error, try `rustc --explain E0506`.
4647```
4748
4849This 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