-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Explain "It is a logic error ... " in HashMap, BTreeMap and others #80657
Copy link
Copy link
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In various pieces of the documentation that talk about "It is a logic error ...", mostly to change the keys of HashMap/Sets and BTreeMap/Sets, using RefCells or hashing functions which change their behaviour based on global variables.
What does "it is a logic error ... " mean? With some brief playing it appears (to me) that it puts the datastructure in an inconsistent state, where future calls to any member function can return nonsense values.
It appears (from what I can tell) there is no unsafe behaviour, and it isn't possible to make the datastructures call
panic, but I would be happy to say they could panic (saying they won't means checking they can't when someone has already done something stupid).So, I suggest a short extra sentence which just says "These logic errors can lead to incorrect results and panics but not unsafe behaviour"