Skip to content

Improper error about else if collapse. #4971

@wdanilo

Description

@wdanilo

Hi, I've got the following code:

        if t1 > t2 {
            if      value >= t1 { ValueCheck::Correct }
            else if value >= t2 { ValueCheck::Warning }
            else                { ValueCheck::Error   }
        } else {
            if      value <= t1 { ValueCheck::Correct }
            else if value <= t2 { ValueCheck::Warning }
            else                { ValueCheck::Error   }
        }

Clippy tells me:

warning: this `else { if .. }` block can be collapsed
   --> monitor.rs:328:16
    |
328 |           } else {
    |  ________________^
329 | |             if      value <= t1 { ValueCheck::Correct }
330 | |             else if value <= t2 { ValueCheck::Warning }
331 | |             else                { ValueCheck::Error   }
332 | |         }
    | |_________^

I believe this should not happen.

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions