fork/rust

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

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

1.43.0
2.0 KiB39 linesraw
1error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
2  --> $DIR/region-borrow-params-issue-29793-big.rs:67:26
3   |
4LL |         WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
5   |                          ^^^^^^^^^        - `x` is borrowed here
6   |                          |
7   |                          may outlive borrowed value `x`
8   |
9note: closure is returned here
10  --> $DIR/region-borrow-params-issue-29793-big.rs:67:9
11   |
12LL |         WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
13   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword
15   |
16LL |         WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
17   |                          ^^^^^^^^^^^^^^
18
19error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function
20  --> $DIR/region-borrow-params-issue-29793-big.rs:67:26
21   |
22LL |         WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
23   |                          ^^^^^^^^^                   - `y` is borrowed here
24   |                          |
25   |                          may outlive borrowed value `y`
26   |
27note: closure is returned here
28  --> $DIR/region-borrow-params-issue-29793-big.rs:67:9
29   |
30LL |         WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
31   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword
33   |
34LL |         WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
35   |                          ^^^^^^^^^^^^^^
36
37error: aborting due to 2 previous errors
38
39For more information about this error, try `rustc --explain E0373`.