mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
20 lines
359 B
Rust
20 lines
359 B
Rust
// build-fail
|
|
|
|
pub const unsafe fn fake_type<T>() -> T {
|
|
hint_unreachable() //~ ERROR evaluation of `<i32 as Const>::CONSTANT` failed
|
|
}
|
|
|
|
pub const unsafe fn hint_unreachable() -> ! {
|
|
fake_type()
|
|
}
|
|
|
|
trait Const {
|
|
const CONSTANT: i32 = unsafe { fake_type() };
|
|
}
|
|
|
|
impl<T> Const for T {}
|
|
|
|
pub fn main() -> () {
|
|
dbg!(i32::CONSTANT); //~ constant
|
|
}
|