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

bad match_ref_pats suggestion. #4834

Open
Lokathor opened this issue Nov 22, 2019 · 2 comments
Open

bad match_ref_pats suggestion. #4834

Lokathor opened this issue Nov 22, 2019 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Lokathor
Copy link

In this line of this file of this commit, clippy says "you don't need to add & to all patterns", but because the & is actually changing the type of the binding, if you take off that & then the type going into png_u16 become wrong and the code doesn't compile.

@flip1995
Copy link
Member

We shouldn't emit this lint if the match is on &[T].

@flip1995 flip1995 added the C-bug Category: Clippy is not doing the correct thing label Nov 23, 2019
@ebroto
Copy link
Member

ebroto commented Jun 10, 2020

The lint also suggests to dereference the scrutinee. Wouldn't that work as expected?

fn test() {
    let v: &[i32] = &[1, 2, 3, 4];

    #[allow(clippy::single_match)]
    match *v {
        [a0, a1, b0, b1] => {
            takes_arr([a0, b0]);
            takes_arr([a1, b1]);
        },
        _ => {},
    }
}

fn takes_arr(_: [i32; 2]) {}

fn main() {
    test();
}

(playground)

@phansch phansch added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Dec 19, 2020
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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

4 participants