Skip to content

Commit 6102f39

Browse files
authored
Rollup merge of #105265 - aDotInTheVoid:sum-product-on-unimplemented, r=estebank
Add `rustc_on_unimplemented` to `Sum` and `Product` trait. Helps with #105184, but I don't think it fully fixes it.
2 parents e6b65d5 + 351b002 commit 6102f39

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/src/iter/traits/accum.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use crate::num::Wrapping;
1010
/// [`sum()`]: Iterator::sum
1111
/// [`FromIterator`]: iter::FromIterator
1212
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
13+
#[rustc_on_unimplemented(
14+
message = "a value of type `{Self}` cannot be made by summing an iterator over elements of type `{A}`",
15+
label = "value of type `{Self}` cannot be made by summing a `std::iter::Iterator<Item={A}>`"
16+
)]
1317
pub trait Sum<A = Self>: Sized {
1418
/// Method which takes an iterator and generates `Self` from the elements by
1519
/// "summing up" the items.
@@ -27,6 +31,10 @@ pub trait Sum<A = Self>: Sized {
2731
/// [`product()`]: Iterator::product
2832
/// [`FromIterator`]: iter::FromIterator
2933
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
34+
#[rustc_on_unimplemented(
35+
message = "a value of type `{Self}` cannot be made by multiplying all elements of type `{A}` from an iterator",
36+
label = "value of type `{Self}` cannot be made by multiplying all elements from a `std::iter::Iterator<Item={A}>`"
37+
)]
3038
pub trait Product<A = Self>: Sized {
3139
/// Method which takes an iterator and generates `Self` from the elements by
3240
/// multiplying the items.

0 commit comments

Comments
 (0)