]> git.lizzy.rs Git - rust.git/blob - tests/codegen/noreturn-uninhabited.rs
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
[rust.git] / tests / codegen / noreturn-uninhabited.rs
1 // compile-flags: -g -C no-prepopulate-passes
2
3 #![crate_type = "lib"]
4
5 #[derive(Clone, Copy)]
6 pub enum EmptyEnum {}
7
8 #[no_mangle]
9 pub fn empty(x: &EmptyEnum) -> EmptyEnum {
10     // CHECK: @empty({{.*}}) unnamed_addr #0
11     // CHECK-NOT: ret void
12     // CHECK: call void @llvm.trap()
13     // CHECK: unreachable
14     *x
15 }
16
17 pub struct Foo(String, EmptyEnum);
18
19 #[no_mangle]
20 pub fn foo(x: String, y: &EmptyEnum) -> Foo {
21     // CHECK: @foo({{.*}}) unnamed_addr #0
22     // CHECK-NOT: ret %Foo
23     // CHECK: call void @llvm.trap()
24     // CHECK: unreachable
25     Foo(x, *y)
26 }
27
28 // CHECK: attributes #0 = {{{.*}} noreturn {{.*}}}
29
30 // CHECK: DISubprogram(name: "empty", {{.*}} DIFlagNoReturn
31 // CHECK: DISubprogram(name: "foo", {{.*}} DIFlagNoReturn