Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4ced370
Make `missing_copy_implementations` more cautious
Sep 28, 2022
b209ff2
Update trait check
Nov 19, 2022
34277fc
Rebase
Nov 29, 2022
e658144
Rename `LitKind::to_token_lit` as `LitKind::synthesize_token_lit`.
nnethercote Nov 29, 2022
a7f35c4
Add `StrStyle` to `ast::LitKind::ByteStr`.
nnethercote Nov 29, 2022
2fd364a
Remove `token::Lit` from `ast::MetaItemLit`.
nnethercote Nov 29, 2022
d5526ff
Reorder `StrLit` fields.
nnethercote Nov 29, 2022
4a4270a
Migrate "function cannot return without recursing" diagnostic
lzcunt Aug 20, 2022
6b000cb
Migrate "unsafe_op_in_unsafe_fn" lints
lzcunt Aug 20, 2022
1443d1b
Migrate "requires unsafe" diagnostics
lzcunt Aug 24, 2022
cc85b01
Migrate "unused unsafe" lint
lzcunt Aug 24, 2022
07d3ce5
Migrate "non-exhaustive patterns: type is non-empty" diagnostic
lzcunt Aug 26, 2022
85c6818
Migrate pattern inlining error diagnostics
lzcunt Aug 26, 2022
7d0d2de
Migrate unreachable pattern diagnostic
lzcunt Aug 27, 2022
75694d5
Migrate "constant pattern depends on generic parameter" diagnostic
lzcunt Aug 27, 2022
baa6c15
Migrate "could not evaluate const pattern" diagnostic
lzcunt Aug 27, 2022
5c64edf
Migrate lower range bound diagnostics
lzcunt Aug 27, 2022
42a8f37
Migrate leading/trailing irrefutable let pattern diagnostics
lzcunt Aug 28, 2022
8c00282
Migrate pattern bindings with variant name lint
lzcunt Aug 29, 2022
1a18ee8
Migrate irrefutable let pattern diagnostics
lzcunt Aug 29, 2022
e2d9380
Migrate borrow of moved value diagnostic
lzcunt Aug 30, 2022
03128ba
Migrate multiple mut borrows diagnostic
lzcunt Aug 30, 2022
1d324dd
Resolve various merge conflicts
Nov 26, 2022
7d30472
Remove `mk_name_value_item{,_str}`.
nnethercote Dec 5, 2022
4ae956f
Remove `ExtCtxt::expr_lit`.
nnethercote Dec 5, 2022
d887615
Parameterise `Parser::{recover_unclosed_char,handle_missing_lit}`.
nnethercote Dec 5, 2022
568e647
Remove three uses of `LitKind::synthesize_token_lit`.
nnethercote Dec 5, 2022
7e0c6db
Remove `LitKind::synthesize_token_lit`.
nnethercote Dec 5, 2022
58e60ac
Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`
scottmcm Dec 8, 2022
5626df9
Add `rustc_on_unimplemented` to `Sum` and `Product` trait.
aDotInTheVoid Dec 4, 2022
90da11d
rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }`
notriddle Dec 9, 2022
6648134
Apply review feedback; Fix no_global_oom_handling build
scottmcm Dec 9, 2022
f41576b
Fix typo in apple_base.rs
eltociear Dec 9, 2022
0f0b4f6
Rollup merge of #102406 - mejrs:missing_copy, r=wesleywiser
Dylan-DPC Dec 9, 2022
979eaf4
Rollup merge of #104417 - mejrs:mir_build, r=davidtwco
Dylan-DPC Dec 9, 2022
c07a66a
Rollup merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Dylan-DPC Dec 9, 2022
bd92c94
Rollup merge of #105265 - aDotInTheVoid:sum-product-on-unimplemented,…
Dylan-DPC Dec 9, 2022
f5aaea5
Rollup merge of #105453 - scottmcm:vecdeque_from_iter, r=the8472
Dylan-DPC Dec 9, 2022
e2b4035
Rollup merge of #105480 - notriddle:notriddle/sidebar-toggle-mobile-c…
Dylan-DPC Dec 9, 2022
3b7e614
Rollup merge of #105489 - eltociear:patch-17, r=Dylan-DPC
Dylan-DPC Dec 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add rustc_on_unimplemented to Sum and Product trait.
  • Loading branch information
aDotInTheVoid committed Dec 8, 2022
commit 5626df9c9098fc83518e3bc4cef06e449279ac3c
8 changes: 8 additions & 0 deletions library/core/src/iter/traits/accum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use crate::num::Wrapping;
/// [`sum()`]: Iterator::sum
/// [`FromIterator`]: iter::FromIterator
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[rustc_on_unimplemented(
message = "a value of type `{Self}` cannot be made by summing an iterator over elements of type `{A}`",
label = "value of type `{Self}` cannot be made by summing a `std::iter::Iterator<Item={A}>`"
)]
pub trait Sum<A = Self>: Sized {
/// Method which takes an iterator and generates `Self` from the elements by
/// "summing up" the items.
Expand All @@ -27,6 +31,10 @@ pub trait Sum<A = Self>: Sized {
/// [`product()`]: Iterator::product
/// [`FromIterator`]: iter::FromIterator
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[rustc_on_unimplemented(
message = "a value of type `{Self}` cannot be made by multiplying all elements of type `{A}` from an iterator",
label = "value of type `{Self}` cannot be made by multiplying all elements from a `std::iter::Iterator<Item={A}>`"
)]
pub trait Product<A = Self>: Sized {
/// Method which takes an iterator and generates `Self` from the elements by
/// multiplying the items.
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/on-unimplemented/sum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// <https://github.com/rust-lang/rust/issues/105184>

fn main() {
vec![(), ()].iter().sum::<i32>();
//~^ ERROR

vec![(), ()].iter().product::<i32>();
//~^ ERROR
}
39 changes: 39 additions & 0 deletions src/test/ui/on-unimplemented/sum.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/sum.rs:4:5
|
LL | vec![(), ()].iter().sum::<i32>();
| ^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
| |
| value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
<i32 as Sum<&'a i32>>
<i32 as Sum>
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | S: Sum<Self::Item>,
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`

error[E0277]: a value of type `i32` cannot be made by multiplying all elements of type `&()` from an iterator
--> $DIR/sum.rs:7:5
|
LL | vec![(), ()].iter().product::<i32>();
| ^^^^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
| |
| value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>`
|
= help: the trait `Product<&()>` is not implemented for `i32`
= help: the following other types implement trait `Product<A>`:
<i32 as Product<&'a i32>>
<i32 as Product>
note: required by a bound in `std::iter::Iterator::product`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | P: Product<Self::Item>,
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::product`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.