rust/tests/ui/consts/unstable-const-fn-in-libcore.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
746 B
Rust
Raw Normal View History

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> {
#[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 {
//~^ ERROR destructor of
//~| 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(),
2019-12-05 08:02:41 -06:00
}
}
}
fn main() {}