rust/tests/ui/traits/const-traits/hir-const-check.rs

22 lines
568 B
Rust
Raw Normal View History

2024-10-21 19:37:48 +00:00
//@ compile-flags: -Znext-solver
2020-03-02 18:53:58 +00:00
// Regression test for #69615.
2024-06-21 12:22:29 +00:00
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
2020-03-02 18:53:58 +00:00
2022-08-28 06:27:31 +00:00
#[const_trait]
2020-03-02 18:53:58 +00:00
pub trait MyTrait {
2020-06-26 00:43:48 +00:00
fn method(&self) -> Option<()>;
2020-03-02 18:53:58 +00:00
}
impl const MyTrait for () {
2020-06-26 00:43:48 +00:00
fn method(&self) -> Option<()> {
Some(())?; //~ ERROR `?` is not allowed in a `const fn`
//~^ ERROR `?` cannot determine the branch of `Option<()>` in constant functions
//~| ERROR `?` cannot convert from residual of `Option<()>` in constant functions
2020-06-26 00:43:48 +00:00
None
2020-03-02 18:53:58 +00:00
}
}
fn main() {}