fork/rust

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

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
1.7 KiB34 linesraw
1error[E0597]: `y` does not live long enough
2  --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5
3   |
4LL |     y.borrow().clone()
5   |     ^---------
6   |     |
7   |     borrowed value does not live long enough
8   |     a temporary with access to the borrow is created here ...
9LL | }
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 `std::cell::Ref<'_, std::string::String>`
14   |
15   = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. 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.
16
17error[E0597]: `y` does not live long enough
18  --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9
19   |
20LL |         y.borrow().clone()
21   |         ^---------
22   |         |
23   |         borrowed value does not live long enough
24   |         a temporary with access to the borrow is created here ...
25LL |     };
26   |     -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>`
27   |     |
28   |     `y` dropped here while still borrowed
29   |
30   = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. 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.
31
32error: aborting due to 2 previous errors
33
34For more information about this error, try `rustc --explain E0597`.