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

std: Refactor liballoc out of lib{std,sync} #14230

Merged
merged 2 commits into from
May 18, 2014

Conversation

alexcrichton
Copy link
Member

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.

@brson brson mentioned this pull request May 15, 2014
9 tasks
total_size
}

// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power
Copy link
Contributor

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?

@emberian
Copy link
Member

@alexcrichton travis failure seems legit

@alexcrichton
Copy link
Member Author

The travis failure is happening for all travis builds. A snapshot will fix it (not specific to this PR)

@emberian
Copy link
Member

Ah, sorry.

On Fri, May 16, 2014 at 1:57 PM, Alex Crichton notifications@github.comwrote:

The travis failure is happening for all travis builds. A snapshot will fix
it (not specific to this PR)


Reply to this email directly or view it on GitHubhttps://github.com//pull/14230#issuecomment-43378603
.

http://octayn.net/

//!
//! 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.
Copy link
Member

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.)

Copy link
Member Author

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.

Copy link
Member

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.)

Copy link
Member Author

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.
bors added a commit that referenced this pull request May 18, 2014
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.
@bors bors closed this May 18, 2014
@bors bors merged commit 4a1d21a into rust-lang:master May 18, 2014
@alexcrichton alexcrichton deleted the liballoc branch May 19, 2014 15:57
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

Successfully merging this pull request may close these issues.

5 participants