about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2015-04-15Fix some typos.Ms2ger-1/+1
2015-04-07alloc: impl fmt::Pointer for Rc, Arc and BoxRicho Healey-0/+24
Closes #24091
2015-04-04Removed explicit lifetimes for `get_mut`. Fixed the doc test.Dzmitry Malyshau-2/+4
2015-04-04Renamed Arc::try_unique to get_mutDzmitry Malyshau-23/+21
2015-04-04Rollup merge of #23997 - richo:typos, r=huonwManish Goregaokar-1/+1
Kinda hoped I'd spot something else for this PR, but then didn't.
2015-04-02liballoc: fix typoRicho Healey-1/+1
2015-04-01rollup merge of #23176: huonw/rm-boundsAlex Crichton-2/+2
2015-04-01Test fixes and rebase conflicts, round 1Alex Crichton-1/+4
2015-04-01rollup merge of #23939: nikomatsakis/fn-boxAlex Crichton-0/+71
Conflicts: src/liballoc/boxed.rs
2015-04-01rollup merge of #23867: nikomatsakis/issue-23086-take-3Alex Crichton-51/+2
This PR implements rust-lang/rfcs#1023. In the process it fixes #23086 and #23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence. I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable). Fixes #23918.
2015-04-01Collect the definition of the `Error` trait into `libstd` for now. ThisNiko Matsakis-51/+2
sidesteps a coherence difficulty where `liballoc` had to prove that `&str: !Error`, which didn't involve any local types.
2015-04-02Rollup merge of #23867 - nikomatsakis:issue-23086-take-3, r=pnkfelixManish Goregaokar-11/+7
This PR implements rust-lang/rfcs#1023. In the process it fixes #23086 and #23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence. I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable). Fixes #23918.
2015-04-02Rollup merge of #23844 - kvark:try_unique, r=alexcrichtonManish Goregaokar-6/+50
While trying to implement parallel ECS processing, I stumbled upon the need to mutate `Arc` contents. The only existed method that allowed that was `make_unique`, but it has issues: - it may clone the data as if nothing happened, where the program may just need to crash - it forces `Clone` bound, which I don't have The new `try_unique` allows accessing the contents mutably without `Clone` bound and error out if the pointer is not unique.
2015-04-01Remove `Thunk` struct and `Invoke` trait; change `Thunk` to be an aliasNiko Matsakis-8/+4
for `Box<FnBox()>`. I found the alias was still handy because it is shorter than the fully written type. This is a [breaking-change]: convert code using `Invoke` to use `FnBox`, which is usually pretty straight-forward. Code using thunk mostly works if you change `Thunk::new => Box::new` and `foo.invoke(arg)` to `foo(arg)`.
2015-04-01Add (unstable) FnBox trait as a nicer replacement for `Thunk`. The docNiko Matsakis-0/+75
comment includes a test that also shows how it can be used.
2015-04-01Fallout in libstd: remove impls now considered to conflict.Niko Matsakis-11/+4
2015-04-01Add `#[fundamental]` annotations into libcore so that `Sized` and theNiko Matsakis-0/+3
`Fn` traits are considered fundamental, along with `Box` (though that is mostly for show; the real type is `~T` in the compiler).
2015-03-31Added Arc::try_uniqueDzmitry Malyshau-6/+50
2015-03-31Test fixes and rebase conflicts, round 3Alex Crichton-1/+0
2015-03-31rollup merge of #23919: alexcrichton/stabilize-io-errorAlex Crichton-2/+45
Conflicts: src/libstd/fs/tempdir.rs src/libstd/io/error.rs
2015-03-31std: Stabilize last bits of io::ErrorAlex Crichton-2/+45
This commit stabilizes a few remaining bits of the `io::Error` type: * The `Error::new` method is now stable. The last `detail` parameter was removed and the second `desc` parameter was generalized to `E: Into<Box<Error>>` to allow creating an I/O error from any form of error. Currently there is no form of downcasting, but this will be added in time. * An implementation of `From<&str> for Box<Error>` was added to liballoc to allow construction of errors from raw strings. * The `Error::raw_os_error` method was stabilized as-is. * Trait impls for `Clone`, `Eq`, and `PartialEq` were removed from `Error` as it is not possible to use them with trait objects. This is a breaking change due to the modification of the `new` method as well as the removal of the trait implementations for the `Error` type. [breaking-change]
2015-03-31rollup merge of #23879: seanmonstar/del-from-errorAlex Crichton-3/+3
Conflicts: src/libcore/error.rs
2015-03-31rollup merge of #23886: demelev/remove_as_slice_usageAlex Crichton-1/+1
2015-03-31rollup merge of #23876: alexcrichton/stabilize-anyAlex Crichton-21/+6
This commit stabilizes the following APIs: * `TypeId::of` - now that it has an `Any` bound it's ready to be stable. * `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these inherent methods. This is a breaking change due to the removal of the `BoxAny` trait, but consumers can simply remove imports to fix crates. [breaking-change]
2015-03-31rollup merge of #23549: aturon/stab-numAlex Crichton-1/+0
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change] r? @alexcrichton
2015-03-31Auto merge of #23549 - aturon:stab-num, r=alexcrichtonbors-1/+0
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change] r? @alexcrichton
2015-03-31Stabilize std::numAaron Turon-1/+0
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-30convert: remove FromError, use From<E> insteadSean McArthur-3/+3
This removes the FromError trait, since it can now be expressed using the new convert::Into trait. All implementations of FromError<E> where changed to From<E>, and `try!` was changed to use From::from instead. Because this removes FromError, it is a breaking change, but fixing it simply requires changing the words `FromError` to `From`, and `from_error` to `from`. [breaking-change]
2015-03-30std: Stabilize the rest of Any/BoxAnyAlex Crichton-21/+6
This commit stabilizes the following APIs: * `TypeId::of` - now that it has an `Any` bound it's ready to be stable. * `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these inherent methods. This is a breaking change due to the removal of the `BoxAny` trait, but consumers can simply remove imports to fix crates. [breaking-change]
2015-03-31replace deprecated as_slice()Emeliov Dmitrii-1/+1
2015-03-30std: Standardize (input, output) param orderingsAlex Crichton-1/+1
This functions swaps the order of arguments to a few functions that previously took (output, input) parameters, but now take (input, output) parameters (in that order). The affected functions are: * ptr::copy * ptr::copy_nonoverlapping * slice::bytes::copy_memory * intrinsics::copy * intrinsics::copy_nonoverlapping Closes #22890 [breaking-change]
2015-03-28Rollup merge of #23803 - richo:unused-braces, r=ManishearthManish Goregaokar-1/+1
Pretty much what it says on the tin.
2015-03-28cleanup: Remove unused braces in use statementsRicho Healey-1/+1
2015-03-27rollup merge of #23775: alexcrichton/fix-flaky-testAlex Crichton-2/+2
Windows gets quite unhappy when a thread fails while the main thread is exiting, frequently leading to process deadlock. This has been causing quite a few deadlocks on the windows bots recently. The child threads are presumably failing because the `println!` is failing due to the main thread being shut down.
2015-03-27rollup merge of #23743: Adenilson/addInfoArcClone01Alex Crichton-1/+5
Adding more information about the behavior of Arc/Rc when you perform a clone() call.
2015-03-27rollup merge of #23712: nikomatsakis/reflect-traitAlex Crichton-3/+3
This PR introduces a `Reflect` marker trait which is a supertrait of `Any`. The idea is that `Reflect` is defined for all concrete types, but is not defined for type parameters unless there is a `T:Reflect` bound. This is intended to preserve the parametricity property. This allows the `Any` interface to be stabilized without committing us to unbounded reflection that is not easily detectable by the caller. The implementation of `Reflect` relies on an experimental variant of OIBIT. This variant behaves differently for objects, since it requires that all types exposed as part of the object's *interface* are `Reflect`, but isn't concerned about other types that may be closed over. In other words, you don't have to write `Foo+Reflect` in order for `Foo: Reflect` to hold (where `Foo` is a trait). Given that `Any` is slated to stabilization and hence that we are committed to some form of reflection, the goal of this PR is to leave our options open with respect to parametricity. I see the options for full stabilization as follows (I think an RFC would be an appropriate way to confirm whichever of these three routes we take): 1. We make `Reflect` a lang-item. 2. We stabilize some version of the OIBIT variation I implemented as a general mechanism that may be appropriate for other use cases. 3. We give up on preserving parametricity here and just have `impl<T> Reflect for T` instead. In that case, `Reflect` is a harmless but not especially useful trait going forward. cc @aturon cc @alexcrichton cc @glaebhoerl (this is more-or-less your proposal, as I understood it) cc @reem (this is more-or-less what we discussed on IRC at some point) cc @FlaPer87 (vaguely pertains to OIBIT)
2015-03-27alloc: Don't run some Arc doc testsAlex Crichton-2/+2
Windows gets quite unhappy when a thread fails while the main thread is exiting, frequently leading to process deadlock. This has been causing quite a few deadlocks on the windows bots recently. The child threads are presumably failing because the `println!` is failing due to the main thread being shut down.
2015-03-26Implement `Reflect` trait with a variant on the standard OIBITNiko Matsakis-3/+3
semantics that tests the *interface* of trait objects, rather than what they close over.
2015-03-26Adding more information about the behavior of Arc/RcAdenilson Cavalcanti-1/+5
when you perform a clone() call.
2015-03-26Added instability markers to `POST_DROP_*` consts, and related opt-in's.Felix S. Klock II-1/+1
(Reviewed rest of code; did not see other `pub` items that needed such treatment.) Driveby: fix typo in comment in ptr.rs.
2015-03-26Switch drop-flag to `u8` to allow special tags to instrument state.Felix S. Klock II-5/+6
Refactored code so that the drop-flag values for initialized (`DTOR_NEEDED`) versus dropped (`DTOR_DONE`) are given explicit names. Add `mem::dropped()` (which with `DTOR_DONE == 0` is semantically the same as `mem::zeroed`, but the point is that it abstracts away from the particular choice of value for `DTOR_DONE`). Filling-drop needs to use something other than `ptr::read_and_zero`, so I added such a function: `ptr::read_and_drop`. But, libraries should not use it if they can otherwise avoid it. Fixes to tests to accommodate filling-drop.
2015-03-24Remove unnecessary bounds from Drop impl for `Arc` and `arc::Weak` andFelix S. Klock II-3/+3
one of the helper method impls.
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-74/+92
2015-03-23rollup merge of #23598: brson/gateAlex Crichton-0/+24
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-0/+24
2015-03-23Add note about pointer state after the call.Steve Klabnik-0/+3
Fixes #23422
2015-03-18liballoc: Partially inline the refcount manipulation in the ArcPatrick Walton-8/+18
destructor.
2015-03-18Register new snapshotsAlex Crichton-8/+0
2015-03-17Auto merge of #23423 - nikomatsakis:issue-18737-trait-subtyping, r=nrcbors-1/+10
This upcast coercion currently never requires vtable changes. It should be generalized. This is a [breaking-change] -- if you have an impl on an object type like `impl SomeTrait`, then this will no longer be applicable to object types like `SomeTrait+Send`. In the standard library, this primarily affected `Any`, and this PR adds impls for `Any+Send` as to keep the API the same in practice. An alternate workaround is to use UFCS form or standalone fns. For more details, see <https://github.com/rust-lang/rust/issues/18737#issuecomment-78450798>. r? @nrc
2015-03-17Remove subtyping for object types and replace with an *upcast* coercion.Niko Matsakis-1/+10
This upcast coercion currently preserves the vtable for the object, but eventually it can be used to create a derived vtable. The upcast coercion is not introduced into method dispatch; see comment on #18737 for information about why. Fixes #18737.