From b740179fc63a0638f5f4ea82c839000f101d1718 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 23 Sep 2022 14:42:01 -0700 Subject: [PATCH] attributes: suppress dead code warnings for compile tests (#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. --- tracing-attributes/tests/async_fn.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tracing-attributes/tests/async_fn.rs b/tracing-attributes/tests/async_fn.rs index 7e27fb5ce2..9d0d61c8ff 100644 --- a/tracing-attributes/tests/async_fn.rs +++ b/tracing-attributes/tests/async_fn.rs @@ -14,6 +14,7 @@ async fn test_async_fn(polls: usize) -> Result<(), ()> { // Reproduces a compile error when returning an `impl Trait` from an // instrumented async fn (see https://github.com/tokio-rs/tracing/issues/1615) +#[allow(dead_code)] // this is just here to test whether it compiles. #[instrument] async fn test_ret_impl_trait(n: i32) -> Result, ()> { let n = n; @@ -22,6 +23,7 @@ async fn test_ret_impl_trait(n: i32) -> Result, ()> { // Reproduces a compile error when returning an `impl Trait` from an // instrumented async fn (see https://github.com/tokio-rs/tracing/issues/1615) +#[allow(dead_code)] // this is just here to test whether it compiles. #[instrument(err)] async fn test_ret_impl_trait_err(n: i32) -> Result, &'static str> { Ok((0..10).filter(move |x| *x < n)) @@ -53,6 +55,7 @@ async fn repro_1613_2() { } // Reproduces https://github.com/tokio-rs/tracing/issues/1831 +#[allow(dead_code)] // this is just here to test whether it compiles. #[instrument] #[deny(unused_braces)] fn repro_1831() -> Pin>> { @@ -61,6 +64,7 @@ fn repro_1831() -> Pin>> { // This replicates the pattern used to implement async trait methods on nightly using the // `type_alias_impl_trait` feature +#[allow(dead_code)] // this is just here to test whether it compiles. #[instrument(ret, err)] #[deny(unused_braces)] #[allow(clippy::manual_async_fn)]