diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-03-30 19:13:20 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-03-30 19:13:47 +0200 |
| commit | 40c5eefdcde3a8696881643faeb7e2619ea0322f (patch) | |
| tree | 895c9bda0926889de74cbb065c3738b575dfa326 /src/test/ui/array-slice-vec | |
| parent | 7f12561135e48fce7b23d58fa6ca4970d74523e3 (diff) | |
| download | rust-40c5eefdcde3a8696881643faeb7e2619ea0322f.tar.gz rust-40c5eefdcde3a8696881643faeb7e2619ea0322f.zip | |
add test for array len inference
Diffstat (limited to 'src/test/ui/array-slice-vec')
| -rw-r--r-- | src/test/ui/array-slice-vec/infer_array_len.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/array-slice-vec/infer_array_len.stderr | 11 |
2 files changed, 32 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 +} diff --git a/src/test/ui/array-slice-vec/infer_array_len.stderr b/src/test/ui/array-slice-vec/infer_array_len.stderr new file mode 100644 index 00000000000..6eed4ce4f0c --- /dev/null +++ b/src/test/ui/array-slice-vec/infer_array_len.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed + --> $DIR/infer_array_len.rs:19:9 + | +LL | let [_, _] = a.into(); + | ^^^^^^ consider giving this pattern a type + | + = note: type must be known at this point + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. |
