Skip to content

equatable_if_let should not expand macros in suggestion #7781

@ghost

Description

I tried this code:

#![warn(clippy::equatable_if_let)]

macro_rules! m1 {
    (x) => { "abc" };
    (y) => { "def" };
}

fn main() {
    if let m1!(x) = "abc" { 
        println!("OK");
    }
}

I expected to see this happen: I would get recommendation if "abc" == m1!(x)

Instead, this happened:

warning: this pattern matching can be expressed using equality
 --> src/main.rs:9:8
  |
9 |     if let m1!(x) = "abc" { 
  |        ^^^^^^^^^^^^^^^^^^ help: try: `"abc" == "abc"`
  |

The macro call is expanded. This code isn't equivalent depending on the macro.

Meta

Run on clippy master - 01ea06a

@rustbot label +L-suggestion

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingL-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