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

Struct destructuring allows repeated bindings of a moved variable #9725

Closed
alexcrichton opened this issue Oct 5, 2013 · 2 comments · Fixed by #10776
Closed

Struct destructuring allows repeated bindings of a moved variable #9725

alexcrichton opened this issue Oct 5, 2013 · 2 comments · Fixed by #10776
Labels
A-codegen Area: Code generation P-medium Medium priority
Milestone

Comments

@alexcrichton
Copy link
Member

This code will segfault when run:

struct A {
    a: ~int,
    b: bool,
}

fn main() {
    let a = A { a: ~2, b: true };
    let A { a, a, _ } = a;
    println!("{:?}", a);
}

I'm not entirely sure why it segfaults, but I shouldn't be able to bind the name a twice. Turns out if you have long variable names and you accidentally forget the colon (to make it a: a, then this is will come back to bite you!)

@alexcrichton
Copy link
Member Author

Nominating production-ready

@catamorphism
Copy link
Contributor

1.0, high

flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 29, 2022
…x, r=llogiq

 Fix [match_single_binding] suggestion introduced an extra semicolon

Fix rust-lang#9725

---

changelog: [`match_single_binding`]: suggestion no longer introduces unneeded semicolons
[rust-lang#10060](rust-lang/rust-clippy#10060)
<!-- changelog_checked -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants