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

Inconsistency between destructuring assignment and pattern matching with tuples #5689

Closed
bstrie opened this issue Apr 3, 2013 · 1 comment

Comments

@bstrie
Copy link
Contributor

bstrie commented Apr 3, 2013

This code fails to compile:

fn main() {
    let bar = ~(1,2);
    foo(bar);
}

fn foo<T,U>(x: &(T,U)) {
    let (ref a, ref b) = *x;  // error: moving out of dereference of immutable & pointer
}

...but this (seemingly) logically equivalent does compile:

fn main() {
    let bar = ~(1,2);
    foo(bar);
}

fn foo<T,U>(x: &(T,U)) {
    let (a, b) = match *x {
        (ref a, ref b) => (a, b)
    };
}
@nikomatsakis
Copy link
Contributor

Dup of #4384

tesuji pushed a commit to tesuji/rustc that referenced this issue Jun 9, 2020
reversed_empty_ranges: avoid linting N..N except in for loop arguments

changelog: [`reversed_empty_ranges`]: avoid linting N..N except in for loop arguments

r? @yaahc
Fixes rust-lang#5689
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 12, 2023
…or` loop.

Reading the documentation for the lint, one could expect that the lint works in all cases that `X == Y`. This is false.

While the lint was updated, the documentation wasn't.

More information about the `N..N` problem in rust-lang#5689 and rust-lang#5628
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 12, 2023
…dswij

[rust-lang#10167] Clarify that the lint only works if x eq. y in a `for` loop.

Reading the documentation for the lint, one could expect that the lint works in all cases that `X == Y`. This is false.

While the lint was updated, the documentation wasn't.

More information about the `N..N` problem in rust-lang#5689 and rust-lang#5628

---

Fixes rust-lang#10167
changelog: [`reversed_empty_ranges`]: Update and clarify documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants