Skip to content
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

Can/should things like Box<T, A> move to libcore? #24

Open
scottmcm opened this issue Jun 11, 2019 · 7 comments
Open

Can/should things like Box<T, A> move to libcore? #24

scottmcm opened this issue Jun 11, 2019 · 7 comments

Comments

@scottmcm
Copy link
Member

Given that Alloc is defined in core::alloc -- and alloc::alloc::Alloc is just a re-export -- would be be reasonable for things like Box to live in libcore? It seems like it would work, there just wouldn't be a default for the type parameter when using it from core instead of alloc or std...

@glandium
Copy link

You could say the same for almost everything in liballoc...

@SimonSapin
Copy link
Contributor

Yes. On principle, if there’s a "version" of an allocator-generic container without a default allocator, there’s no reason not to have it in libcore.

But how do we make that happen? Does pub type Box<T, A = Global> = core::boxed::Box<T, A>; work correctly, even with type inference? Are are you thinking of wrapper structs?

@glandium
Copy link

See rust-lang/rust#50882 (comment)

@Ericson2314
Copy link

I don't want to make core bigger, I want to separate the compiler-specific vs compiler-agnostic (purely stable Rust) parts of std and core so move library development can work independent and in parallel of rustc's release schedule (as long as it doesn't make any breaking interface changes).

@gnzlbg
Copy link

gnzlbg commented Jun 11, 2019

@Ericson2314 that sounds more like splitting libcore into a liblangitem sub-component, that's tied to the compiler, and layering the compiler agnostic stuff on top. While this might be desirable, there are other issues to balance, e.g., due to coherence, we can't implement traits from liblangitem for types declared in liblangitem outside of liblangitem, we can't implement methods for types inliblangitem outside of liblangitem without doing so via a trait, which has its own issues (e.g. trait methods can't be const fn yet, etc.), etc.

@Ericson2314
Copy link

Ericson2314 commented Jun 12, 2019

@gnzlbg yes it is hard and yes I'd like to make existing core a facade too. But that is another reason why I'd like to not put things in core now. Even if we agree to split it up later, if those items get entangled with everything else in the meantime it will be a lot harder than if those items lived in their own crate from the get-go.

@TimDiekmann
Copy link
Member

that sounds more like splitting libcore into a liblangitem

As Box is tied to the compiler, Box would even fit into liblangitem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants