You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've ran into a borrowing issue using try_borrow() in an if let statement.
The problem occurs when it's the last expression of the scope and is resolved by making it a statement.
I'm not sure if this is a bug or limitation in the borrow checker, but either way the error message is confusing.
rustc 1.16.0 (30cf806 2017-03-10)
error: container does not live long enough
--> :6:1
|
5 | if let Ok(_) = container.try_borrow() { }
| --------- borrow occurs here
6 | }
| ^ container dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error: aborting due to previous error
The text was updated successfully, but these errors were encountered:
rustc 1.16.0 (30cf806ef 2017-03-10)
error: `container` does not live long enough
--> <anon>:12:1
|
11 | if let true = container.try_borrow().is_ok() { }
| --------- borrow occurs here
12 | }
| ^ `container` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error: `container` does not live long enough
--> <anon>:20:1
|
16 | match container.try_borrow().is_ok() {
| --------- borrow occurs here
...
20 | }
| ^ `container` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error: aborting due to 2 previous errors
I've ran into a borrowing issue using try_borrow() in an if let statement.
The problem occurs when it's the last expression of the scope and is resolved by making it a statement.
I'm not sure if this is a bug or limitation in the borrow checker, but either way the error message is confusing.
rust play link
The text was updated successfully, but these errors were encountered: