-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
A-lintArea: New lintsArea: New lintsL-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint group
Description
What it does
I saw an interesting bug today. Apparently the following code is valid.
[3,1,2].sort_by_key(|x|{x;}|);The extra semicolon makes this function return (), which is valid, but this makes the sorting pointless.
Lint Name
useless_sort_by_key
Category
correctness
Advantage
- This is likely a bug, and should be fixed. I had it happen to my code, once.
- Or it can be just called redundant sort_by_key.
Drawbacks
- I don't see any
Example
[3,1,2].sort_by_key(|x|{x;}|);Could be written as:
That codes does nothing can be removed.
Or can be fixed, but it may be impossible to figure out what the user intended
[3,1,2].sort_by_key(|x|{x}|);I think this should be marked as an potential error.
aleksanderkrauze, TonalidadeHidrica, Alexendoo and jubnzv
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint group