Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Veetaha opened this issue Mar 14, 2024 · 3 comments

Comments

@Veetaha
Copy link
Contributor

Veetaha commented Mar 14, 2024

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
@kaffarell
Copy link
Contributor

kaffarell commented Mar 15, 2024

This has been fixed by #2880

@Veetaha
Copy link
Contributor Author

Veetaha commented May 27, 2024

@kaffarell could you get this change released please? The last tracing-attributes release was in October 2023

@Veetaha
Copy link
Contributor Author

Veetaha commented May 27, 2024

Or maybe I should ask @hawkw instead for a release. Without this fix we have to disable this clippy lint globally because we have a lot of usages of this pattern of code with tracing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants