Skip to content

logic_bug lint should understand cfg! #1932

Closed
@ipetkov

Description

@ipetkov

Had a use case where a certain input parameter must trigger some fallback behavior for a specific OS, but clippy reported it as a logical bug:

let v: Vec<_> = ...;

if cfg!(windows) && v.is_empty() {
   // fallback behavior
} else {
   // default behavior for Unix/non-empty param
}

Clippy is correctly reporting that this is equivalent to false && ... on unix systems, but removing the first check (as per the suggestion) does not reflect the actual programmer intent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions