summary refs log tree commit diff
path: root/tests/ui/drop/tail-expr-drop-order-negative.rs
blob: c570b3a1ee23510f38008b659defcdc56d1d3fd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//@ revisions: edition2021 edition2024
//@ [edition2024] compile-flags: -Zunstable-options
//@ [edition2024] edition: 2024
//@ [edition2021] check-pass

#![feature(shorter_tail_lifetimes)]

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();
}