2018-08-13 03:05:29 +00:00
|
|
|
error[E0597]: `my_string` does not live long enough
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/try-block-bad-lifetime.rs:15:33
|
2018-08-13 03:05:29 +00:00
|
|
|
|
|
2018-08-31 23:20:43 +00:00
|
|
|
LL | let result: Result<(), &str> = try {
|
2018-10-09 21:59:46 +00:00
|
|
|
| ------ borrow later stored here
|
2018-08-31 23:20:43 +00:00
|
|
|
LL | let my_string = String::from("");
|
2018-08-13 03:05:29 +00:00
|
|
|
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
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/try-block-bad-lifetime.rs:29:13
|
2018-08-13 03:05:29 +00:00
|
|
|
|
|
|
|
|
LL | let k = &mut i;
|
|
|
|
| ------ borrow of `i` occurs here
|
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | i = 10;
|
2018-08-13 03:05:29 +00:00
|
|
|
| ^^^^^^ assignment to borrowed `i` occurs here
|
|
|
|
LL | };
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | ::std::mem::drop(k);
|
2018-08-13 03:05:29 +00:00
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0382]: use of moved value: `k`
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/try-block-bad-lifetime.rs:31:26
|
2018-08-13 03:05:29 +00:00
|
|
|
|
|
2019-01-03 00:43:08 +00:00
|
|
|
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 {
|
2018-08-13 03:05:29 +00:00
|
|
|
LL | Err(k) ?;
|
|
|
|
| - value moved here
|
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | ::std::mem::drop(k);
|
2018-08-13 03:05:29 +00:00
|
|
|
| ^ value used here after move
|
|
|
|
|
|
|
|
error[E0506]: cannot assign to `i` because it is borrowed
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/try-block-bad-lifetime.rs:32:9
|
2018-08-13 03:05:29 +00:00
|
|
|
|
|
|
|
|
LL | let k = &mut i;
|
|
|
|
| ------ borrow of `i` occurs here
|
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | i = 40;
|
2018-08-13 03:05:29 +00:00
|
|
|
| ^^^^^^ assignment to borrowed `i` occurs here
|
2022-06-08 18:07:59 +00:00
|
|
|
LL |
|
2018-08-13 03:05:29 +00:00
|
|
|
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
|
|
|
|
|
2019-04-17 17:26:38 +00:00
|
|
|
Some errors have detailed explanations: E0382, E0506, E0597.
|
2018-08-13 03:05:29 +00:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|