mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
27 lines
976 B
Rust
27 lines
976 B
Rust
pub const fn id<T>(x: T) -> T { x }
|
|
pub const C: () = {
|
|
let _: &'static _ = &String::new();
|
|
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
|
|
let _: &'static _ = &id(&String::new());
|
|
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
|
|
let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
|
|
//~^ ERROR: temporary value dropped while borrowed
|
|
};
|
|
|
|
fn main() {
|
|
let _: &'static _ = &String::new();
|
|
//~^ ERROR: temporary value dropped while borrowed
|
|
|
|
let _: &'static _ = &id(&String::new());
|
|
//~^ ERROR: temporary value dropped while borrowed
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
|
|
let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
|
|
//~^ ERROR: temporary value dropped while borrowed
|
|
}
|