rust/tests/ui/consts/uninhabited-const-issue-61744.rs

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

20 lines
360 B
Rust
Raw Normal View History

//@ build-fail
2019-06-25 02:39:23 +00:00
pub const unsafe fn fake_type<T>() -> T {
2022-09-21 11:05:20 +00:00
hint_unreachable() //~ ERROR evaluation of `<i32 as Const>::CONSTANT` failed
2019-06-25 02:39:23 +00:00
}
pub const unsafe fn hint_unreachable() -> ! {
2020-12-02 11:49:11 +00:00
fake_type()
2019-06-25 02:39:23 +00:00
}
trait Const {
2020-12-02 11:49:11 +00:00
const CONSTANT: i32 = unsafe { fake_type() };
2019-06-25 02:39:23 +00:00
}
impl<T> Const for T {}
2019-06-25 02:39:23 +00:00
pub fn main() -> () {
dbg!(i32::CONSTANT); //~ constant
2019-06-25 02:39:23 +00:00
}