unnecessary_sort_by false positive on shared reference keys #5976
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
The
unnecessary_sort_by
lint is a false positive when it suggests to usesort_by_key
for keys that are shared references. The key cannot be returned in that case as it will not survive long enough.See this PR to the Pants project for an example.
Clippy triggers on this code:
Following Clippy's suggestion results in:
Following the next suggestion to remove the
&
marker results in:Meta
cargo clippy -V
: clippy 0.0.212 (04488afe3 2020-08-24)rustc -Vv
:The text was updated successfully, but these errors were encountered: