about summary refs log tree commit diff
path: root/tests/ui/drop/tail-expr-drop-order-negative.rs
blob: 3b20691f8eaa096bf1fa8d4c21fdc4b851573116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//@ revisions: edition2021 edition2024
//@ [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();
}