From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/try-block/try-block-bad-lifetime.stderr | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/ui/try-block/try-block-bad-lifetime.stderr (limited to 'tests/ui/try-block/try-block-bad-lifetime.stderr') diff --git a/tests/ui/try-block/try-block-bad-lifetime.stderr b/tests/ui/try-block/try-block-bad-lifetime.stderr new file mode 100644 index 000000000..ea079e30d --- /dev/null +++ b/tests/ui/try-block/try-block-bad-lifetime.stderr @@ -0,0 +1,52 @@ +error[E0597]: `my_string` does not live long enough + --> $DIR/try-block-bad-lifetime.rs:15:33 + | +LL | let result: Result<(), &str> = try { + | ------ borrow later stored here +LL | let my_string = String::from(""); +LL | let my_str: & str = & my_string; + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | }; + | - `my_string` dropped here while still borrowed + +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/try-block-bad-lifetime.rs:29:13 + | +LL | let k = &mut i; + | ------ borrow of `i` occurs here +... +LL | i = 10; + | ^^^^^^ assignment to borrowed `i` occurs here +LL | }; +LL | ::std::mem::drop(k); + | - borrow later used here + +error[E0382]: use of moved value: `k` + --> $DIR/try-block-bad-lifetime.rs:31:26 + | +LL | let k = &mut i; + | - move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait +LL | let mut j: Result<(), &mut i32> = try { +LL | Err(k) ?; + | - value moved here +... +LL | ::std::mem::drop(k); + | ^ value used here after move + +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/try-block-bad-lifetime.rs:32:9 + | +LL | let k = &mut i; + | ------ borrow of `i` occurs here +... +LL | i = 40; + | ^^^^^^ assignment to borrowed `i` occurs here +LL | +LL | let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") }; + | - borrow later used here + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0382, E0506, E0597. +For more information about an error, try `rustc --explain E0382`. -- cgit v1.2.3