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

unnecessary .. binding in struct #638

Closed
oli-obk opened this issue Feb 8, 2016 · 0 comments · Fixed by #5258
Closed

unnecessary .. binding in struct #638

oli-obk opened this issue Feb 8, 2016 · 0 comments · Fixed by #5258
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-style Lint: Belongs in the style lint group L-unnecessary Lint: Warn about unnecessary code T-middle Type: Probably requires verifiying types

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Feb 8, 2016

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: "", .. } => {}
        _ => {},
    }
}
@oli-obk oli-obk added L-style Lint: Belongs in the style lint group L-unnecessary Lint: Warn about unnecessary code good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints T-middle Type: Probably requires verifiying types labels May 10, 2017
bors added a commit that referenced this issue Mar 3, 2020
Add lint for .. use in fully binded struct

This PR adds the lint `match-wild-in-fully-binded-struct` to prevent the use of the `..` pattern when all fields of the struct are already binded.

Fixes: #638

changelog: Add [`rest_pat_in_fully_bound_structs`] lint to warn against the use of `..` in fully binded struct
bors added a commit that referenced this issue Mar 3, 2020
Add lint for .. use in fully binded struct

This PR adds the lint `match-wild-in-fully-binded-struct` to prevent the use of the `..` pattern when all fields of the struct are already binded.

Fixes: #638

changelog: Add [`rest_pat_in_fully_bound_structs`] lint to warn against the use of `..` in fully binded struct
bors added a commit that referenced this issue Mar 3, 2020
Add lint for .. use in fully binded struct

This PR adds the lint `match-wild-in-fully-binded-struct` to prevent the use of the `..` pattern when all fields of the struct are already binded.

Fixes: #638

changelog: Add [`rest_pat_in_fully_bound_structs`] lint to warn against the use of `..` in fully binded struct
bors added a commit that referenced this issue Mar 4, 2020
Add lint for .. use in fully binded struct

This PR adds the lint `match-wild-in-fully-binded-struct` to prevent the use of the `..` pattern when all fields of the struct are already binded.

Fixes: #638

changelog: Add [`rest_pat_in_fully_bound_structs`] lint to warn against the use of `..` in fully binded struct
@bors bors closed this as completed in 36b6598 Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-style Lint: Belongs in the style lint group L-unnecessary Lint: Warn about unnecessary code T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants