rust/tests/ui/drop/tail-expr-drop-order-negative.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
463 B
Rust
Raw Normal View History

//@ revisions: edition2021 edition2024
//@ [edition2024] compile-flags: -Zunstable-options
//@ [edition2024] edition: 2024
//@ [edition2021] check-pass
fn why_would_you_do_this() -> bool {
let mut x = None;
// Make a temporary `RefCell` and put a `Ref` that borrows it in `x`.
x.replace(std::cell::RefCell::new(123).borrow()).is_some()
//[edition2024]~^ ERROR: temporary value dropped while borrowed
}
fn main() {
why_would_you_do_this();
}