Skip to content

[i, j] is considered a refutable pattern for [int, ..2] #14256

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

Closed
kmcallister opened this issue May 17, 2014 · 1 comment
Closed

[i, j] is considered a refutable pattern for [int, ..2] #14256

kmcallister opened this issue May 17, 2014 · 1 comment

Comments

@kmcallister
Copy link
Contributor

let f: |[int, ..2]| -> int = |[i, j]| i+j;

produces

foo.rs:2:35: 2:41 error: refutable pattern in function argument
foo.rs:2     let f: |[int, ..2]| -> int = |[i, j]| i+j;
                                           ^~~~~~

But

for [i, j] in Some([1,2]).move_iter() {}

is fine.

rustc 0.11.0-pre (fbd8f4a 2014-05-15 08:36:50 -0700)
host: x86_64-unknown-linux-gnu
@huonw
Copy link
Member

huonw commented May 17, 2014

The reason for for working is it uses match internally, which was changed to recognise fixed-length vectors properly at some point, but let does not. (Dupe of #7784.)

@huonw huonw closed this as completed May 17, 2014
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