-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error E0597 with Refcell::borrow and "if let", but disappear after adding more statements #67222
Comments
Adding a semicolon after the |
Minimal repro: fn main() {
let s = std::cell::RefCell::new(Some(()));
if let Some(_) = s.borrow().as_ref() {} else {} // add `;` to make it compilable
} PS: I suspect - it has some tiny relation to #53528 |
Thanks, I've changed the issue title to match the minimal repro |
The code and diagnostic reported in the original issue are wrong. Fixing the code yields this diagnostic:
The |
Ok, somehow i had missed the note..... still I wander if it is a stable behavior, and if so, is it documented somewhere? |
It's documented here: https://doc.rust-lang.org/stable/reference/expressions.html#temporary-lifetimes The text doesn't account for function bodies also being blocks, however. Feel free to send a PR to the reference changing the wording there. |
@jonas-schievink |
That also makes it no longer the trailing expression in the block |
There is a minimal repro at #67222 (comment) by @andreytkachenko
Sorry for the unclear title, but I found it hard to explain the situation I'm in. The following code leads to an E0597 error
Which leads to:
However, if I add some more statement before the main function ends, even a totally irrelevant print statement, the error disappear.
The platform is as follow:
5.0.0-37-generic #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
And the rustc version:
rustc 1.41.0-nightly (7dbfb0a8c 2019-12-10)
Thanks!
The text was updated successfully, but these errors were encountered: