-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #55139
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This turns `Box<T>` into `Box<T, A: Alloc = Global>`. This is a minimalist 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 rust-lang#50822 (comment)
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 |
As expected #52694 is still a problem. There is no way around it, short of requiring LLVM 7 for system LLVM builds. One problem here being that there isn't even a llvm-7-tools package for any version of Ubuntu (and travis builds are using 16.04, which doesn't even have LLVM 6) |
This PR introduces some new |
let ptr = ptr.as_ptr(); | ||
let size = size_of_val(&*ptr); | ||
let align = min_align_of_val(&*ptr); | ||
// We do not allocate for Box<T> when T is ZST, so deallocation is also not necessary. | ||
if size != 0 { | ||
let layout = Layout::from_size_align_unchecked(size, align); | ||
dealloc(ptr as *mut u8, layout); | ||
a.dealloc(NonNull::new_unchecked(ptr).cast(), layout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl<T> From<Unique<T>> for NonNull<T>
is safe and can be used here.
Ping from triage! Is there a way to work around the LLVM issues, short of requiring at least LLVM 7.0? Raising the minimum LLVM version would probably involve some kind of team RFC, but I'm not sure which team would be most appropriate. |
☔ The latest upstream changes (presumably #55316) made this pull request unmergeable. Please resolve the merge conflicts. |
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)
This is a rebased version of #50882, meant primarily to get CI results and see if #52694 is still a problem.
Cc: @SimonSapin