mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-12 16:45:37 +00:00
18 lines
500 B
Rust
18 lines
500 B
Rust
//@ 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();
|
|
}
|