Skip to content

#[instrument(err)] triggers clippy::blocks_in_conditions when used inside of #[async_trait] on nightly #2912

Open
@Veetaha

Description

@Veetaha

Reproduction

Here is sample well-formed code that shouldn't trigger clippy lints:

#[async_trait::async_trait]
pub trait Foo {
    #[tracing::instrument(err)]
    async fn bar() -> Result<(), &'static str> {
        Ok(())
    }
}

When you give it to clippy you'll see a warning:

$ cargo +nightly clippy                              
    Checking sandbox v0.1.0 (/home/veetaha/sandbox/rust/crates/sandbox)
warning: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
 --> crates/sandbox/src/lib.rs:4:48
  |
4 |       async fn bar() -> Result<(), &'static str> {
  |  ________________________________________________^
5 | |         Ok(())
6 | |     }
  | |_____^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
  = note: `#[warn(clippy::blocks_in_conditions)]` on by default

warning: `sandbox` (lib) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.22s

Version

cargo 1.78.0-nightly (a4c63fe53 2024-03-06)
cargo tree | rg 'tracing|async-trait'
├── async-trait v0.1.77 (proc-macro)
├── tracing v0.1.40
│   ├── tracing-attributes v0.1.27 (proc-macro)
│   └── tracing-core v0.1.32
└── tracing-core v0.1.32 (*)

Platform

uname -a                             
Linux devbox-vkryvenko 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions