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

Allow destructuring assignment on fixed-length vectors #5520

Closed
tredoe opened this issue Mar 24, 2013 · 4 comments
Closed

Allow destructuring assignment on fixed-length vectors #5520

tredoe opened this issue Mar 24, 2013 · 4 comments
Labels
A-typesystem Area: The type system

Comments

@tredoe
Copy link

tredoe commented Mar 24, 2013

This expression looks refutable to me, but the compiler shows an error:

let [a, b] = [1, 2];
@bstrie
Copy link
Contributor

bstrie commented Mar 24, 2013

Historically the problem here is that an expression like let [a, b] = ... isn't irrefutable in the general case. Even something like this:

let [head, ..tail] = foo();

is refutable in the case where the result of foo() is an empty vector.

However, I wonder if this can be made to work only in the case of functions that return fixed-length vectors. If we know that the return type of foo() is [T, ..N] for any N > 0, this should be irrefutable, correct? Would that be useful?

@bstrie
Copy link
Contributor

bstrie commented Apr 22, 2013

Updated issue with new title.

@graydon
Copy link
Contributor

graydon commented Jun 11, 2013

reproduced 2013-06-11, tagged. nominating (weakly) for feature complete. not a backwards compat issue.

@bstrie
Copy link
Contributor

bstrie commented Jul 15, 2013

Rolling this into #7784 and closing.

@bstrie bstrie closed this as completed Jul 15, 2013
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
…nsch

rustup rust-lang#71215

There's currently an crash in `ui/new_without_default.rs` that I need to figure out how to avoid.

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

3 participants