diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-31 15:59:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-31 15:59:46 +0200 |
| commit | 3ef70fe156be1f8236c23a49c0db841207895ef9 (patch) | |
| tree | 0f9e5c446397b06ad51e574ed5b2fa8ae373544c /src/test/ui/array-slice-vec/infer_array_len.rs | |
| parent | 38cd294ed5a90036d570b663e7bcdf8dd0fd775f (diff) | |
| parent | a3df1db8ee40f8c5dc520a5d0a37adc5a70a15be (diff) | |
| download | rust-3ef70fe156be1f8236c23a49c0db841207895ef9.tar.gz rust-3ef70fe156be1f8236c23a49c0db841207895ef9.zip | |
Rollup merge of #70562 - lcnr:const-arr_len, r=Centril
infer array len from pattern
closes #70529
This still errors in the following case
```rust
#![feature(const_generics)]
fn arr<const N: usize>() -> [u8; N] {
todo!()
}
fn main() {
match arr() {
[5, ..] => (),
//~^ ERROR cannot pattern-match on an array without a fixed length
[_, _] => (),
}
}
```
Considering that this should be rare and is harder to implement I would merge this PR without *fixing* the above.
Diffstat (limited to 'src/test/ui/array-slice-vec/infer_array_len.rs')
| -rw-r--r-- | src/test/ui/array-slice-vec/infer_array_len.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/array-slice-vec/infer_array_len.rs b/src/test/ui/array-slice-vec/infer_array_len.rs new file mode 100644 index 00000000000..22fe7cb8838 --- /dev/null +++ b/src/test/ui/array-slice-vec/infer_array_len.rs @@ -0,0 +1,21 @@ +// see issue #70529 +struct A; + +impl From<A> for [u8; 2] { + fn from(a: A) -> Self { + [0; 2] + } +} + +impl From<A> for [u8; 3] { + fn from(a: A) -> Self { + [0; 3] + } +} + + +fn main() { + let a = A; + let [_, _] = a.into(); + //~^ ERROR type annotations needed +} |
