Skip to content

Commit 887fbd9

Browse files
committed
Split out async fn and generator test
This keeps FileCheck from tripping over unimportant differences in codegen.
1 parent fe3df64 commit 887fbd9

File tree

4 files changed

+102
-72
lines changed

4 files changed

+102
-72
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Verify debuginfo for generators:
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+
// only-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_union_type, name: "generator-0", scope: [[ASYNC_FN]], {{.*}}flags: DIFlagArtificial
21+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
22+
// For brevity, we only check the struct name and members of the last variant.
23+
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 11,
24+
// CHECK-SAME: flags: DIFlagArtificial
25+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
26+
// CHECK-SAME: file: [[FILE]], line: 15,
27+
// CHECK-SAME: flags: DIFlagArtificial
28+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
29+
// CHECK-SAME: file: [[FILE]], line: 15,
30+
// CHECK-SAME: flags: DIFlagArtificial
31+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
32+
// CHECK-SAME: file: [[FILE]], line: 12,
33+
// CHECK-SAME: flags: DIFlagArtificial
34+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
35+
// CHECK-SAME: file: [[FILE]], line: 14,
36+
// CHECK-SAME: baseType: [[VARIANT:![0-9]*]]
37+
// CHECK-SAME: flags: DIFlagArtificial
38+
// CHECK: [[S1:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[ASYNC_FN]],
39+
// CHECK-SAME: flags: DIFlagArtificial
40+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "RUST$ENUM$DISR", scope: [[S1]],
41+
// CHECK-SAME: flags: DIFlagArtificial
42+
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: [[S1]]
43+
// CHECK-NOT: flags: DIFlagArtificial
44+
// CHECK-SAME: )
45+
46+
fn main() {
47+
let _dummy = async_fn_test();
48+
}

src/test/codegen/async-fn-debug.rs

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
}

src/test/codegen/generator-debug-msvc.rs

+3-37
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// - Captured vars from the source are not marked artificial
55
//
66
// ignore-tidy-linelength
7-
// compile-flags: -C debuginfo=2 --edition=2018
7+
// compile-flags: -C debuginfo=2
88
// only-msvc
99

1010
#![feature(generators, generator_trait)]
@@ -18,19 +18,12 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
1818
}
1919
}
2020

21-
async fn foo() {}
22-
async fn async_fn_test() {
23-
foo().await;
24-
let s = String::from("foo");
25-
foo().await;
26-
}
27-
2821
// FIXME: No way to reliably check the filename.
2922

3023
// CHECK-DAG: [[GEN_FN:!.*]] = !DINamespace(name: "generator_test"
31-
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "generator-0", scope: [[GEN_FN]],
24+
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "generator-0", scope: [[GEN_FN]], {{.*}}flags: DIFlagArtificial
3225
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
33-
// For brevity, we just check the struct name and members of the last variant.
26+
// For brevity, we only check the struct name and members of the last variant.
3427
// CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
3528
// CHECK-SAME: flags: DIFlagArtificial
3629
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
@@ -54,33 +47,6 @@ async fn async_fn_test() {
5447
// CHECK-NOT: flags: DIFlagArtificial
5548
// CHECK-SAME: )
5649

57-
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "generator-0", scope: [[ASYNC_FN:![0-9]*]], {{.*}}flags: DIFlagArtificial
58-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
59-
// For brevity, we just check the struct name and members of the last variant.
60-
// CHECK-SAME: file: [[FILE]], line: 22,
61-
// CHECK-SAME: flags: DIFlagArtificial
62-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
63-
// CHECK-SAME: file: [[FILE]], line: 26,
64-
// CHECK-SAME: flags: DIFlagArtificial
65-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
66-
// CHECK-SAME: file: [[FILE]], line: 26,
67-
// CHECK-SAME: flags: DIFlagArtificial
68-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
69-
// CHECK-SAME: file: [[FILE]], line: 23,
70-
// CHECK-SAME: flags: DIFlagArtificial
71-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, scope: [[GEN]],
72-
// CHECK-SAME: file: [[FILE]], line: 25,
73-
// CHECK-SAME: baseType: [[VARIANT:![0-9]*]]
74-
// CHECK-SAME: flags: DIFlagArtificial
75-
// CHECK: [[S1:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[ASYNC_FN]],
76-
// CHECK-SAME: flags: DIFlagArtificial
77-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "RUST$ENUM$DISR", scope: [[S1]],
78-
// CHECK-SAME: flags: DIFlagArtificial
79-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: [[S1]]
80-
// CHECK-NOT: flags: DIFlagArtificial
81-
// CHECK-SAME: )
82-
8350
fn main() {
8451
let _dummy = generator_test();
85-
let _dummy = async_fn_test();
8652
}

src/test/codegen/generator-debug.rs

-35
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
1818
}
1919
}
2020

21-
async fn foo() {}
22-
async fn async_fn_test() {
23-
foo().await;
24-
let s = String::from("foo");
25-
foo().await;
26-
}
27-
2821
// FIXME: No way to reliably check the filename.
2922

3023
// CHECK-DAG: [[GEN_FN:!.*]] = !DINamespace(name: "generator_test"
@@ -57,34 +50,6 @@ async fn async_fn_test() {
5750
// CHECK: [[DISC]] = !DIDerivedType(tag: DW_TAG_member, name: "__state", scope: [[GEN_FN]],
5851
// CHECK-SAME: flags: DIFlagArtificial
5952

60-
// CHECK-DAG: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "generator-0", scope: [[ASYNC_FN:![0-9]*]], {{.*}}flags: DIFlagArtificial
61-
// CHECK: [[VARIANT:!.*]] = !DICompositeType(tag: DW_TAG_variant_part, scope: [[ASYNC_FN]],
62-
// CHECK-SAME: flags: DIFlagArtificial
63-
// CHECK-SAME: discriminator: [[DISC:![0-9]*]]
64-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "0", scope: [[VARIANT]],
65-
// CHECK-SAME: file: [[FILE]], line: 22,
66-
// CHECK-SAME: flags: DIFlagArtificial
67-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]],
68-
// CHECK-SAME: file: [[FILE]], line: 26,
69-
// CHECK-SAME: flags: DIFlagArtificial
70-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]],
71-
// CHECK-SAME: file: [[FILE]], line: 26,
72-
// CHECK-SAME: flags: DIFlagArtificial
73-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]],
74-
// CHECK-SAME: file: [[FILE]], line: 23,
75-
// CHECK-SAME: flags: DIFlagArtificial
76-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "4", scope: [[VARIANT]],
77-
// CHECK-SAME: file: [[FILE]], line: 25,
78-
// CHECK-SAME: flags: DIFlagArtificial
79-
// CHECK: [[S1:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend1", scope: [[GEN]],
80-
// CHECK-SAME: flags: DIFlagArtificial
81-
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: [[S1]]
82-
// CHECK-NOT: flags: DIFlagArtificial
83-
// CHECK-SAME: )
84-
// CHECK: [[DISC]] = !DIDerivedType(tag: DW_TAG_member, name: "__state", scope: [[ASYNC_FN]],
85-
// CHECK-SAME: flags: DIFlagArtificial
86-
8753
fn main() {
8854
let _dummy = generator_test();
89-
let _dummy = async_fn_test();
9055
}

0 commit comments

Comments
 (0)