-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Associate an allocator to boxes #50882
Conversation
r? @bluss (rust_highfive has picked a reviewer for you, use r? to override) |
Note this has trivial conflicts with PR #50880, so whichever goes in first will need the other to be rebased on top of it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The various UI test changes raise the interesting question whether the compiler should "hide" default generic params in error messages. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
A few comments now that this is passing tests:
|
☔ The latest upstream changes (presumably #50984) made this pull request unmergeable. Please resolve the merge conflicts. |
Triage ping, @bluss / @rust-lang/libs: This PR needs you review, and, I assume, a crater run & FCP. |
We've long wanted to do something like this but we've been hesitant to do so historically due to various compiler bugs (which indeed aren't well tracked!). From the looks of the diff here it seems that error messages related to |
There is a crates.io crate that does this, but it can't replace Box. It's only by implementing things in liballoc that we end up figuring out what's good and what's bad about it. See #50882 (comment). |
☔ The latest upstream changes (presumably #50880) made this pull request unmergeable. Please resolve the merge conflicts. |
Sure yeah makes sense, but as a PR to rust is this expected to be merged? I'd personally still be wary of the error message segregation |
Re, degredation* |
As a PR to rust, it allows tests to run. A crater run could be useful, for instance. There are some implementation details that still need to be figured out. For example, the current patch doesn't remove the use of the box keyword, so only Box has fn new, while Box<T, A: Alloc + Default> theoretically could have it. |
Ping from triage! How should we move forward with this? |
☔ The latest upstream changes (presumably #51263) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm just still disappointed that unstable methods in an unstable create ( I'm reminded of the vision best described by @gnzlbg in rust-lang/rfcs#2480 (comment) on making |
I'll note that it is possible to experiment with crates today, to some extent, and I've done so with the allocator_api crate, that implements BUT "to some extent" is key. Because the liballoc exposes types rather than traits, one can't use an hypothetical That being said, this PR is a relatively small step to start experimenting with these things, and, like @Ericson2314, I don't see why this would need to wait. Well, except for the fact that, at the moment, I'm concerned that it breaks some compiler assumptions and that that would be the reason for the test failure. |
Yeah, it's precisely because this experiment will take so long that that it's important to unlock the parallelism of not hogging tons of lib team time. |
Yes the libs team understands the value in experimentation and doesn't want to unnecessarily block efforts, but this PR is touching the |
Ping from triage! If I understand correctly, this PR is blocked until after the 2018 edition ships, which is still quite some time to go. As such I'm closing this PR as blocked, following our triage procedure. Please add a comment or re-open if I missunderstood. |
@glandium Do you have plans to reopen this PR now that the 2018 edition has shipped? This would be really great to have. |
Yes please! Happy to assist in any way once it is, too. |
As long as #52694 is a problem (and it is because travis uses a system llvm that is affected), I can't make progress on this. |
Can we |
Can we? |
So... I tried to gave a quick try to the idea, but I hit two snags:
which I don't know what to do about.
With:
I can still compile code that uses |
That apparently comes from #54383. @mikeyhew, @nikomatsakis, @eddyb, any idea how to get around this? |
Thanks does trying! And sorry I didn't respond earlier. I think we can make an Also did you push this experiment yet? I'd love to try it. |
In this PR, you update the definition of pub struct Box<T: ?Sized, A: Alloc = Global>(Unique<T>, A); The problem is You need to edit this code here: https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/coherence/builtin.rs#L226. There are a couple options:
The real fix will be to support dynamic dispatch for method receivers with arbitrary ABIs, but that's pretty far off. For now it's probably best to use the |
I haven't fully rebased, because I was only trying to see if box_free could be made to type-error. Considering the |
Ah, what a mess! The one good thing is hopefully |
At this point it might be easier to support extra fields in I believe such support could work if built on top of the chalk-oriented "bounded/universe" types, e.g. computing the layout of This could also be used to represent the type of the data pointer field of DSTs, without overloading the meaning of a |
So the good news is that #52694 is now "magically" gone. I'm currently in the process of reviving this patch in a different form, working around the |
Opened #58457. |
This turns
Box<T>
intoBox<T, A: Alloc = Global>
. This is aminimalist change to achieve this, not touching anything that could have
backwards incompatible consequences like requiring type annotations in
places where they currently aren't required,
per #50822 (comment)