mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
14 lines
497 B
Rust
14 lines
497 B
Rust
#![feature(const_precise_live_drops)]
|
|
pub const fn id<T>(x: T) -> T { x }
|
|
pub const C: () = {
|
|
let _: &'static _ = &id(&String::new());
|
|
//~^ ERROR: temporary value dropped while borrowed
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
//~| ERROR: destructor of `String` cannot be evaluated at compile-time
|
|
};
|
|
|
|
fn main() {
|
|
let _: &'static _ = &id(&String::new());
|
|
//~^ ERROR: temporary value dropped while borrowed
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
}
|