2022-11-30 06:29:01 -06:00
|
|
|
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
|
2022-11-30 08:35:23 -06:00
|
|
|
//~| ERROR: temporary value dropped while borrowed
|
|
|
|
//~| ERROR: temporary value dropped while borrowed
|
2022-11-30 06:29:01 -06:00
|
|
|
|
|
|
|
let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
|
2022-11-30 08:35:23 -06:00
|
|
|
//~^ ERROR: temporary value dropped while borrowed
|
2022-11-30 06:29:01 -06:00
|
|
|
};
|
|
|
|
|
2022-12-01 07:22:29 -06:00
|
|
|
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
|
|
|
|
}
|