Skip to content

Warn suspicious_else_formatting when a function using "tracing crate" has a comment containing "else". #7760

Closed

Description

Lint name: suspicious_else_formatting

I tried this code:

use tracing::instrument;

#[instrument]
async fn func1() {
    // a
    // else
}

#[instrument]
async fn func2() {
    ()
    // else
}

#[instrument]
async fn func3() {
    let _ = ();
    // else
}

I expected to see this happen: No warning

Instead, this happened:

warning: this is an `else {..}` but the formatting might hide it
 --> src\lib.rs:4:17
  |
4 |   async fn func1() {
  |  _________________^
5 | |     // a;
6 | |     // else
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

Same warning for func1 to func3.

With version 0.1.28 of tracing.

Meta

Rust version (rustc -Vv):

rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-pc-windows-msvc
release: 1.55.0
LLVM version: 12.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions