]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/issue-45983.nll.stderr
Give an error number for "borrowed data escapes outside of closure"
[rust.git] / src / test / ui / borrowck / issue-45983.nll.stderr
1 error[E0521]: borrowed data escapes outside of closure
2   --> $DIR/issue-45983.rs:36:18
3    |
4 LL |     let x = None;
5    |         - `x` is declared here, outside of the closure body
6 LL |     give_any(|y| x = Some(y));
7    |               -  ^^^^^^^^^^^ `y` escapes the closure body here
8    |               |
9    |               `y` is a reference that is only valid in the closure body
10
11 error[E0594]: cannot assign to `x`, as it is not declared as mutable
12   --> $DIR/issue-45983.rs:36:18
13    |
14 LL |     let x = None;
15    |         - help: consider changing this to be mutable: `mut x`
16 LL |     give_any(|y| x = Some(y));
17    |                  ^^^^^^^^^^^ cannot assign
18
19 error: aborting due to 2 previous errors
20
21 Some errors occurred: E0521, E0594.
22 For more information about an error, try `rustc --explain E0521`.