Skip to content

Commit 4b83208

Browse files
authored
Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco
Better error messages when collecting into `[T; n]` Fixes #96461
2 parents 4965bb4 + 1d1358b commit 4b83208

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

core/src/iter/traits/collect.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,24 @@
9696
#[rustc_on_unimplemented(
9797
on(
9898
_Self = "[{A}]",
99-
message = "a value of type `{Self}` cannot be built since `{Self}` has no definite size",
99+
message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
100100
label = "try explicitly collecting into a `Vec<{A}>`",
101101
),
102102
on(
103-
all(
104-
A = "{integer}",
105-
any(
106-
_Self = "[i8]",
107-
_Self = "[i16]",
108-
_Self = "[i32]",
109-
_Self = "[i64]",
110-
_Self = "[i128]",
111-
_Self = "[isize]",
112-
_Self = "[u8]",
113-
_Self = "[u16]",
114-
_Self = "[u32]",
115-
_Self = "[u64]",
116-
_Self = "[u128]",
117-
_Self = "[usize]"
118-
)
119-
),
120-
message = "a value of type `{Self}` cannot be built since `{Self}` has no definite size",
103+
all(A = "{integer}", any(_Self = "[{integral}]",)),
104+
message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
121105
label = "try explicitly collecting into a `Vec<{A}>`",
122106
),
107+
on(
108+
_Self = "[{A}; _]",
109+
message = "an array of type `{Self}` cannot be built directly from an iterator",
110+
label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
111+
),
112+
on(
113+
all(A = "{integer}", any(_Self = "[{integral}; _]",)),
114+
message = "an array of type `{Self}` cannot be built directly from an iterator",
115+
label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
116+
),
123117
message = "a value of type `{Self}` cannot be built from an iterator \
124118
over elements of type `{A}`",
125119
label = "value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`"

0 commit comments

Comments
 (0)