2023-08-13 04:02:31 -05:00
|
|
|
// known-bug: #110395
|
|
|
|
// FIXME check-pass
|
2019-12-05 08:02:41 -06: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 08:31:04 -05:00
|
|
|
#![feature(staged_api, const_trait_impl)]
|
2019-12-05 08:02:41 -06:00
|
|
|
|
|
|
|
enum Opt<T> {
|
|
|
|
Some(T),
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Opt<T> {
|
2019-12-21 05:16:18 -06:00
|
|
|
#[rustc_const_unstable(feature = "foo", issue = "none")]
|
2019-12-05 08:02:41 -06:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2022-09-17 08:31:04 -05:00
|
|
|
const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
2023-08-13 04:02:31 -05:00
|
|
|
//FIXME ~^ ERROR destructor of
|
|
|
|
//FIXME ~| ERROR destructor of
|
2019-12-05 08:02:41 -06:00
|
|
|
match self {
|
|
|
|
Opt::Some(t) => t,
|
2022-09-17 08:31:04 -05:00
|
|
|
Opt::None => f(),
|
2023-08-13 04:02:31 -05:00
|
|
|
//FIXME ~^ ERROR cannot call
|
2019-12-05 08:02:41 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|