]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / dont_promote_unstable_const_fn.rs
1 #![unstable(feature = "humans",
2 reason = "who ever let humans program computers,
3 we're apparently really bad at it",
4 issue = "none")]
5
6 #![feature(staged_api)]
7
8 #[stable(feature = "rust1", since = "1.0.0")]
9 #[rustc_const_unstable(feature="foo", issue = "none")]
10 const fn foo() -> u32 { 42 }
11
12 fn meh() -> u32 { 42 }
13
14 const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn
15
16 fn a() {
17 let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed
18 }
19
20 fn main() {
21 let _: &'static u32 = &meh(); //~ ERROR temporary value dropped while borrowed
22 let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
23 //~^ ERROR temporary value dropped while borrowed
24 }