Skip to content

Commit 7855cfb

Browse files
committed
Add test for async function and async block
1 parent 9ceeedc commit 7855cfb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/codegen/issue-98678-async.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This test verifies the accuracy of emitted file and line debuginfo metadata for async blocks and
2+
// async functions.
3+
//
4+
// edition: 2021
5+
// compile-flags: -C debuginfo=2
6+
#![crate_type = "lib"]
7+
8+
// ignore-tidy-linelength
9+
10+
// NONMSVC-DAG: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}/codegen/issue-98678-async.rs{{".*}})
11+
// MSVC: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}\\codegen\\issue-98678-async.rs{{".*}})
12+
13+
// NONMSVC-DAG: !DISubprogram(name: "foo",{{.*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]],
14+
// MSVC-DAG: !DISubprogram(name: "foo",{{.*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
15+
pub async fn foo() -> u8 { 5 }
16+
17+
pub fn bar() -> impl std::future::Future<Output = u8> {
18+
// NONMSVC: !DICompositeType({{.*"}}{async_block_env#0}{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]],
19+
// MSVC-DAG: !DICompositeType({{.*"}}enum2$<issue_98678_async::bar::async_block_env$0>{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
20+
async {
21+
let x: u8 = foo().await;
22+
x + 5
23+
}
24+
25+
}

0 commit comments

Comments
 (0)