docs(guidelines): correct the max_by_key tie direction and record the decline's cost - #1294
Open
inureyes wants to merge 1 commit into
Open
docs(guidelines): correct the max_by_key tie direction and record the decline's cost#1294inureyes wants to merge 1 commit into
inureyes wants to merge 1 commit into
Conversation
… decline's cost Two corrections to the `HashMap Iteration Order` section added in #1290. The order-sensitive consumer list said `min_by_key` and `max_by_key` "both return the FIRST extremum". That is wrong for the max side and it is wrong in a way that misleads a fix: `min_by_key` and `min_by` return the first minimum, while `max_by_key` and `max_by` return the last maximum. Verified with `rustc -O` over `[(1, 5), (2, 5), (3, 5)]`: max yields `(3, 5)` and min yields `(1, 5)`. The practical consequence is that a tie component has to face the right direction for the call being fixed, and two arms of one policy can need opposite directions, which is exactly the case in #1293. The enforcement block recorded why two static-check candidates were declined but recorded only the arguments in favour of declining. It now also records what the decision has cost: #1293 is an eighth instance whose tie is reachable, and neither candidate flagged it, because its receiver is a cross-module accessor method rather than a literal `.values()` on a locally declared map. That is the same limitation the block already describes for #1277, so the section was predicting its own miss without saying so. Documentation only, no Rust changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docs(guidelines): correct the max_by_key tie direction and record the decline's cost
Two corrections to the
HashMap Iteration Ordersection added in #1290.The order-sensitive consumer list said
min_by_keyandmax_by_key"bothreturn the FIRST extremum". That is wrong for the max side and it is wrong in a
way that misleads a fix:
min_by_keyandmin_byreturn the first minimum,while
max_by_keyandmax_byreturn the last maximum. Verified withrustc -Oover[(1, 5), (2, 5), (3, 5)]: max yields(3, 5)and min yields(1, 5). The practical consequence is that a tie component has to face theright direction for the call being fixed, and two arms of one policy can need
opposite directions, which is exactly the case in #1293.
The enforcement block recorded why two static-check candidates were declined but
recorded only the arguments in favour of declining. It now also records what the
decision has cost: #1293 is an eighth instance whose tie is reachable, and
neither candidate flagged it, because its receiver is a cross-module accessor
method rather than a literal
.values()on a locally declared map. That is thesame limitation the block already describes for #1277, so the section was
predicting its own miss without saying so.
Documentation only, no Rust changed.