Skip to content

Commit f0eaa66

Browse files
committed
Add a test for tuple_array_conversion
1 parent e35eb91 commit f0eaa66

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/ui/tuple_array_conversions.rs

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ fn main() {
8282
[a, c];
8383
let [[a, b], [c, d]] = [[1, 2], [3, 4]];
8484
(a, c);
85+
// Array length is not usize (#11144)
86+
fn generic_array_length<const N: usize>() {
87+
let src = [0; N];
88+
let dest: (u8,) = (src[0],);
89+
}
8590
}
8691

8792
#[clippy::msrv = "1.70.0"]

tests/ui/tuple_array_conversions.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ LL | (src, dest);
6464
= help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed
6565

6666
error: it looks like you're trying to convert an array to a tuple
67-
--> $DIR/tuple_array_conversions.rs:99:13
67+
--> $DIR/tuple_array_conversions.rs:104:13
6868
|
6969
LL | let x = (x[0], x[1]);
7070
| ^^^^^^^^^^^^
7171
|
7272
= help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed
7373

7474
error: it looks like you're trying to convert a tuple to an array
75-
--> $DIR/tuple_array_conversions.rs:100:13
75+
--> $DIR/tuple_array_conversions.rs:105:13
7676
|
7777
LL | let x = [x.0, x.1];
7878
| ^^^^^^^^^^

0 commit comments

Comments
 (0)