-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move HashMap to liballoc #51846
Move HashMap to liballoc #51846
Conversation
This is a step in the opposite direction of #51607 and rust-lang/rfcs#2480 :( As you say it doesn’t make a practical difference at the moment, but hopefully we can eliminate blockers one by one to get there. So I’d rather not add a new blocker without a plan of how to solve it eventually. |
This comment has been minimized.
This comment has been minimized.
You don't need to define the lang item manually. You can just not use |
My understanding of weak lang items is that just linking the This wouldn’t directly preclude stabilization of the crate, only make it less useful. |
If that is true, it's an accidential side effect of how rustc chooses which functions to emit code form, and thus rather fragile. Besides, "don't use this stable API in certain circumstances or else you get linker errors" is horrible UX.
If no_std usage of liballoc is liable to randomly break with linker errors (see above), the intended users of stable liballoc are hosed. |
That is correct.
In my view, the stabilization of liballoc is primarily aimed at allowing library crates which require memory allocation to be used in However, creating
I'm actually somewhat uncertain on how we can move forward with this. The only reasonable option that I can think of at the moment is to use a dynamic hook like we do for OOM. However I feel that this makes it too easy to forget to set the hook in no_std projects. |
Yes this is a tough problem, which is why I’m hesitant to accept this PR as proposed. |
Maybe we could make
|
This comment has been minimized.
This comment has been minimized.
Defining |
True, but no_std binaries require nightly anyways. And I feel that it's better to have |
This comment has been minimized.
This comment has been minimized.
More than requiring Nightly, I suppose what bothers me is adding one more obscure step that one might not care about but need to go through anyway (with often unhelpful error messages) in order to get a |
This comment has been minimized.
This comment has been minimized.
@SimonSapin We agree that's bothersome, but not giving |
no_std is very close to not requiring nightly, and this would be a huge step back. |
For what it’s worth I’m not arguing for not making this move ever, only for having a plan of what stabilization might look like. |
It's not a coincidence that stuff like choosing the global allocator, the OOM hook, panic hook, and now this keeps on coming up. The stabilization has to be one of a) general needs-provides, b) magic- |
This comment has been minimized.
This comment has been minimized.
I feel that having
Source: My current project uses no_std + liballoc. |
This comment has been minimized.
This comment has been minimized.
Yes unstable features churn is painful for everyone, but for allocation we’re reaching the end: with 1.28 + rust-lang/rfcs#2480 I believe that |
Full list of features used: |
This comment has been minimized.
This comment has been minimized.
It seems to me the issue with The current idea is to use the OS when available ( It would be nice if any solution for |
This comment has been minimized.
This comment has been minimized.
rust-lang/rfcs#2492 provides the single mechanism to solve separate |
This comment has been minimized.
This comment has been minimized.
I've changed |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
CC @alexcrichton per your comments on the alloc RFC, I think would agree this is a good first step to take while things are figured out long term? |
I would personally prefer to not merge this until that RFC is decided on. I don't think we're able to commit long-term to |
Since it's unstable in alloc but stable in std as of the latest revision of this PR, I don't think it would be hard to move it back at all. But fair enough, waiting a little bit shouldn't be too bad. |
Closing this until the RFC is merged. |
This PR adds a weak lang item
hashmap_random_keys
which returns two random numbers which are used to initialize SipHash for a newHashMap
. The previous implementation is moved into libstd which defines the lang item.This eliminates the only reason for keeping
HashMap
in libstd, and allows it to be used inno_std
projects. They will still need to define the lang item manually, butno_std
binaries are still nightly-only at the moment.r? @SimonSapin
cc @glandium