Skip to content

replace_consts false positive when using integer constant as part of range in match #4969

@ghost

Description

cargo clippy -V: clippy 0.0.212 (69f99e7 2019-12-14)

Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=401f208640cdf49300acf4ef902f01ee

Minimal example:

#![warn(clippy::replace_consts)] fn main() { match 0_u32 { 0 => "zero", // std::u32::MAX is suggested to be replaced with u32::max_value() 1..=std::u32::MAX => "more", }; }

If I try replacing std::u32::MAX with u32::max_value(), I get a syntax error from rust. Wrapping in parenthesis or curly braces doesn't make it valid.

I don't get a warning if it's not part of a range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions