-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Stabilize the alloc crate #2480
Conversation
I think having a stable I'm definitely in favour of not blocking a reasonable concrete solution to making fewer assumptions about the runtime environment on a perfect hypothetical vision of the future 👍 |
rust-lang/rust#42774 is so close unless we do this, because of issues I don't at this moment fully recall (having mentally paged them out over the last few months) adding default type variables. off-topic rant: Honestly more stabilization-as-is proposals kind of annoy me; I had a fairly detailed steps on how to make progress on the more pie-in-sky goals without blocking on research-level stuff from the portability working group, but I was never able to sit down with a quorum of people that mattered and fully explain things, so nothing could be prioritized and coordinated. Instead we keep on drifting by default towards "screw facade, stick it all back in std" despite the portability group leaning in the opposite direction. And the big-std approach does require way more language-level work before portability goals have any hope of being achieved, so I consider it a non-starter. With a stalling of the portability group (and 2nd-half-of-year delay for std-aware Cargo) I just went and worked on other things, and now I poke my head back in to see stuff like this. |
@Ericson2314 Could you explain that “unless”? I don’t see how having an As to your self-described off-topic rant, maybe you’re reacting to the discussion of a single-crate standard library in the RFC? That’s a possibility that may or may not happen, it is only discussed to show that this RFC doesn’t prevent it. It is not what this RFC is proposing. In fact this RFC is moving in the opposite direction, committing to having more standard library crates.
Beyond not factually describing this proposal, you’re making an accusation of attitude that I feel is not fair at all. I’m trying to argue for a way to make incremental improvement and to discuss alternatives, while I have yet to extract any concrete proposal from your many words written on this topic. |
Indeed we agree that
A separate If I recall correctly, there are difficulties going from
C.f with
You're right that I was not being fair. I had the hardest time explaining my preference for many little crates which is based on many separate individually small and future benefits, which is hard to string together into a single argument. We thankfully do agree that
The conversation is indeed woefully decentralized, inevitably leading to the difficulties in coordination. rust-lang/rust#42774 (comment) I mention doing the alias. rust-lang/rust#42774 (comment) I link to a (now-deleted?) post where I linked to the branch where I started generalized the collections. rust-lang-nursery/portability-wg#1 (comment), a still-existing post, I link that branch, and a preparatory PR to to |
I think there is value in So if the plan for allocator-generic collections is to make new types, I would prefer these types to have different names. Or at the very least to be in a dedicated module whose name indicates what the difference is, but not overloading the
It sounds like you have no objection to this RFC as proposed, so further discussion of the |
My objection is until we actually start making allocator-polymorphic and fallible collections, we shouldn't stabilize the For example rust-lang/rust#51607 (comment) I think registering a hook is a needlessly awkward interface I rather if we have ergonomic fallible collections. I also think that ergonomic fallible collections are way easier to implement than everyone else does.
OK so the thing we really want is for the allocator polymorphic types and std types to unify. I.e. there exists some allocator such that The library work I'm proposing is really easy if we could only get some consensus it's worth doing. [I don't really want to just crank out PRs until there's some consensus on the path should persued, but I made the linked branch to convert a few collections and show how easy it is]. I think all the collections could be converted in a month. The language work could take 2. We could definitely stabilize |
I guess I'm afraid this goes back to our little-libraries philosophy debate in that I want the crates beneath |
Again I don’t see how this is related to this RFC (stabilizing the
Also off-topic.
Still off-topic, but: are you volunteering to do this work? Consider working with glandium in rust-lang/rust#50882. (Not in this thread!)
As mentioned in the RFC, everything being stabilized here already exists (re-exported) as stable under If you’d like to object to the RFC please concentrate on what it actually proposes compared to the current situation, and keep other things you’d also like to happen to the relevant threads. |
This seems reasonable to me. One request: in the RFC, could you add a recommendation for conventions that crates supporting builds with or without the use of |
Please no more negative features, |
@joshtriplett The RFC already gives this example: #![no_std]
extern crate alloc;
use alloc::vec::Vec; One of the motivation points for the RFC is to allow this on stable Rust without using a Cargo feature at all. (Is that not clear? I can try to rephrase it.) @Nemo157 The example I had in mind was a For other libraries that can work with only |
I only want to say: Thank you so much for this! This will be awesome for anyone who has gone through the pain of conditional compilation of |
Thanks for the link. I commented there.
I disagree these stabile APIs are good enough for alloc. They might be good enough for the narrower set of situations For example I want to be able to look a library's dependencies and know that it may use allocation but it doesn't have any weird ambient authority. Being able to set hooks and use a global allocator constitute that ambient authority. Yes the hook interface isn't stable yet, but the global alloc stuff would be: I'd want to move it out to Taking a quote from rust-lang/rust#50882
If we make Overall, the portable work requires some realm for experimenting (not even for too long!), and stabilizing every crate behind facade ties are hands. (we can make more, but the good names will be taken). I'll never understand this rush to stabilize concurrent with no clear path (to me at least) for the working group to coalesce around proposals for an official roadmap. |
@Nemo157 I completely agree, I'd rather see this always done as a positive lint rather than a negative one. |
Having a global allocator (and possibly OOM hooks) is everything that the If/when we have something similar to |
Is that what this is about? You’re advocating to block real use cases for months or years over a name? |
I sort of presumed there was zero appetite to split core up and make a second facade. But I'd love to be wrong—that's a big reassurance! My mental model for stabilization was sort or bottom-up: working up carve out all the pure code and then deal with the lang items. But maybe this is better thought of as top down: strip things out of std leaving self-supporting subsets, while opening the door to future dividing-and-conquering down to pure bits. If the preceding paragraph sounds good to you, then yes that does just leave the name. If that is "everything" this create is about, can we call it |
I am not in favor of renaming the In what order you would like to focus your attention on other things doesn’t seem relevant. This thread is about this RFC making this proposal at this time. Off-topic: My earlier comment was not in support of nor against splitting up libcore. Whether that is possible or desirable is a discussion for another thread. It was only a statement of possibility not prevented by our stability policy. I only included it in an attempt to preemptively defuse an off-topic objection I suspected would be coming from you. |
Forget about my plans for a moment. You pointed out
Let's no pretend these intermediate crates haven't changed because people have been broadly happy with their existance. |
Would it not be possible to add a prelude and use it automatically when
which implies that it would also be possible to make |
The quoted part of the RFC might be giving a misleading framing. I think it’s better to think of current prelude(s) as the default one and the Until such a proposal is accepted, I think |
I pushed a commit that rewrite that paragraph. |
Could the pub mod prelude {
pub mod v1 {
pub use crate::boxed::Box;
pub use crate::borrow::ToOwned;
pub use crate::string::String;
pub use crate::string::ToString;
pub use crate::vec::Vec;
}
} This would hopefully be forward compatible with any implicit prelude proposal since it's a pattern used in a lot of crates now. |
Minor note: we should probably be naming the module |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
@SimonSapin I have a quick question -- perhaps @eddyb can elaborate -- but during the all hands it came up that we might want the compiler to be able to treat allocation functions as a "pure function" i.e., something the compiler could remove etc. Is there any "text" of this kind planned? (Sorry for being vague, I don't recall the details off hand.) |
Also I might be totally wrong and this has nothing to do with defining one's own allocators. =) In that case ignore me. |
@nikomatsakis Those were specifically for I think @alexcrichton is familiar with all the guarantees we tell LLVM about, and I suppose the question for him is "how many of those do you think we could reasonably add to The extra things we wanted, aside from the LLVM ones, were:
The "we can't guarantee X" language can also be replaced with "the allocator should accept/remain safe in face of X not being upheld by the compiler". |
@nikomatsakis I believe these questions are only tangentially relevant to this RFC (they remain the same if I believe the current status is that we patch LLVM ( We probably should document in the For the |
It looks like miri intercepts and special-cases ( |
The @rust-lang/libs team has decided to accept this RFC, after discussion in today’s triage meeting. To track further progress, subscribe to the repurposed tracking issue here: rust-lang/rust#27783 Consensus was that if and when |
This implements RFC 2480: * rust-lang/rfcs#2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes rust-lang#27783
…hton Stabilize the `alloc` crate. This implements RFC 2480: * rust-lang/rfcs#2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes rust-lang#27783
…hton Stabilize the `alloc` crate. This implements RFC 2480: * rust-lang/rfcs#2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes rust-lang#27783
…hton Stabilize the `alloc` crate. This implements RFC 2480: * rust-lang/rfcs#2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes rust-lang#27783
…hton Stabilize the `alloc` crate. This implements RFC 2480: * rust-lang/rfcs#2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes rust-lang#27783
Existing tracking issue: rust-lang/rust#27783
HTML view