Skip to content

clippy::suspicious_else_formatting reports some Enums (?!) #7650

Closed
@Fishrock123

Description

@Fishrock123

Lint name: clippy::suspicious_else_formatting

This rule is certainly not working correctly.

I tried this code:

use clap::AppSettings::*;
use clap::Clap;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Clone, Debug, Deserialize, Serialize, Clap)]
#[clap(about = "about")]
#[clap(global_setting(ColoredHelp), global_setting(ColorAuto))]
pub enum MyEnum {
    MyVar { id: Uuid, id: Uuid },
}
clap = "3.0.0-beta.4"
serde_json = "1.0.66"
strum_macros = "0.21.1"
uuid = "0.8.2"

I expected to see this happen: Nothing, there is no if statement.

Instead, this happened:

warning: this looks like an `else if` but the `else` is missing
   --> my_file.rs:257:23
    |
257 |     MyVar { id: Uuid, id: Uuid },
    |               ^^^^^^^^
    |
    = note: `#[warn(clippy::suspicious_else_formatting)]` on by default
    = note: to remove this lint, add the missing `else` or add a new line before the second `if`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting

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-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1

This started happening after upgrading to Rust 1.55

Metadata

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