1 // This is a non-regression test for const-qualification of unstable items in libcore
2 // as explained in issue #67053.
3 // const-qualification could miss some `const fn`s if they were unstable and the feature
4 // gate was not enabled in libcore.
5 
6 #![stable(feature = "core", since = "1.6.0")]
7 #![feature(rustc_const_unstable)]
8 #![feature(staged_api)]
9 #![feature(const_fn_trait_bound)]
10 
11 enum Opt<T> {
12     Some(T),
13     None,
14 }
15 
16 impl<T> Opt<T> {
17     #[rustc_const_unstable(feature = "foo", issue = "none")]
18     #[stable(feature = "rust1", since = "1.0.0")]
unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T19     const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
20     //~^ ERROR destructors cannot be evaluated at compile-time
21     //~| ERROR destructors cannot be evaluated at compile-time
22         match self {
23             Opt::Some(t) => t,
24             Opt::None => f(), //~ ERROR E0015
25         }
26     }
27 }
28 
main()29 fn main() {}
30