]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/promoted_const_call3.rs
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
[rust.git] / tests / ui / consts / promoted_const_call3.rs
1 pub const fn id<T>(x: T) -> T { x }
2 pub const C: () = {
3     let _: &'static _ = &String::new();
4     //~^ ERROR: destructor of `String` cannot be evaluated at compile-time
5     //~| ERROR: temporary value dropped while borrowed
6
7     let _: &'static _ = &id(&String::new());
8     //~^ ERROR: destructor of `String` cannot be evaluated at compile-time
9     //~| ERROR: temporary value dropped while borrowed
10     //~| ERROR: temporary value dropped while borrowed
11
12     let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
13     //~^ ERROR: temporary value dropped while borrowed
14 };
15
16 fn main() {
17     let _: &'static _ = &String::new();
18     //~^ ERROR: temporary value dropped while borrowed
19
20     let _: &'static _ = &id(&String::new());
21     //~^ ERROR: temporary value dropped while borrowed
22     //~| ERROR: temporary value dropped while borrowed
23
24     let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
25     //~^ ERROR: temporary value dropped while borrowed
26 }