summaryrefslogtreecommitdiff
path: root/tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr')
-rw-r--r--tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr b/tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr
new file mode 100644
index 00000000000..858be42d540
--- /dev/null
+++ b/tests/ui/lifetimes/refcell-in-tail-expr.edition2021.stderr
@@ -0,0 +1,26 @@
+error[E0597]: `cell` does not live long enough
+ --> $DIR/refcell-in-tail-expr.rs:12: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`.