]>
git.proxmox.com Git - rustc.git/blob - tests/ui/consts/promoted_const_call5.rs
1 #![feature(rustc_attrs)]
2 #![feature(staged_api)]
3 #![stable(feature = "a", since = "1.0.0")]
6 #[stable(feature = "a", since = "1.0.0")]
7 #[rustc_const_stable(feature = "a", since = "1.0.0")]
8 pub const fn id
<T
>(x
: &'
static T
) -> &'
static T { x }
11 #[stable(feature = "a", since = "1.0.0")]
12 #[rustc_const_stable(feature = "a", since = "1.0.0")]
13 pub const fn new_string() -> String
{
18 #[stable(feature = "a", since = "1.0.0")]
19 #[rustc_const_stable(feature = "a", since = "1.0.0")]
20 pub const fn new_manually_drop
<T
>(t
: T
) -> std
::mem
::ManuallyDrop
<T
> {
21 std
::mem
::ManuallyDrop
::new(t
)
26 let _
: &'
static _
= &id(&new_string());
27 //~^ ERROR destructor of `String` cannot be evaluated at compile-time
28 //~| ERROR: temporary value dropped while borrowed
29 //~| ERROR: temporary value dropped while borrowed
31 let _
: &'
static _
= &new_manually_drop(new_string());
32 //~^ ERROR: temporary value dropped while borrowed
36 let _
: &'
static _
= &id(&new_string());
37 //~^ ERROR: temporary value dropped while borrowed
38 //~| ERROR: temporary value dropped while borrowed
40 let _
: &'
static _
= &new_manually_drop(new_string());
41 //~^ ERROR: temporary value dropped while borrowed