-
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
std: Refactor liballoc out of lib{std,sync} #14230
Conversation
total_size | ||
} | ||
|
||
// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power |
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.
Shouln't this be the next multiple of the alignment, not the nearest?
@alexcrichton travis failure seems legit |
The travis failure is happening for all travis builds. A snapshot will fix it (not specific to this PR) |
Ah, sorry. On Fri, May 16, 2014 at 1:57 PM, Alex Crichton notifications@github.comwrote:
|
//! | ||
//! This is the lowest level library through which allocation in Rust can be | ||
//! performed where the allocation is assumed to succeed. This library will | ||
//! trigger a task failure when allocation fails. |
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.
Hm... shouldn't the lowest level library not be triggering task failure? Are we planning to have any lower-level libraries returning Option
or something?
(Not a blocker for landing this at all.)
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.
I found that it was quite common to want to trigger task failure, much more so than I originally realized. I also found that all contexts have some form or notion of failure, although it's not always task failure.
For example, any of these operations can fail:
Option::unwrap
Result::unwrap
- integer division
- indexing a vector
- indexing a string
There's a bunch of others throughout the methods in libcore. Consumers of libcore also really want to fail such as liballoc, libcollections, etc. It ended up being common enough that I found it a core enough concept to declare in libcore, but not define in libcore.
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.
I was thinking from the perspective of task failure not being recoverable at the call site, i.e. a higher level library is free to fail, but the absolute lowest building blocks shouldn't, so that people can handle problems as they wish (even if it's just manually triggering task failure).
If liballoc isn't designed to be the lowest level allocation library, failing is fine.
(BTW, I think you may've misinterpreted my comment, because I wasn't talking about libcore, just liballoc.)
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.
Oops, sorry! I believe that the core allocator interface (located in liballoc) will be specced to not fail!()
, just the primitives on top of them (for example, the box
operator).
Perhaps we could extend the box
syntax to allow returning Option<T>
one day to accommodate this use case, because I'd definitely like to be able to re-use this code!
This commit is part of the libstd facade RFC, issue rust-lang#13851. This creates a new library, liballoc, which is intended to be the core allocation library for all of Rust. It is pinned on the basic assumption that an allocation failure is an abort or failure. This module has inherited the heap/libc_heap modules from std::rt, the owned/rc modules from std, and the arc module from libsync. These three pointers are currently the three most core pointer implementations in Rust. The UnsafeArc type in std::sync should be considered deprecated and replaced by Arc<Unsafe<T>>. This commit does not currently migrate to this type, but future commits will continue this refactoring.
This commit is part of the libstd facade RFC, issue #13851. This creates a new library, liballoc, which is intended to be the core allocation library for all of Rust. It is pinned on the basic assumption that an allocation failure is an abort or failure. This module has inherited the heap/libc_heap modules from std::rt, the owned/rc modules from std, and the arc module from libsync. These three pointers are currently the three most core pointer implementations in Rust. The UnsafeArc type in std::sync should be considered deprecated and replaced by `Arc<Unsafe<T>>`. This commit does not currently migrate to this type, but future commits will continue this refactoring.
This commit is part of the libstd facade RFC, issue #13851. This creates a new
library, liballoc, which is intended to be the core allocation library for all
of Rust. It is pinned on the basic assumption that an allocation failure is an
abort or failure.
This module has inherited the heap/libc_heap modules from std::rt, the owned/rc
modules from std, and the arc module from libsync. These three pointers are
currently the three most core pointer implementations in Rust.
The UnsafeArc type in std::sync should be considered deprecated and replaced by
Arc<Unsafe<T>>
. This commit does not currently migrate to this type, but futurecommits will continue this refactoring.