Skip to content

tracing::instrument triggers clippy warning #1613

@malobre

Description

@malobre

Bug Report

Version

├── tracing v0.1.28
└── tracing-subscriber v0.2.24
    ├── tracing-core v0.1.21
    └── tracing-serde v0.1.2
        └── tracing-core v0.1.21

Platform

Linux 5.14.8-arch1-1 #1 SMP PREEMPT Sun, 26 Sep 2021 19:36:15 +0000 x86_64 GNU/Linux

Description

This code:

#[tracing::instrument]
pub async fn print_bool(var: bool) {
    println!(
        "{}",
        if var { "true" } else { "false" }
    );
}

triggers a clippy warning:

warning: this is an `else {..}` but the formatting might hide it
 --> src/lib.rs:2:36
  |
2 |   pub async fn print_bool(var: bool) {
  |  ____________________________________^
3 | |     println!(
4 | |         "{}",
5 | |         if var { "true" } else { "false" }
6 | |     );
7 | | }
  | |_^
  |
  = note: `#[warn(clippy::suspicious_else_formatting)]` on by default
  = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting

Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/attributesRelated to the `tracing-attributes` cratekind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions