Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed3c9b6

Browse files
committed
attributes: suppress dead code warnings for compile tests (tokio-rs#2322)
The `async_fn` test file in `tracing-attributes` contains several functions that exist just to test whether they _compile_, rather than make assertions about their behavior. Because these functions are never called, they (naturally) emit dead code warnings. This commit adds `#[allow(dead_code)]` to the compilation tests, plus a comment explaining why we do this.
1 parent 5ced411 commit ed3c9b6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tracing-attributes/tests/async_fn.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async fn test_async_fn(polls: usize) -> Result<(), ()> {
1414

1515
// Reproduces a compile error when returning an `impl Trait` from an
1616
// instrumented async fn (see https://github.com/tokio-rs/tracing/issues/1615)
17+
#[allow(dead_code)] // this is just here to test whether it compiles.
1718
#[instrument]
1819
async fn test_ret_impl_trait(n: i32) -> Result<impl Iterator<Item = i32>, ()> {
1920
let n = n;
@@ -22,6 +23,7 @@ async fn test_ret_impl_trait(n: i32) -> Result<impl Iterator<Item = i32>, ()> {
2223

2324
// Reproduces a compile error when returning an `impl Trait` from an
2425
// instrumented async fn (see https://github.com/tokio-rs/tracing/issues/1615)
26+
#[allow(dead_code)] // this is just here to test whether it compiles.
2527
#[instrument(err)]
2628
async fn test_ret_impl_trait_err(n: i32) -> Result<impl Iterator<Item = i32>, &'static str> {
2729
Ok((0..10).filter(move |x| *x < n))
@@ -53,6 +55,7 @@ async fn repro_1613_2() {
5355
}
5456

5557
// Reproduces https://github.com/tokio-rs/tracing/issues/1831
58+
#[allow(dead_code)] // this is just here to test whether it compiles.
5659
#[instrument]
5760
#[deny(unused_braces)]
5861
fn repro_1831() -> Pin<Box<dyn Future<Output = ()>>> {
@@ -61,6 +64,7 @@ fn repro_1831() -> Pin<Box<dyn Future<Output = ()>>> {
6164

6265
// This replicates the pattern used to implement async trait methods on nightly using the
6366
// `type_alias_impl_trait` feature
67+
#[allow(dead_code)] // this is just here to test whether it compiles.
6468
#[instrument(ret, err)]
6569
#[deny(unused_braces)]
6670
#[allow(clippy::manual_async_fn)]

0 commit comments

Comments
 (0)