]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/unstable-const-fn-in-libcore.rs
Do not suggest `let_else` if no bindings would be introduced
[rust.git] / src / test / ui / consts / unstable-const-fn-in-libcore.rs
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(staged_api)]
8
9 enum Opt<T> {
10     Some(T),
11     None,
12 }
13
14 impl<T> Opt<T> {
15     #[rustc_const_unstable(feature = "foo", issue = "none")]
16     #[stable(feature = "rust1", since = "1.0.0")]
17     const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
18     //~^ ERROR destructors cannot be evaluated at compile-time
19     //~| ERROR destructors cannot be evaluated at compile-time
20         match self {
21             Opt::Some(t) => t,
22             Opt::None => f(), //~ ERROR E0015
23         }
24     }
25 }
26
27 fn main() {}