fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

1.39.0
1.1 KiB33 linesraw
1warning: captured variable cannot escape `FnMut` closure body
2  --> $DIR/issue-49824.rs:10:9
3   |
4LL |       || {
5   |        - inferred to be a `FnMut` closure
6LL | /         || {
7LL | |
8LL | |
9LL | |
10LL | |             let _y = &mut x;
11LL | |         }
12   | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
13   |
14   = note: `FnMut` closures only have access to their captured variables while they are executing...
15   = note: ...therefore, they cannot allow references to captured variables to escape
16   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
17   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
18   = note: for more information, try `rustc --explain E0729`
19
20error: compilation successful
21  --> $DIR/issue-49824.rs:6:1
22   |
23LL | / fn main() {
24LL | |
25LL | |     let mut x = 0;
26LL | |     || {
27...  |
28LL | |     };
29LL | | }
30   | |_^
31
32error: aborting due to previous error
33