diff options
Diffstat (limited to 'src/test/ui/consts/uninhabited-const-issue-61744.rs')
-rw-r--r-- | src/test/ui/consts/uninhabited-const-issue-61744.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.rs b/src/test/ui/consts/uninhabited-const-issue-61744.rs new file mode 100644 index 000000000..860628c39 --- /dev/null +++ b/src/test/ui/consts/uninhabited-const-issue-61744.rs @@ -0,0 +1,20 @@ +// build-fail + +pub const unsafe fn fake_type<T>() -> T { + hint_unreachable() //~ ERROR any use of this value will cause an error [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out +} + +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); //~ ERROR erroneous constant used +} |