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

Autofix on an if statement with a nested if statement using matches breaks #5962

Closed
RDambrosio016 opened this issue Aug 25, 2020 · 1 comment · Fixed by #5992
Closed

Autofix on an if statement with a nested if statement using matches breaks #5962

RDambrosio016 opened this issue Aug 25, 2020 · 1 comment · Fixed by #5992
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-macros Type: Issues with macros and macro expansion

Comments

@RDambrosio016
Copy link

RDambrosio016 commented Aug 25, 2020

I tried this code:

if true {
    if matches!(true, true) {
        /* .. */
    }
}

I expected to see this happen (correct autofix):

if true && matches!(true, true) {
    /* .. */
}

Instead, this happened:

if true && match $expression {
            $( $pattern )|+ $( if $guard )? => true,
            _ => false
        } {
    /* .. */
}

Meta

  • cargo clippy -V: 0.0.212 (de521cb 2020-08-21)
  • rustc -Vv:
rustc 1.47.0-nightly (de521cbb3 2020-08-21)
binary: rustc
commit-hash: de521cbb303c08febd9fa3755caccd4f3e491ea3
commit-date: 2020-08-21
host: x86_64-pc-windows-msvc
release: 1.47.0-nightly
LLVM version: 10.0
@RDambrosio016 RDambrosio016 added the C-bug Category: Clippy is not doing the correct thing label Aug 25, 2020
@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-macros Type: Issues with macros and macro expansion labels Aug 25, 2020
@giraffate
Copy link
Contributor

I will prepare a fix.

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 good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants