]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0596.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0596.md
CommitLineData
60c5eb7d
XL
1This error occurs because you tried to mutably borrow a non-mutable variable.
2
3Erroneous code example:
4
5```compile_fail,E0596
6let x = 1;
7let y = &mut x; // error: cannot borrow mutably
8```
9
10In here, `x` isn't mutable, so when we try to mutably borrow it in `y`, it
11fails. To fix this error, you need to make `x` mutable:
12
13```
14let mut x = 1;
15let y = &mut x; // ok!
16```