]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/async-fn-debug.rs
Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa
[rust.git] / src / test / codegen / async-fn-debug.rs
1 // Verify debuginfo for async fn:
2 //  - Each variant points to the file and line of its yield point
3 //  - The generator types and variants are marked artificial
4 //  - Captured vars from the source are not marked artificial
5 //
6 // ignore-tidy-linelength
7 // compile-flags: -C debuginfo=2 --edition=2018
8 // ignore-msvc
9
10 async fn foo() {}
11 async fn async_fn_test() {
12     foo().await;
13     let s = String::from("foo");
14     foo().await;
15 }
16
17 // FIXME: No way to reliably check the filename.
18
19 // CHECK-DAG:  [[ASYNC_FN:!.*]] = !DINamespace(name: "async_fn_test"
20 // CHECK-DAG:  [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "generator-0", scope: [[ASYNC_FN]], {{.*}}flags: DIFlagArtificial
21 // CHECK:      [[VARIANT:!.*]] = !DICompositeType(tag: DW_TAG_variant_part, scope: [[ASYNC_FN]],
22 // CHECK-SAME: flags: DIFlagArtificial
23 // CHECK-SAME: discriminator: [[DISC:![0-9]*]]
24 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "0", scope: [[VARIANT]],
25 // CHECK-SAME: file: [[FILE:![0-9]*]], line: 11,
26 // CHECK-SAME: flags: DIFlagArtificial
27 // CHECK:      {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "Unresumed", scope: [[GEN]],
28 // CHECK-SAME: flags: DIFlagArtificial
29 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]],
30 // CHECK-SAME: file: [[FILE]], line: 15,
31 // CHECK-SAME: flags: DIFlagArtificial
32 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]],
33 // CHECK-SAME: file: [[FILE]], line: 15,
34 // CHECK-SAME: flags: DIFlagArtificial
35 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]],
36 // CHECK-SAME: file: [[FILE]], line: 12,
37 // CHECK-SAME: flags: DIFlagArtificial
38 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "4", scope: [[VARIANT]],
39 // CHECK-SAME: file: [[FILE]], line: 14,
40 // CHECK-SAME: flags: DIFlagArtificial
41 // CHECK:      [[S1:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[GEN]],
42 // CHECK-SAME: flags: DIFlagArtificial
43 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: [[S1]]
44 // CHECK-NOT:  flags: DIFlagArtificial
45 // CHECK-SAME: )
46 // CHECK:      [[DISC]] = !DIDerivedType(tag: DW_TAG_member, name: "__state", scope: [[ASYNC_FN]],
47 // CHECK-SAME: flags: DIFlagArtificial
48
49 fn main() {
50     let _dummy = async_fn_test();
51 }