Closed
Description
What it does
I would say the unnecessary_sort_by
lint should use the precise namespace for Reverse
.
Currently, it shows help like the following:
help: try: `args.sort_by_key(|b| Reverse(b.name()))`
It is not obvious where Reverse
is; for instance, if users' code includes Reverse
such as struct
or impl
, then this suggestion misleads them.
Accordingly, I would suggest using the precise namespace for Reverse
as std::cmp::Reverse
.
help: try: `args.sort_by_key(|b| std::cmp::Reverse(b.name()))`
Lint Name
unnecessary_sort_by
Example
The current help could be:
error: use Vec::sort_by_key here instead
--> $DIR/unnecessary_sort_by.rs:94:9
|
LL | args.sort_by(|a, b| b.name().cmp(&a.name()));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|b| Reverse(b.name()))`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|b| std::cmp::Reverse(b.name()))`