]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs
Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkor
[rust.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(const_fn)]
7 #![feature(staged_api)]
8
9 #[stable(feature = "rust1", since = "1.0.0")]
10 #[rustc_const_unstable(feature="foo", issue = "none")]
11 const fn foo() -> u32 { 42 }
12
13 fn meh() -> u32 { 42 }
14
15 const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn
16
17 fn a() {
18     let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed
19 }
20
21 fn main() {
22     let _: &'static u32 = &meh(); //~ ERROR temporary value dropped while borrowed
23     let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
24     //~^ ERROR temporary value dropped while borrowed
25 }