rust/tests/ui/type-inference/sort_by_key.stderr

20 lines
723 B
Plaintext

error[E0283]: type annotations needed
--> $DIR/sort_by_key.rs:3:40
|
LL | lst.sort_by_key(|&(v, _)| v.iter().sum());
| ----------- ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
| |
| type must be known at this point
|
= note: cannot satisfy `_: Ord`
note: required by a bound in `slice::<impl [T]>::sort_by_key`
--> $SRC_DIR/alloc/src/slice.rs:LL:COL
help: consider specifying the generic argument
|
LL | lst.sort_by_key(|&(v, _)| v.iter().sum::<S>());
| +++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0283`.