-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Odd and unexpected compiler error #95381
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
Comments
Playground repro: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=ef9fc1e647fb3d4c24bc023338d24f44 Real error, rather than the IDE-neutered one:
Note that this compiles if one adds the |
Thanks, @scottmcm. But I don't understand what's going on. Why is this error happening in the first place? The As an aside, where is the borrow of "leaf" even occurring in that code. |
This code also doesn't compile for the same reasons.
No local variables defined in the block. |
Minimized version use std::cell::RefCell;
fn main() {
let leaf = RefCell::new(());
if let a = leaf.borrow() {}
} |
This is fixed in the 2024 edition by shortening the temporary's scope to be dropped sooner: edition guide |
This code won't compile
I tried this code:
I expected to see this happen: code compiled
Instead, this happened: compiler error
The text was updated successfully, but these errors were encountered: