Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equatable_if_let should not expand macros in suggestion #7781

Closed
ghost opened this issue Oct 7, 2021 · 0 comments · Fixed by #7788
Closed

equatable_if_let should not expand macros in suggestion #7781

ghost opened this issue Oct 7, 2021 · 0 comments · Fixed by #7788
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@ghost
Copy link

ghost commented Oct 7, 2021

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

@ghost ghost added the C-bug Category: Clippy is not doing the correct thing label Oct 7, 2021
@rustbot rustbot added the L-suggestion Lint: Improving, adding or fixing lint suggestions label Oct 7, 2021
bors added a commit that referenced this issue Oct 13, 2021
Do not expand macros in equatable_if_let suggestion

Fixes #7781

Let's use Hacktoberfest as a motivation to start contributing PRs myself again :)

changelog: [`equatable_if_let`]: No longer expands macros in the suggestion
bors added a commit that referenced this issue Oct 13, 2021
Do not expand macros in equatable_if_let suggestion

Fixes #7781

Let's use Hacktoberfest as a motivation to start contributing PRs myself again :)

changelog: [`equatable_if_let`]: No longer expands macros in the suggestion
@bors bors closed this as completed in 57dc034 Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant