Commit Graph

154 Commits

Author SHA1 Message Date
Luqman Aden
b44d7cb89c Don't expose NonZero through libstd. 2014-12-28 19:40:48 -05:00
Luqman Aden
466135bfef libcore: Make it unsafe to create NonZero and impl Deref. 2014-12-28 19:40:48 -05:00
Luqman Aden
4af50548b9 liballoc: Use NonZero in Arc. 2014-12-28 19:40:47 -05:00
Luqman Aden
0d48f76224 liballoc: Use NonZero in Rc. 2014-12-28 19:40:47 -05:00
Flavio Percoco
29b3698f7f Implement Sync/Send for ArcInner and Weak 2014-12-26 17:26:33 +01:00
Flavio Percoco
8818693496 Relax Arc bounds don't require Sync+Send
Besides the above making sense, it'll also allow us to make `RacyCell`
private and use UnsafeCell instead.
2014-12-26 17:26:33 +01:00
Flavio Percoco
7df17a2868 Rename UniquePtr to Unique
Mostly following the convention in RFC 356
2014-12-26 17:26:33 +01:00
Flavio Percoco
f436f9ca29 Make Send and Sync traits unsafe 2014-12-26 17:26:33 +01:00
Flavio Percoco
686ce664da Rename OwnedPtr to UniquePtr 2014-12-26 17:26:33 +01:00
Flavio Percoco
fb803a8570 Require types to opt-in Sync 2014-12-26 17:26:32 +01:00
Alex Crichton
fb7c08876e Test fixes and rebase conflicts 2014-12-21 13:49:04 -08:00
Alex Crichton
1dc5e6312f rollup merge of #20070: aturon/stab-2-clone
This patch marks `clone` stable, as well as the `Clone` trait, but
leaves `clone_from` unstable. The latter will be decided by the beta.

The patch also marks most manual implementations of `Clone` as stable,
except where the APIs are otherwise deprecated or where there is
uncertainty about providing `Clone`.

r? @alexcrichton
2014-12-21 09:27:36 -08:00
Alex Crichton
40d59e9467 rollup merge of #20052: barosl/deref-for-box
As the previous pull request (#19023) was closed due to inactivity, I steal the chance and open this pull request. 😊

Fixes #18624.
2014-12-21 09:27:35 -08:00
Alex Crichton
c76590cb14 rollup merge of #19944: steveklabnik/doc_sync_arc
Take the docs from Rc<T>, apply them to Arc<T>, and fix some line lengths.
2014-12-21 09:26:42 -08:00
Aaron Turon
92ccc073e1 Stabilize clone
This patch marks `clone` stable, as well as the `Clone` trait, but
leaves `clone_from` unstable. The latter will be decided by the beta.

The patch also marks most manual implementations of `Clone` as stable,
except where the APIs are otherwise deprecated or where there is
uncertainty about providing `Clone`.
2014-12-20 00:37:44 -08:00
Barosl Lee
39f249067a Implement Deref for Box
Fixes #18624.
2014-12-20 08:58:33 +09:00
Aaron Turon
a27fbac868 Revise std::thread API to join by default
This commit is part of a series that introduces a `std::thread` API to
replace `std::task`.

In the new API, `spawn` returns a `JoinGuard`, which by default will
join the spawned thread when dropped. It can also be used to join
explicitly at any time, returning the thread's result. Alternatively,
the spawned thread can be explicitly detached (so no join takes place).

As part of this change, Rust processes now terminate when the main
thread exits, even if other detached threads are still running, moving
Rust closer to standard threading models. This new behavior may break code
that was relying on the previously implicit join-all.

In addition to the above, the new thread API also offers some built-in
support for building blocking abstractions in user space; see the module
doc for details.

Closes #18000

[breaking-change]
2014-12-18 23:31:52 -08:00
Alex Crichton
76fbb5d527 rollup merge of #19947: csouth3/arc-borrowfrom
Closes #19937.
2014-12-17 11:50:31 -08:00
Alex Crichton
3369b33a20 rollup merge of #19902: alexcrichton/second-pass-mem
This commit stabilizes the `mem` and `default` modules of std.
2014-12-17 11:50:29 -08:00
Chase Southwood
9caa66f9c8 Implement BorrowFrom<Arc<T>> for T 2014-12-16 22:12:40 -06:00
Steve Klabnik
6875eb5748 Improve Arc<T> documentation, and Rc<T> docs a bit
Take the docs from Rc<T>, apply them to Arc<T>, and fix some line lengths.
2014-12-16 21:07:57 -05:00
Steven Fackler
24a8ef63ff Move hash module from collections to core 2014-12-15 22:48:54 -08:00
Alex Crichton
9021f61ef7 std: Second pass stabilization of default
This commit performs a second pass stabilization of the `std::default` module.
The module was already marked `#[stable]`, and the inheritance of `#[stable]`
was removed since this attribute was applied. This commit adds the `#[stable]`
attribute to the trait definition and one method name, along with all
implementations found in the standard distribution.
2014-12-15 20:04:52 -08:00
Niko Matsakis
5c3d398919 Mostly rote conversion of proc() to move|| (and occasionally Thunk::new) 2014-12-14 04:21:56 -05:00
Aaron Weiss
ad7dacd9eb Implemented BorrowFrom<Rc<T>> for T. 2014-12-08 16:32:08 -05:00
bors
83a44c7fa6 auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns:

- `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")`
- `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")`
- `vec.as_mut_slice().sort()` -> `vec.sort()`
- `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)`

---

Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation.

This is rebased on top of #19167

cc @alexcrichton @aturon
2014-12-08 02:32:31 +00:00
Jorge Aparicio
0ac3b166df liballoc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Corey Farwell
4ef16741e3 Utilize fewer reexports
In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::* and Result::*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
2014-12-05 18:13:04 -05:00
Alexander Light
87235687a1 Add ability to use custom alloc::heap::imp
Adds the ability to use a custom allocator heap by passing either --cfg
external_crate and --extern external=<allocator_crate_name> or --cfg
external_funcs and defining the allocator functions prefixed by 'rust_'
somewhere.

This is useful for many reasons including OS/embedded development, and
allocator development and testing.
2014-12-04 16:23:29 -05:00
bors
4eb72d268f auto merge of #19112 : steveklabnik/rust/doc_rc, r=Gankro 2014-11-27 17:26:22 +00:00
Steven Fackler
348cc9418a Remove special casing for some meta attributes
Descriptions and licenses are handled by Cargo now, so there's no reason
to keep these attributes around.
2014-11-26 11:44:45 -08:00
Steve Klabnik
a1d983aa16 Document liballoc::rc
This commit introduces a bunch of documentation, fixes some consistency
issues, and just basically brings Rc<T> and Weak<T> up to snuff.
2014-11-25 15:49:51 -05:00
Jakub Bukaj
11700cb1d4 rollup merge of #19225: reem/any-unnecessary-transmute-copy
transmute_copy is no longer needed and is just slow.
2014-11-23 14:11:58 -05:00
Jakub Bukaj
77d1f0b83b rollup merge of #19193: scialex/rc-counts
These functions allow you to see how many weak and strong references
there are to an `Arc`, `Rc`, or an `rc::Weak`. Due to the design of
`Arc` it is not possible to get the number of weak references of an
arbitrary `arc::Weak`. Look in `arc.rs` for a more in-depth explanation.

On `arc::Arc` and `arc::Weak` these operations are wait-free and atomic.

This sort of information is useful for creating dynamically cleared caches for use in OS development, for example holding pages of files in memory until the address space is needed for something else.
2014-11-23 14:11:50 -05:00
Jonathan Reem
1b17eefa4a Any: use plain transmute instead of transmute_copy for downcasting.
transmute_copy is no longer needed and is just slow.
2014-11-22 16:06:21 -08:00
Alexander Light
69861df831 Shuffle locations for Deref
Remove both `strong_count` and `weak_count` from `Weak`s and make the
methods bare functions so as not to cause trouble with `deref`.
2014-11-21 17:56:33 -05:00
Alexander Light
4c36ad01e7 Add weak_count and strong_count to Rc and Arc
These functions allow you to see how many weak and strong references
there are to an `Arc`, `Rc`, or an `rc::Weak`. Due to the design of
`Arc` it is not possible to get the number of weak references of an
arbitrary `arc::Weak`. Look in `arc.rs` for a more in-depth explanation.

On `arc::Arc` and `arc::Weak` these operations are wait-free and atomic.
2014-11-21 15:42:01 -05:00
Aaron Turon
40c78ab037 Fallout from libgreen and libnative removal 2014-11-20 17:19:24 -08:00
Aaron Turon
4caffa8526 libs: fix #[stable] inheritance fallout
A recent change turned off inheritance for the #[stable] by default, but
failed to catch all the cases where this was being used in std. This
patch fixes that problem.
2014-11-14 20:39:41 -08:00
Alex Crichton
065e39bb2f Register new snapshots 2014-11-12 12:17:55 -08:00
bors
97a57ec909 auto merge of #18714 : nikomatsakis/rust/issue-18621-deref-for-refs, r=aturon
libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this.

r? @aturon
2014-11-07 11:31:25 +00:00
Niko Matsakis
f2aaed8338 libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this.
Fixes #18621.
2014-11-06 21:51:40 -05:00
Jorge Aparicio
73b86e4778 Implement Default for Box<[T]> 2014-11-06 13:10:20 -05:00
Jorge Aparicio
4c3b42271b DSTify Box<T> implementation of PartialEq, PartialOrd, Eq, Ord 2014-11-05 20:13:08 -05:00
Daniel Micay
fea985a0b5 bubble up out-of-memory errors from liballoc
This makes the low-level allocation API suitable for use cases where
out-of-memory conditions need to be handled.

Closes #18292

[breaking-change]
2014-11-01 19:23:20 -04:00
Jorge Aparicio
eef7e97017 DSTify Show and all the other formatting traits 2014-10-30 23:28:11 -05:00
Steve Klabnik
7828c3dd28 Rename fail! to panic!
https://github.com/rust-lang/rfcs/pull/221

The current terminology of "task failure" often causes problems when
writing or speaking about code. You often want to talk about the
possibility of an operation that returns a Result "failing", but cannot
because of the ambiguity with task failure. Instead, you have to speak
of "the failing case" or "when the operation does not succeed" or other
circumlocutions.

Likewise, we use a "Failure" header in rustdoc to describe when
operations may fail the task, but it would often be helpful to separate
out a section describing the "Err-producing" case.

We have been steadily moving away from task failure and toward Result as
an error-handling mechanism, so we should optimize our terminology
accordingly: Result-producing functions should be easy to describe.

To update your code, rename any call to `fail!` to `panic!` instead.
Assuming you have not created your own macro named `panic!`, this
will work on UNIX based systems:

    grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g'

You can of course also do this by hand.

[breaking-change]
2014-10-29 11:43:07 -04:00
Alex Crichton
35ad00d2ec alloc: Make deriving more friendly with Arc
This adds impls of Eq/Ord/PartialEq/PartialOrd/Show/Default to Arc<T>, and it
also removes the `Send + Sync` bound on the `Clone` impl of Arc to make it more
deriving-friendly. The `Send + Sync` requirement is still enforce on
construction, of course!
2014-10-27 22:45:44 -07:00
Adolfo Ochagavía
79e05e9995 Implement Show for Arc<T>
Fixes https://github.com/rust-lang/rust/issues/18299
2014-10-26 15:30:40 +01:00
Daniel Micay
a9e85100cd fix sized deallocation documentation 2014-10-25 14:12:21 -04:00