Skip to content

Code coverage misses .await lines #98712

Closed
@Will-Low

Description

@Will-Low

I tried running the LLVM code coverage report against this code using cargo llvm-cov:

async fn my_async_fn() -> bool {
    another_async_fn()
	.await
}

async fn another_async_fn() -> bool {
    true
}

#[cfg(test)]
mod tests {
    use crate::my_async_fn;

    #[tokio::test]
    async fn function_returns_true() {
        assert!(my_async_fn().await);
    }
}

I expected this to result in 100% code coverage.

Instead, the .await on line 3 is considered not covered:
Code Coverage

Meta

rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: aarch64-apple-darwin
release: 1.61.0
LLVM version: 14.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions