From 45bd24adc690a6bd2dfd9bc8c9b47e740d09d546 Mon Sep 17 00:00:00 2001 From: liuhaozhan Date: Sat, 5 Nov 2022 01:08:28 +0530 Subject: [PATCH] attributes: allow `clippy::unreachable` warning (#2356) ## Motivation PR #2270 added an unreachable branch with an explicit return value to `#[instrument]` in `async fn`s in order to fix type inference issues. That PR added the appropriate `#[allow]` attribute for the Rust compiler's unreachable code linting, but not Clippy's, so a Clippy warning is still emitted. See: https://github.com/tokio-rs/tracing/pull/2270#issuecomment-1282881008 ## Solution Adding the clippy lint warning as discussed here: https://github.com/tokio-rs/tracing/pull/2270#issuecomment-1282887973 --- tracing-attributes/src/expand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracing-attributes/src/expand.rs b/tracing-attributes/src/expand.rs index 18103ed..2e1cda8 100644 --- a/tracing-attributes/src/expand.rs +++ b/tracing-attributes/src/expand.rs @@ -64,7 +64,7 @@ pub(crate) fn gen_function<'a, B: ToTokens + 'a>( // unreachable, but does affect inference, so it needs to be written // exactly that way for it to do its magic. let fake_return_edge = quote_spanned! {return_span=> - #[allow(unreachable_code, clippy::diverging_sub_expression, clippy::let_unit_value)] + #[allow(unreachable_code, clippy::diverging_sub_expression, clippy::let_unit_value, clippy::unreachable)] if false { let __tracing_attr_fake_return: #return_type = unreachable!("this is just for type inference, and is unreachable code");