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