rust/tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
1014 B
Plaintext
Raw Permalink Normal View History

error[E0597]: `cell` does not live long enough
2024-10-20 15:47:02 -05:00
--> $DIR/refcell-in-tail-expr.rs:10:27
|
LL | let cell = std::cell::RefCell::new(0u8);
| ---- binding `cell` declared here
LL |
LL | if let Ok(mut byte) = cell.try_borrow_mut() {
| ^^^^-----------------
| |
| borrowed value does not live long enough
| a temporary with access to the borrow is created here ...
...
LL | }
| -
| |
| `cell` dropped here while still borrowed
| ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Result<RefMut<'_, u8>, BorrowMutError>`
|
help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
|
LL | };
| +
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0597`.