Skip to content

Commit

Permalink
Rollup merge of #96466 - compiler-errors:error-collect-array, r=david…
Browse files Browse the repository at this point in the history
…twco

Better error messages when collecting into `[T; n]`

Fixes #96461
  • Loading branch information
Dylan-DPC authored Apr 28, 2022
2 parents 4965bb4 + 1d1358b commit 4b83208
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions core/src/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,24 @@
#[rustc_on_unimplemented(
on(
_Self = "[{A}]",
message = "a value of type `{Self}` cannot be built since `{Self}` has no definite size",
message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
label = "try explicitly collecting into a `Vec<{A}>`",
),
on(
all(
A = "{integer}",
any(
_Self = "[i8]",
_Self = "[i16]",
_Self = "[i32]",
_Self = "[i64]",
_Self = "[i128]",
_Self = "[isize]",
_Self = "[u8]",
_Self = "[u16]",
_Self = "[u32]",
_Self = "[u64]",
_Self = "[u128]",
_Self = "[usize]"
)
),
message = "a value of type `{Self}` cannot be built since `{Self}` has no definite size",
all(A = "{integer}", any(_Self = "[{integral}]",)),
message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
label = "try explicitly collecting into a `Vec<{A}>`",
),
on(
_Self = "[{A}; _]",
message = "an array of type `{Self}` cannot be built directly from an iterator",
label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
),
on(
all(A = "{integer}", any(_Self = "[{integral}; _]",)),
message = "an array of type `{Self}` cannot be built directly from an iterator",
label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
),
message = "a value of type `{Self}` cannot be built from an iterator \
over elements of type `{A}`",
label = "value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`"
Expand Down

0 comments on commit 4b83208

Please sign in to comment.