Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: Stabilize the alloc crate #2480
Conversation
SimonSapin
added
the
T-libs
label
Jun 19, 2018
alexcrichton
referenced this pull request
Jun 19, 2018
Open
Tracking issue for location of facade crates #27783
SimonSapin
force-pushed the
SimonSapin:liballoc
branch
from
be28193
to
eca6b28
Jun 19, 2018
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
|
I guess I'm afraid this goes back to our little-libraries philosophy debate in that I want the crates beneath |
This comment has been minimized.
This comment has been minimized.
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 comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
Please no more negative features, |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
|
@Nemo157 I completely agree, I'd rather see this always done as a positive lint rather than a negative one. |
This comment has been minimized.
This comment has been minimized.
Having a global allocator (and possibly OOM hooks) is everything that the If/when we have something similar to |
This comment has been minimized.
This comment has been minimized.
Is that what this is about? You’re advocating to block real use cases for months or years over a name? |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
Centril
referenced this pull request
Jun 22, 2018
Open
Add nominal no_std + alloc support to regex-syntax #477
This comment has been minimized.
This comment has been minimized.
Would it not be possible to add a prelude and use it automatically when
which implies that it would also be possible to make |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
I pushed a commit that rewrite that paragraph. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Minor note: we should probably be naming the module |
This comment has been minimized.
This comment has been minimized.
johnthagen
commented
Mar 15, 2019
•
|
Would this feature allow the use of When evaluating using Rust for an embedded project at work, not having dynamic containers was a big negative at the time compared with C++11/14 where the If this feature enables that kind of subset of Note how the guide currently uses ...
use heapless::{consts, Vec};
#[entry]
fn main() -> ! {
let (usart1, mono_timer, itm) = aux11::init();
// A buffer with 32 bytes of capacity
let mut buffer: Vec<u8, consts::U32> = Vec::new();
... |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
Mar 15, 2019
|
@johnthagen yes! And more than that, it allows critical infrastructure crates which are built on This is particularly interesting for things like RTOS environments which provide a heap but little else. |
Ericson2314
referenced this pull request
Mar 15, 2019
Closed
"allocator" and "nightly" features (for no_std environments) #153
This comment has been minimized.
This comment has been minimized.
|
@johnthagen Yes, if the application picks an allocator library and configures it with the |
This comment has been minimized.
This comment has been minimized.
|
I commented in carllerche/bytes#153 on what I see is the the circular logic behind needing stabilization. Let me reiterate here. It is stated that alloc hasn't changed much so we should stabilize it. But then it is complained that alloc changes a lot so it's too hard to support cargo features. The truth is the items in alloc do not change a lot in incompatible ways---even I believe that---so there should be no practical burden to crates supporting "alloc" vs "std" features today. [It's not like after this RFC those features could be combined or something, there's reasons to opt into std support other than avoiding unstable code.] Even the specific case I put forth as reason not to stabilize (as alloc params, use of hashbrown, fallibility, #2492 (now also a long-open RFC...), etc shake out, we should break apart crates to separate concerns) shouldn't cause library maintainers much pain. Most people make a fake |
This comment has been minimized.
This comment has been minimized.
|
I personally won't be adding alloc-only features to any of the more popular crates I maintain until it stabilizes. I've dealt with nightly only features in the past, and generally my experience there is a net negative due to (reasonable!) breaking changes and otherwise targeting stable Rust. I make the occasional exception or two, depending, but |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
Mar 15, 2019
|
@Ericson2314 regarding the reasons for not merging carllerche/bytes#153
The question is: do you block on failed If you don't block on the (nightly-dependent) tests for the I entirely sympathize with project maintainers who don't want to deal with So what was my solution? I forked bytes and then forked prost. These were both things that were originally PRs I wanted to get upstream. The Prost author was willing, but I'd like to make it clear this is a significant impediment to the sorts of projects I work on. I'm a bit frustrated in that the counterargument seems to be bikeshedding the details of specific proposed solutions, when really it seems like the point is that there are any number of ways |
kennytm
added a commit
to kennytm/rust
that referenced
this pull request
Mar 16, 2019
This was referenced Mar 19, 2019
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Mar 21, 2019
|
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. |
rfcbot
added
finished-final-comment-period
and removed
final-comment-period
labels
Mar 21, 2019
This comment has been minimized.
This comment has been minimized.
|
@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.) |
This comment has been minimized.
This comment has been minimized.
|
Also I might be totally wrong and this has nothing to do with defining one's own allocators. =) In that case ignore me. |
Centril
removed
I-nominated
T-lang
labels
Mar 21, 2019
This comment has been minimized.
This comment has been minimized.
|
@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". |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
It looks like miri intercepts and special-cases ( |
johnthagen
referenced this pull request
Mar 26, 2019
Open
Add section with alloc only but not libstd #10
This comment has been minimized.
This comment has been minimized.
|
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 |
SimonSapin commentedJun 19, 2018
•
edited
Existing tracking issue: rust-lang/rust#27783
HTML view