2019-12-05 14:02:41 +00:00
|
|
|
// This is a non-regression test for const-qualification of unstable items in libcore
|
|
|
|
// as explained in issue #67053.
|
|
|
|
// const-qualification could miss some `const fn`s if they were unstable and the feature
|
|
|
|
// gate was not enabled in libcore.
|
|
|
|
|
|
|
|
#![stable(feature = "core", since = "1.6.0")]
|
2022-09-17 13:31:04 +00:00
|
|
|
#![feature(staged_api, const_trait_impl)]
|
2019-12-05 14:02:41 +00:00
|
|
|
|
|
|
|
enum Opt<T> {
|
|
|
|
Some(T),
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Opt<T> {
|
2019-12-21 11:16:18 +00:00
|
|
|
#[rustc_const_unstable(feature = "foo", issue = "none")]
|
2019-12-05 14:02:41 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2022-09-17 13:31:04 +00:00
|
|
|
const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
2022-09-23 14:22:36 +00:00
|
|
|
//~^ ERROR destructor of
|
|
|
|
//~| ERROR destructor of
|
2019-12-05 14:02:41 +00:00
|
|
|
match self {
|
|
|
|
Opt::Some(t) => t,
|
2022-09-17 13:31:04 +00:00
|
|
|
Opt::None => f(),
|
2019-12-05 14:02:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|