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