Skip to content

Commit fd9f7dc

Browse files
Suggest collecting into Vec<_> when collecting into [_]
1 parent 91050f7 commit fd9f7dc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

core/src/iter/traits/collect.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,32 @@
8181
/// ```
8282
#[stable(feature = "rust1", since = "1.0.0")]
8383
#[rustc_on_unimplemented(
84+
on(
85+
_Self = "[{A}]",
86+
message = "a value of type `{Self}` cannot be built since `{Self}` has no definite size",
87+
label = "try explicitly collecting into a `Vec<{A}>`",
88+
),
89+
on(
90+
all(
91+
A = "{integer}",
92+
any(
93+
_Self = "[i8]",
94+
_Self = "[i16]",
95+
_Self = "[i32]",
96+
_Self = "[i64]",
97+
_Self = "[i128]",
98+
_Self = "[isize]",
99+
_Self = "[u8]",
100+
_Self = "[u16]",
101+
_Self = "[u32]",
102+
_Self = "[u64]",
103+
_Self = "[u128]",
104+
_Self = "[usize]"
105+
)
106+
),
107+
message = "a value of type `{Self}` cannot be built since `{Self}` has no definite size",
108+
label = "try explicitly collecting into a `Vec<{A}>`",
109+
),
84110
message = "a value of type `{Self}` cannot be built from an iterator \
85111
over elements of type `{A}`",
86112
label = "value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`"

0 commit comments

Comments
 (0)