Skip to content

unnecessary .. binding in struct #638

@oli-obk

Description

@oli-obk

Even though all fields of a struct are matched explicitly, it's still allowed to add a .. pattern. This can improve forward compatibility, but I think it's equivalent to having a wildcard pattern after matching all enum variants explicitly (which is forbidden in Rust).

struct A {
    a: i32,
    b: i64,
    c: &'static str,
}

fn main() {
    match unimplemented!() {
        A { a: 5, b: 6, c: "", .. } => {}
        _ => {},
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-styleLint: Belongs in the style lint groupL-unnecessaryLint: Warn about unnecessary codeT-middleType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions