]> git.lizzy.rs Git - rust.git/blob - tests/ui/span/issue-23338-locals-die-before-temps-of-body.stderr
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / tests / ui / span / issue-23338-locals-die-before-temps-of-body.stderr
1 error[E0597]: `y` does not live long enough
2   --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5
3    |
4 LL |     y.borrow().clone()
5    |     ^^^^^^^^^^
6    |     |
7    |     borrowed value does not live long enough
8    |     a temporary with access to the borrow is created here ...
9 LL | }
10    | -
11    | |
12    | `y` dropped here while still borrowed
13    | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Ref<'_, String>`
14    |
15    = note: the temporary is part of an expression at the end of a block;
16            consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
17 help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
18    |
19 LL |     let x = y.borrow().clone(); x
20    |     +++++++                   +++
21
22 error[E0597]: `y` does not live long enough
23   --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9
24    |
25 LL |         y.borrow().clone()
26    |         ^^^^^^^^^^
27    |         |
28    |         borrowed value does not live long enough
29    |         a temporary with access to the borrow is created here ...
30 LL |     };
31    |     -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Ref<'_, String>`
32    |     |
33    |     `y` dropped here while still borrowed
34    |
35    = note: the temporary is part of an expression at the end of a block;
36            consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
37 help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
38    |
39 LL |         let x = y.borrow().clone(); x
40    |         +++++++                   +++
41
42 error: aborting due to 2 previous errors
43
44 For more information about this error, try `rustc --explain E0597`.