Commit Graph

6832 Commits

Author SHA1 Message Date
ville-h 44b3ddef8d fix code referencing RwLockWriteGuard 2015-01-04 13:12:17 +02:00
bors 856b90c400 auto merge of #20393 : japaric/rust/impl-any, r=aturon
Needs a snapshot that contains PR #20385

r? @aturon
2015-01-04 11:01:04 +00:00
ville-h 98e6d12017 rename std::sync::RWLockWriteGuard to RwLockWriteGuard 2015-01-04 12:36:27 +02:00
ville-h 956cab6f97 fix code referencing RwLockReadGuard 2015-01-04 11:45:31 +02:00
ville-h 2dcbdc1eda rename std::sync::RWLockReadGuard to RwLockReadGuard 2015-01-04 11:43:14 +02:00
ville-h c3dcf9b6bf fix code and comments referencing RW_LOCK_INIT 2015-01-04 10:57:05 +02:00
Alex Crichton 7d8d06f86b Remove deprecated functionality
This removes a large array of deprecated functionality, regardless of how
recently it was deprecated. The purpose of this commit is to clean out the
standard libraries and compiler for the upcoming alpha release.

Some notable compiler changes were to enable warnings for all now-deprecated
command line arguments (previously the deprecated versions were silently
accepted) as well as removing deriving(Zero) entirely (the trait was removed).

The distribution no longer contains the libtime or libregex_macros crates. Both
of these have been deprecated for some time and are available externally.
2015-01-03 23:43:57 -08:00
ville-h 5344ae2d4f rename std::sync::RWLOCK_INIT to RW_LOCK_INIT 2015-01-04 09:03:27 +02:00
ville-h 817f75d2fb fix code and comments referencing StaticRwLock 2015-01-04 08:59:06 +02:00
Tshepang Lekhonkhobe d5d6de99b1 doc: remove incomplete sentence 2015-01-04 08:44:31 +02:00
Jorge Aparicio 5172b8046a remove `Any[Mut]RefExt` traits in favor of `impl Any` 2015-01-03 23:01:33 -05:00
Jorge Aparicio 351409a622 sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
Jorge Aparicio 8c5bb80d9b sed -i -s 's/\bmod}/self}/g' **/*.rs 2015-01-03 22:42:37 -05:00
Jorge Aparicio 56dcbd17fd sed -i -s 's/\bmod,/self,/g' **/*.rs 2015-01-03 22:42:21 -05:00
bors c6c786671d auto merge of #20490 : japaric/rust/assoc-types, r=aturon
closes #20486 
closes #20474 
closes #20441

[breaking-change]

The `Index[Mut]` traits now have one less input parameter, as the return type of the indexing operation is an associated type. This breaks all existing implementations.

---

binop traits (`Add`, `Sub`, etc) now have an associated type for their return type. Also, the RHS input parameter now defaults to `Self` (except for the `Shl` and `Shr` traits). For example, the `Add` trait now looks like this:

``` rust
trait Add<Rhs=Self> {
    type Output;

    fn add(self, Rhs) -> Self::Output;
}
```

The `Neg` and `Not` traits now also have an associated type for their return type.

This breaks all existing implementations of these traits.

---
Affected traits:

- `Iterator { type Item }`
- `IteratorExt` no input/output types, uses `<Self as Iterator>::Item` in its methods
- `DoubleEndedIterator` no input/output types, uses `<Self as Iterator>::Item` in its methods
- `DoubleEndedIteratorExt` no input/output types, uses `<Self as Iterator>::Item` in its methods
- `RandomAccessIterator` no input/output types
- `ExactSizeIterator` no input/output types, uses `<Self as Iterator>::Item` in its methods

This breaks all the implementations of these traits.
2015-01-04 00:50:59 +00:00
ville-h fedbde6623 rename std::sync::StaticRWLock to StaticRwLock 2015-01-04 02:15:56 +02:00
ville-h b2ab5d7658 fix code and comments referencing RwLock 2015-01-04 01:58:35 +02:00
Jorge Aparicio 4bfaa93978 std: fix fallout 2015-01-03 16:30:49 -05:00
Jorge Aparicio 7d3c5f020e use assoc types in unop traits 2015-01-03 16:29:22 -05:00
Jorge Aparicio 99017f82b6 use assoc types in binop traits 2015-01-03 16:29:19 -05:00
ville-h a2c2cb942e rename std::sync::RWLock to RwLock 2015-01-03 23:22:09 +02:00
Akos Kiss 6e5fb8bd1b Initial version of AArch64 support.
Adds AArch64 knowledge to:
* configure,
* make files,
* sources,
* tests, and
* documentation.
2015-01-03 15:16:10 +00:00
Jorge Aparicio 7095dd0070 core: merge IteratorPairExt into IteratorExt 2015-01-03 09:34:05 -05:00
Jorge Aparicio 6002c13f9b Register new snapshots 2015-01-03 09:34:05 -05:00
Jorge Aparicio de1446680c core: merge DoubleEndedIteratorExt into IteratorExt 2015-01-03 09:34:05 -05:00
Jorge Aparicio 1971a24441 std: fix fallout 2015-01-03 09:34:04 -05:00
Andrea Canciani 28cca28e62 Improve `make_hash` function
The `make_hash` function is used to prevent hashes of non-empty
buckets to collide with `EMPTY_HASH = 0u64`. Ideally this function
also preserve the uniform distribution of hashes and is cheap to
compute.

The new implementation reduces the input hash size by one bit, simply
by setting the most significant bit. This obviously prevent output
hashes to collide with `EMPTY_HASH` and guarantees that the uniform
distribution is preserved. Moreover, the new function is simpler (no
comparisons, just an OR) and (under the same assumptions as the old
function, i.e. only the least significant bit will contribute to the
bucket index) no additional collisions are caused.
2015-01-03 10:51:37 +01:00
bors 9c3e6082e7 auto merge of #20154 : P1start/rust/qualified-assoc-type-generics, r=nikomatsakis
This modifies `Parser::eat_lt` to always split up `<<`s, instead of doing so only when a lifetime name followed or the `force` parameter (now removed) was `true`. This is because `Foo<<TYPE` is now a valid start to a type, whereas previously only `Foo<<LIFETIME` was valid.

This is a [breaking-change]. Change code that looks like this:

```rust
let x = foo as bar << 13;
```

to use parentheses, like this:

```rust
let x = (foo as bar) << 13;
```

Closes #17362.
2015-01-03 03:25:21 +00:00
Alex Crichton 340f3fd7a9 rollup merge of #20410: japaric/assoc-types
Conflicts:
	src/liballoc/lib.rs
	src/libcollections/lib.rs
	src/libcollections/slice.rs
	src/libcore/ops.rs
	src/libcore/prelude.rs
	src/libcore/ptr.rs
	src/librustc/middle/traits/project.rs
	src/libstd/c_str.rs
	src/libstd/io/mem.rs
	src/libstd/io/mod.rs
	src/libstd/lib.rs
	src/libstd/path/posix.rs
	src/libstd/path/windows.rs
	src/libstd/prelude.rs
	src/libstd/rt/exclusive.rs
	src/libsyntax/lib.rs
	src/test/compile-fail/issue-18566.rs
	src/test/run-pass/deref-mut-on-ref.rs
	src/test/run-pass/deref-on-ref.rs
	src/test/run-pass/dst-deref-mut.rs
	src/test/run-pass/dst-deref.rs
	src/test/run-pass/fixup-deref-mut.rs
	src/test/run-pass/issue-13264.rs
	src/test/run-pass/overloaded-autoderef-indexing.rs
2015-01-02 13:51:50 -08:00
Alex Crichton 4459b1dced rollup merge of #20341: nikomatsakis/impl-trait-for-trait-2
Conflicts:
	src/librustc/middle/traits/mod.rs
	src/libstd/io/mod.rs
	src/test/run-pass/builtin-superkinds-self-type.rs
2015-01-02 11:13:05 -08:00
Alex Crichton e921e3f045 Rollup test fixes and rebase conflicts 2015-01-02 10:50:13 -08:00
Alex Crichton 735c308aed rollup merge of #20416: nikomatsakis/coherence
Conflicts:
	src/test/run-pass/issue-15734.rs
	src/test/run-pass/issue-3743.rs
2015-01-02 09:23:42 -08:00
Jorge Aparicio 64b7c22c46 core: use assoc types in `Deref[Mut]` 2015-01-02 12:19:59 -05:00
Alex Crichton 4b0e084aa1 rollup merge of #20354: alexcrichton/second-pass-thread_local
Conflicts:
	src/libstd/sys/common/thread_info.rs
2015-01-02 09:19:45 -08:00
Alex Crichton 009ec5d2b0 rollup merge of #20315: alexcrichton/std-sync
Conflicts:
	src/libstd/rt/exclusive.rs
	src/libstd/sync/barrier.rs
	src/libstd/sys/unix/pipe.rs
	src/test/bench/shootout-binarytrees.rs
	src/test/bench/shootout-fannkuch-redux.rs
2015-01-02 09:19:00 -08:00
Alex Crichton 074996d6f9 rollup merge of #20377: alexcrichton/issue-20352 2015-01-02 09:16:26 -08:00
Alex Crichton 8b7d032014 rollup merge of #20273: alexcrichton/second-pass-comm
Conflicts:
	src/doc/guide.md
	src/libcollections/bit.rs
	src/libcollections/btree/node.rs
	src/libcollections/slice.rs
	src/libcore/ops.rs
	src/libcore/prelude.rs
	src/librand/rand_impls.rs
	src/librustc/middle/check_match.rs
	src/librustc/middle/infer/region_inference/mod.rs
	src/librustc_driver/lib.rs
	src/librustdoc/test.rs
	src/libstd/bitflags.rs
	src/libstd/io/comm_adapters.rs
	src/libstd/io/mem.rs
	src/libstd/io/mod.rs
	src/libstd/io/net/pipe.rs
	src/libstd/io/net/tcp.rs
	src/libstd/io/net/udp.rs
	src/libstd/io/pipe.rs
	src/libstd/io/process.rs
	src/libstd/io/stdio.rs
	src/libstd/io/timer.rs
	src/libstd/io/util.rs
	src/libstd/macros.rs
	src/libstd/os.rs
	src/libstd/path/posix.rs
	src/libstd/path/windows.rs
	src/libstd/prelude/v1.rs
	src/libstd/rand/mod.rs
	src/libstd/rand/os.rs
	src/libstd/sync/barrier.rs
	src/libstd/sync/condvar.rs
	src/libstd/sync/future.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mpsc/mpsc_queue.rs
	src/libstd/sync/mpsc/select.rs
	src/libstd/sync/mpsc/spsc_queue.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/once.rs
	src/libstd/sync/rwlock.rs
	src/libstd/sync/semaphore.rs
	src/libstd/sync/task_pool.rs
	src/libstd/sys/common/helper_thread.rs
	src/libstd/sys/unix/process.rs
	src/libstd/sys/unix/timer.rs
	src/libstd/sys/windows/c.rs
	src/libstd/sys/windows/timer.rs
	src/libstd/sys/windows/tty.rs
	src/libstd/thread.rs
	src/libstd/thread_local/mod.rs
	src/libstd/thread_local/scoped.rs
	src/libtest/lib.rs
	src/test/auxiliary/cci_capture_clause.rs
	src/test/bench/shootout-reverse-complement.rs
	src/test/bench/shootout-spectralnorm.rs
	src/test/compile-fail/array-old-syntax-2.rs
	src/test/compile-fail/bind-by-move-no-guards.rs
	src/test/compile-fail/builtin-superkinds-self-type.rs
	src/test/compile-fail/comm-not-freeze-receiver.rs
	src/test/compile-fail/comm-not-freeze.rs
	src/test/compile-fail/issue-12041.rs
	src/test/compile-fail/unsendable-class.rs
	src/test/run-pass/builtin-superkinds-capabilities-transitive.rs
	src/test/run-pass/builtin-superkinds-capabilities-xc.rs
	src/test/run-pass/builtin-superkinds-capabilities.rs
	src/test/run-pass/builtin-superkinds-self-type.rs
	src/test/run-pass/capturing-logging.rs
	src/test/run-pass/closure-bounds-can-capture-chan.rs
	src/test/run-pass/comm.rs
	src/test/run-pass/core-run-destroy.rs
	src/test/run-pass/drop-trait-enum.rs
	src/test/run-pass/hashmap-memory.rs
	src/test/run-pass/issue-13494.rs
	src/test/run-pass/issue-3609.rs
	src/test/run-pass/issue-4446.rs
	src/test/run-pass/issue-4448.rs
	src/test/run-pass/issue-8827.rs
	src/test/run-pass/issue-9396.rs
	src/test/run-pass/ivec-tag.rs
	src/test/run-pass/rust-log-filter.rs
	src/test/run-pass/send-resource.rs
	src/test/run-pass/send-type-inference.rs
	src/test/run-pass/sendable-class.rs
	src/test/run-pass/spawn-types.rs
	src/test/run-pass/task-comm-0.rs
	src/test/run-pass/task-comm-10.rs
	src/test/run-pass/task-comm-11.rs
	src/test/run-pass/task-comm-13.rs
	src/test/run-pass/task-comm-14.rs
	src/test/run-pass/task-comm-15.rs
	src/test/run-pass/task-comm-16.rs
	src/test/run-pass/task-comm-3.rs
	src/test/run-pass/task-comm-4.rs
	src/test/run-pass/task-comm-5.rs
	src/test/run-pass/task-comm-6.rs
	src/test/run-pass/task-comm-7.rs
	src/test/run-pass/task-comm-9.rs
	src/test/run-pass/task-comm-chan-nil.rs
	src/test/run-pass/task-spawn-move-and-copy.rs
	src/test/run-pass/task-stderr.rs
	src/test/run-pass/tcp-accept-stress.rs
	src/test/run-pass/tcp-connect-timeouts.rs
	src/test/run-pass/tempfile.rs
	src/test/run-pass/trait-bounds-in-arc.rs
	src/test/run-pass/trivial-message.rs
	src/test/run-pass/unique-send-2.rs
	src/test/run-pass/unique-send.rs
	src/test/run-pass/unwind-resource.rs
2015-01-02 09:15:54 -08:00
Jorge Aparicio cc5ecaf765 merge `*SliceExt` traits, use assoc types in `SliceExt`, `Raw[Mut]Ptr` 2015-01-02 12:07:04 -05:00
Niko Matsakis 1b3734f8ae Fix fallout from change, adding explicit `Sized` annotations where necessary. 2015-01-02 12:06:59 -05:00
Steve Klabnik 76e3bc2338 Properly deal with Ordering in the guide
Now that it's been removed from the prelude, we need to treat things differently.

Fixes #17967
2015-01-02 08:54:06 -08:00
Alex Crichton 56290a0044 std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization
story for the prelude. Most of the RFC was directly applied, removing reexports.
Some reexports are kept around, however:

* `range` remains until range syntax has landed to reduce churn.
* `Path` and `GenericPath` remain until path reform lands. This is done to
  prevent many imports of `GenericPath` which will soon be removed.
* All `io` traits remain until I/O reform lands so imports can be rewritten all
  at once to `std::io::prelude::*`.

This is a breaking change because many prelude reexports have been removed, and
the RFC can be consulted for the exact list of removed reexports, as well as to
find the locations of where to import them.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md
[breaking-change]

Closes #20068
2015-01-02 08:54:06 -08:00
bors 71b46b18a2 auto merge of #20356 : Gankro/rust/stab, r=aturon
This stabilizes most of libcollections, carefully avoiding sections of API which are being managed in other PRs. APIs which are not stable are marked explicitly unstable with a reason.

Deprecates:

* DList
  * rotate_forward
  * rotate_backward
  * prepend
  * insert_when
  * insert_ordered
  * merge

* VecMap
  * update
  * update_with_key

* Renames and newtypes the Bitv and BitvSet iterators to match conventions.

* Removes the Copy impl from DList's Iter.

as such this is a

[breaking-change]
2015-01-02 15:51:25 +00:00
Niko Matsakis c61a0092bc Fix orphan checking (cc #19470). (This is not a complete fix of #19470 because of the backwards compatibility feature gate.)
This is a [breaking-change]. The new rules require that, for an impl of a trait defined
in some other crate, two conditions must hold:

1. Some type must be local.
2. Every type parameter must appear "under" some local type.

Here are some examples that are legal:

```rust
struct MyStruct<T> { ... }

// Here `T` appears "under' `MyStruct`.
impl<T> Clone for MyStruct<T> { }

// Here `T` appears "under' `MyStruct` as well. Note that it also appears
// elsewhere.
impl<T> Iterator<T> for MyStruct<T> { }
```

Here is an illegal example:

```rust
// Here `U` does not appear "under" `MyStruct` or any other local type.
// We call `U` "uncovered".
impl<T,U> Iterator<U> for MyStruct<T> { }
```

There are a couple of ways to rewrite this last example so that it is
legal:

1. In some cases, the uncovered type parameter (here, `U`) should be converted
   into an associated type. This is however a non-local change that requires access
   to the original trait. Also, associated types are not fully baked.
2. Add `U` as a type parameter of `MyStruct`:
   ```rust
   struct MyStruct<T,U> { ... }
   impl<T,U> Iterator<U> for MyStruct<T,U> { }
   ```
3. Create a newtype wrapper for `U`
   ```rust
   impl<T,U> Iterator<Wrapper<U>> for MyStruct<T,U> { }
   ```

Because associated types are not fully baked, which in the case of the
`Hash` trait makes adhering to this rule impossible, you can
temporarily disable this rule in your crate by using
`#![feature(old_orphan_check)]`. Note that the `old_orphan_check`
feature will be removed before 1.0 is released.
2015-01-02 04:06:09 -05:00
Alex Crichton e423fcf0e0 std: Enforce Unicode in fmt::Writer
This commit is an implementation of [RFC 526][rfc] which is a change to alter
the definition of the old `fmt::FormatWriter`. The new trait, renamed to
`Writer`, now only exposes one method `write_str` in order to guarantee that all
implementations of the formatting traits can only produce valid Unicode.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md

One of the primary improvements of this patch is the performance of the
`.to_string()` method by avoiding an almost-always redundant UTF-8 check. This
is a breaking change due to the renaming of the trait as well as the loss of the
`write` method, but migration paths should be relatively easy:

* All usage of `write` should move to `write_str`. If truly binary data was
  being written in an implementation of `Show`, then it will need to use a
  different trait or an altogether different code path.

* All usage of `write!` should continue to work as-is with no modifications.

* All usage of `Show` where implementations just delegate to another should
  continue to work as-is.

[breaking-change]

Closes #20352
2015-01-01 22:04:46 -08:00
Alex Crichton f3a7ec7028 std: Second pass stabilization of sync
This pass performs a second pass of stabilization through the `std::sync`
module, avoiding modules/types that are being handled in other PRs (e.g.
mutexes, rwlocks, condvars, and channels).

The following items are now stable

* `sync::atomic`
* `sync::atomic::ATOMIC_BOOL_INIT` (was `INIT_ATOMIC_BOOL`)
* `sync::atomic::ATOMIC_INT_INIT` (was `INIT_ATOMIC_INT`)
* `sync::atomic::ATOMIC_UINT_INIT` (was `INIT_ATOMIC_UINT`)
* `sync::Once`
* `sync::ONCE_INIT`
* `sync::Once::call_once` (was `doit`)
  * C == `pthread_once(..)`
  * Boost == `call_once(..)`
  * Windows == `InitOnceExecuteOnce`
* `sync::Barrier`
* `sync::Barrier::new`
* `sync::Barrier::wait` (now returns a `bool`)
* `sync::Semaphore::new`
* `sync::Semaphore::acquire`
* `sync::Semaphore::release`

The following items remain unstable

* `sync::SemaphoreGuard`
* `sync::Semaphore::access` - it's unclear how this relates to the poisoning
                              story of mutexes.
* `sync::TaskPool` - the semantics of a failing task and whether a thread is
                     re-attached to a thread pool are somewhat unclear, and the
                     utility of this type in `sync` is question with respect to
                     the jobs of other primitives. This type will likely become
                     stable or move out of the standard library over time.
* `sync::Future` - futures as-is have yet to be deeply re-evaluated with the
                   recent core changes to Rust's synchronization story, and will
                   likely become stable in the future but are unstable until
                   that time comes.

[breaking-change]
2015-01-01 22:02:59 -08:00
Nick Cameron 2c92ddeda7 More fallout 2015-01-02 10:28:19 +13:00
Nick Cameron 7e2b9ea235 Fallout - change array syntax to use `;` 2015-01-02 10:28:19 +13:00
Jorge Aparicio 12dd7781d6 std: unbox closures used in let bindings 2014-12-31 22:50:27 -05:00
Jorge Aparicio 371f04d433 std: unbox closures used in function arguments 2014-12-31 22:50:25 -05:00
Alexis Beingessner 8dbaa7105e stabilize more of collections 2014-12-31 18:54:08 -05:00
Alex Crichton be11aa6d70 std: Second pass stabilization for thread_local
This commit performs a second pass over the `std::thread_local` module. Most of
the functionality remains explicitly unstable, but the specific actions taken
were:

* `thread_local` is now stable
* `thread_local!` is now stable
* `thread_local::Key` is now stable
* `thread_local::Key::with` is now stable
* `thread_local::Key::destroyed` is deprecated in favor of a more general
  `state` function
* `thread_local::Key::state` was added to query the three states that a key can
  be in: uninitialized, valid, or destroyed. This function, and the
  corresponding `State` enum, are both marked unstable as we may wish to expand
  it later on.
* `thread_local::scoped` is entirely unstable. There hasn't been a whole lot of
  usage of this module in the standard distribution, so it remains unstable at
  this time.

Note that while the structure `Key` is marked stable, it is currently forced to
expose all of its implementation details due to the use of
construction-via-macro. The use of construction-via-macro is currently required
in order to place the `#[thread_local]` attribute on static in a
platform-specific manner. These stability attributes were assigned assuming that
it will be acceptable to tweak the implementation of `Key` in the future.
2014-12-31 15:50:28 -08:00
Alex Crichton aec67c2ee0 Revert "std: Re-enable at_exit()"
This reverts commit 9e224c2bf1.

Conflicts:
	src/libstd/sys/windows/os.rs
2014-12-31 10:20:31 -08:00
Alex Crichton 582cba183f Test fixes and rebase conflicts 2014-12-31 08:33:13 -08:00
Alex Crichton 67d13883f8 rollup merge of #20061: aturon/stab-2-vec-slice
Conflicts:
	src/libcollections/slice.rs
	src/libcollections/vec.rs
	src/libstd/sys/windows/os.rs
2014-12-30 18:51:51 -08:00
Aaron Turon 6abfac083f Fallout from stabilization 2014-12-30 17:06:08 -08:00
Alex Crichton dd0f29ad0f rollup merge of #20353: alexcrichton/snapshots 2014-12-30 16:26:24 -08:00
Alex Crichton 38f9805f11 rollup merge of #20348: frewsxcv/rm-reexports
Part of #19253

[breaking-change]
2014-12-30 16:26:22 -08:00
Alex Crichton ecf48fb469 rollup merge of #20329: vhbit/ios-rand-fix 2014-12-30 16:26:16 -08:00
Alex Crichton a8820f7a2d rollup merge of #20328: huonw/attack-of-the-clones
It's useful to be able to save state.
2014-12-30 16:26:15 -08:00
Alex Crichton d1a19e8303 rollup merge of #20321: epall/patch-1
In f436f9ca2, the Send and Sync traits became `unsafe`. They were updated for `target_arch = x86` and others, but `mips` was missed.
2014-12-30 16:26:08 -08:00
Alex Crichton b936fb3d16 rollup merge of #20286: murarth/get-address-name 2014-12-30 16:26:02 -08:00
Alex Crichton 836bcb6ef4 rollup merge of #20065: aturon/stab-2-cmp
This patch marks `PartialEq`, `Eq`, `PartialOrd`, and `Ord` as
`#[stable]`, as well as the majorify of manual implementaitons of these
traits. The traits match the [reform RFC](https://github.com/rust-lang/rfcs/pull/439).

In the future, many of the impls should be generalized; see #20063.
However, there is no problem stabilizing the less general impls, since
generalizing later is not a breaking change.

r? @alexcrichton
2014-12-30 16:25:47 -08:00
Alex Crichton 262c1efe63 Register new snapshots 2014-12-30 15:04:43 -08:00
Aaron Turon b94bcbf56e Stabilize cmp
This patch marks `PartialEq`, `Eq`, `PartialOrd`, and `Ord` as
`#[stable]`, as well as the majorify of manual implementaitons of these
traits. The traits match the [reform
RFC](https://github.com/rust-lang/rfcs/pull/439).

Along the way, two changes are made:

* The recently-added type parameters for `Ord` and `Eq` are
  removed. These were mistakenly added while adding them to `PartialOrd`
  and `PartialEq`, but they don't make sense given the laws that are
  required for (and use cases for) `Ord` and `Eq`.

* More explicit laws are added for `PartialEq` and `PartialOrd`,
  connecting them to their associated mathematical concepts.

In the future, many of the impls should be generalized; see
since generalizing later is not a breaking change.

[breaking-change]
2014-12-30 14:44:26 -08:00
Alex Crichton 9e224c2bf1 std: Re-enable at_exit()
The new semantics of this function are that the callbacks are run when the *main
thread* exits, not when all threads have exited. This implies that other threads
may still be running when the `at_exit` callbacks are invoked and users need to
be prepared for this situation.

Users in the standard library have been audited in accordance to these new rules
as well.

Closes #20012
2014-12-30 14:33:59 -08:00
Aaron Turon e91d810b9b Libs: Unify concat and concat_vec
We've long had traits `StrVector` and `VectorVector` providing
`concat`/`connect` and `concat_vec`/`connect_vec` respectively. The
reason for the distinction is that coherence rules did not used to be
robust enough to allow impls on e.g. `Vec<String>` versus `Vec<&[T]>`.

This commit consolidates the traits into a single `SliceConcatExt` trait
provided by `slice` and the preldue (where it replaces `StrVector`,
which is removed.)

[breaking-change]
2014-12-30 12:02:22 -08:00
Aaron Turon 9d919d2302 Second pass stabilization: vec
This commit takes a second pass through the `vec` module to
stabilize its API. The changes are as follows:

**Stable**:

* `dedup`
* `from_raw_parts`
* `insert`
* `into_iter`
* `is_empty`
* `remove`
* `reserve_exact`
* `reserve`
* `retain`
* `swap_remove`
* `truncate`

**Deprecated**:

* `from_fn`, `from_elem`, `grow_fn` and `grow`, all deprecated in
  favor of iterators. See https://github.com/rust-lang/rfcs/pull/509

* `partition`, `partitioned`, deprecated in favor of a new, more
  general iterator consumer called `partition`.

* `unzip`, deprecated in favor of a new, more general iterator
  consumer called `unzip`.

A few remaining methods are left at experimental status.

[breaking-change]
2014-12-30 12:02:22 -08:00
Aaron Turon 8a5057af2e std::iter: Add partition and unzip methods to iterators 2014-12-30 12:02:21 -08:00
Corey Farwell 1d26fb9e07 Remove core::atomic::Ordering::* public reexport
Part of #19253

[breaking-change]
2014-12-30 11:43:51 -08:00
Valerii Hiora c3ff80399b iOS: fallout of Sync oibit 2014-12-30 14:57:03 +02:00
Huon Wilson b7832ed0b4 Implement `Clone` for a large number of iterators & other adaptors.
It's useful to be able to save state.
2014-12-30 21:01:36 +11:00
Alex Crichton 470ae101d6 Test fixes and rebase conflicts 2014-12-29 23:55:49 -08:00
Eric Allen 011b5ca1bd Fix impl of Send and Sync for mips
In f436f9ca2, the Send and Sync traits became `unsafe`. They were updated for `target_arch = x86` and others, but `mips` was missed.
2014-12-29 22:16:53 -05:00
Alex Crichton 79db01a30d rollup merge of #20306: alexcrichton/second-pass-string
This commit performs a second pass over the `std::string` module, performing the
following actions:

* The name `std::string` is now stable.
* The `String::from_utf8` function is now stable after having been altered to
  return a new `FromUtf8Error` structure. The `FromUtf8Error` structure is now
  stable as well as its `into_bytes` and `utf8_error` methods.
* The `String::from_utf8_lossy` function is now stable.
* The `String::from_chars` method is now deprecated in favor of `.collect()`
* The `String::from_raw_parts` method is now stable
* The `String::from_str` function remains experimental
* The `String::from_raw_buf` function remains experimental
* The `String::from_raw_buf_len` function remains experimental
* The `String::from_utf8_unchecked` function is now stable
* The `String::from_char` function is now deprecated in favor of
  `repeat(c).take(n).collect()`
* The `String::grow` function is now deprecated in favor of
  `.extend(repeat(c).take(n)`
* The `String::capacity` method is now stable
* The `String::reserve` method is now stable
* The `String::reserve_exact` method is now stable
* The `String::shrink_to_fit` method is now stable
* The `String::pop` method is now stable
* The `String::as_mut_vec` method is now stable
* The `String::is_empty` method is now stable
* The `IntoString` trait is now deprecated (there are no implementors)
* The `String::truncate` method is now stable
* The `String::insert` method is now stable
* The `String::remove` method is now stable
* The `String::push` method is now stable
* The `String::push_str` method is now stable
* The `String::from_utf16` function is now stable after its error type has now
  become an opaque structure to carry more semantic information in the future.

A number of these changes are breaking changes, but the migrations should be
fairly straightforward on a case-by-case basis (outlined above where possible).

[breaking-change]
2014-12-29 16:36:52 -08:00
Alex Crichton 806cb35f4d rollup merge of #20289: nick29581/shadowing
r? eddyb
2014-12-29 16:36:49 -08:00
Alex Crichton b1dec37561 rollup merge of #20265: nicholasbishop/bishop_add_missing_bitflags_methods
The methods `from_bits` and `from_bits_truncate` were missing from the
list of generated methods. Didn't see a useful way to abbreviate, so
added with the same docstrings used in the macro definition.
2014-12-29 16:36:30 -08:00
Alex Crichton 9cbbfee8a4 rollup merge of #20264: nagisa/threadrng
Since runtime is removed, rust has no tasks anymore and everything is moving
from being task-* to thread-*. Let’s rename TaskRng as well!

This is a breaking change. If a breaking change for consistency is not desired, feel free to close.
2014-12-29 16:36:29 -08:00
Alex Crichton 6b473b2e05 rollup merge of #20262: arturoc/fix-scoped_thread_local
was missing a couple of semicolons and applications using it failed to compile
2014-12-29 16:36:25 -08:00
Alex Crichton 1c61e74518 rollup merge of #20250: ipetkov/deriving
* Both enums already derived `Copy`, but storing them in any
  struct/container would prevent implementing `Clone` for said
  struct/container even though they should be clonable.
* Also add PartialEq and Eq for good measure.
2014-12-29 16:36:22 -08:00
Alex Crichton 4717f07989 rollup merge of #20248: steveklabnik/gh20038
A part of #20038

This is just the beginning of what needs to be done, but it's some of it.

/cc @aturon
2014-12-29 16:36:20 -08:00
Alex Crichton 3801c2678f rollup merge of #20231: fhahn/issue-20226-eexist
I've created a patch for #20226, which maps `EEXIST` to the `PathAlreadyExists` error on Unix. To test this, I use `mkdir`, which raises `EEXIST` if the directory already exists.

On Windows, I map `ERROR_ALREADY_EXISTS` to `PathAlreadyExist`, but I am note sure if `mkdir` on Windows raises `ERROR_ALREADY_EXISTS` and do not have a Windows installation handy for testing.

And I noticed another thing. No error seems to map to `IoErrorKind::PathDoesntExist` and I am wondering what the difference to `FileNotFound` is?
2014-12-29 16:36:12 -08:00
Alex Crichton 0d95b41148 rollup merge of #20223: aochagavia/typo 2014-12-29 16:36:09 -08:00
Alex Crichton 0fbd1e2496 rollup merge of #20216: sfackler/fix-mangling
Closes #20209

r? @alexcrichton
2014-12-29 16:36:07 -08:00
Alex Crichton 748440c5b3 rollup merge of #20215: csouth3/hashmap-rename
Rename struct `Entries` to `Iter` in hash/table.rs and hash/map.rs, to match the naming convention of rust-lang/rfcs#344.

This is a [breaking-change].
2014-12-29 16:36:06 -08:00
Alex Crichton 9f6eb29a9d rollup merge of #20214: bluss/fix-hashmap-example
The example derived Hash + Eq on a type that was used as *values* for
a hashmap.. for the example to make sense, we have to use a custom *key*
type.

Write a slightly more involved example, still using Vikings, but this
time as key.

I preferred using String over &str here, since that's the typical usage
and we might want to lead users down that path.
2014-12-29 16:36:05 -08:00
Alex Crichton dbc8440821 rollup merge of #20160: nick29581/ranges2
The first six commits are from an earlier PR (#19858) and have already been reviewed. This PR makes an awful hack in the compiler to accommodate slices both natively and in the index a range form. After a snapshot we can hopefully add the new Index impls and then we can remove these awful hacks.

r? @nikomatsakis (or anyone who knows the compiler, really)
2014-12-29 16:35:53 -08:00
Alex Crichton 52315a97c6 rollup merge of #20042: alexcrichton/second-pass-ptr
This commit performs a second pass for stabilization over the `std::ptr` module.
The specific actions taken were:

* The `RawPtr` trait was renamed to `PtrExt`
* The `RawMutPtr` trait was renamed to `PtrMutExt`
* The module name `ptr` is now stable.
* These functions were all marked `#[stable]` with no modification:
  * `null`
  * `null_mut`
  * `swap`
  * `replace`
  * `read`
  * `write`
  * `PtrExt::is_null`
  * `PtrExt::is_not_null`
  * `PtrExt::offset`
* These functions remain unstable:
  * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive
                         as null isn't the only bad value, and it's unclear
                         whether we want to commit to these functions at this
                         time. The reference/lifetime semantics as written are
                         also problematic in how they encourage arbitrary
                         lifetimes.
  * `zero_memory` - This function is currently not used at all in the
                    distribution, and in general it plays a broader role in the
                    "working with unsafe pointers" story. This story is not yet
                    fully developed, so at this time the function remains
                    unstable for now.
  * `read_and_zero` - This function remains unstable for largely the same
                      reasons as `zero_memory`.
* These functions are now all deprecated:
  * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead.
  * `PtrExt::to_uint` - use an `as` expression instead.
2014-12-29 16:35:51 -08:00
Alex Crichton cc20d6009e rollup merge of #19661: alexcrichton/mutex-result
All of the current std::sync primitives have poisoning enable which means that
when a task fails inside of a write-access lock then all future attempts to
acquire the lock will fail. This strategy ensures that stale data whose
invariants are possibly not upheld are never viewed by other tasks to help
propagate unexpected panics (bugs in a program) among tasks.

Currently there is no way to test whether a mutex or rwlock is poisoned. One
method would be to duplicate all the methods with a sister foo_catch function,
for example. This pattern is, however, against our [error guidelines][errors].
As a result, this commit exposes the fact that a task has failed internally
through the return value of a `Result`.

[errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

All methods now return a `LockResult<T>` or a `TryLockResult<T>` which
communicates whether the lock was poisoned or not. In a `LockResult`, both the
`Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in
order to allow access to the data if poisoning is not desired. This also means
that the lock is *always* held upon returning from `.lock()`.

A new type, `PoisonError`, was added with one method `into_guard` which can
consume the assertion that a lock is poisoned to gain access to the underlying
data.

This is a breaking change because the signatures of these methods have changed,
often incompatible ways. One major difference is that the `wait` methods on a
condition variable now consume the guard and return it in as a `LockResult` to
indicate whether the lock was poisoned while waiting. Most code can be updated
by calling `.unwrap()` on the return value of `.lock()`.

[breaking-change]
2014-12-29 16:35:50 -08:00
Nick Cameron 3bf405682d Fallout from mut slices 2014-12-30 13:06:25 +13:00
Alex Crichton 54452cdd68 std: Second pass stabilization for `ptr`
This commit performs a second pass for stabilization over the `std::ptr` module.
The specific actions taken were:

* The `RawPtr` trait was renamed to `PtrExt`
* The `RawMutPtr` trait was renamed to `MutPtrExt`
* The module name `ptr` is now stable.
* These functions were all marked `#[stable]` with no modification:
  * `null`
  * `null_mut`
  * `swap`
  * `replace`
  * `read`
  * `write`
  * `PtrExt::is_null`
  * `PtrExt::offset`
* These functions remain unstable:
  * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive
                         as null isn't the only bad value, and it's unclear
                         whether we want to commit to these functions at this
                         time. The reference/lifetime semantics as written are
                         also problematic in how they encourage arbitrary
                         lifetimes.
  * `zero_memory` - This function is currently not used at all in the
                    distribution, and in general it plays a broader role in the
                    "working with unsafe pointers" story. This story is not yet
                    fully developed, so at this time the function remains
                    unstable for now.
  * `read_and_zero` - This function remains unstable for largely the same
                      reasons as `zero_memory`.
* These functions are now all deprecated:
  * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead.
  * `PtrExt::to_uint` - use an `as` expression instead.
  * `PtrExt::is_not_null` - use `!p.is_null()` instead.
2014-12-29 15:57:28 -08:00
Alex Crichton 35e63e3827 std: Stabilization pass for mutex/rwlock/condvar
This commit performs a stabilization pass over the sync::{mutex, rwlock,
condvar} modules, marking the following items as stable:

* Mutex
* Mutex::new
* Mutex::lock
* Mutex::try_lock
* MutexGuard
* RWLock
* RWLock::new
* RWLock::read
* RWLock::try_read
* RWLock::write
* RWLock::try_write
* RWLockReadGuard
* RWLockWriteGuard
* Condvar
* Condvar::new
* Condvar::wait
* Condvar::notify_one
* Condvar::notify_all
* PoisonError
* TryLockError
* TryLockError::Poisoned
* TryLockError::WouldBlock
* LockResult
* TryLockResult

The following items remain unstable to explore future possibilities of unifying
the static/non-static variants of the types:

* StaticMutex
* StaticMutex::new
* StaticMutex::lock
* StaticMutex::try_lock
* StaticMutex::desroy
* StaticRWLock
* StaticRWLock::new
* StaticRWLock::read
* StaticRWLock::try_read
* StaticRWLock::write
* StaticRWLock::try_write
* StaticRWLock::destroy

The following items were removed in favor of `Guard<'static, ()>` instead.

* StaticMutexGuard
* StaticRWLockReadGuard
* StaticRWLockWriteGuard
2014-12-29 14:41:30 -08:00
Alex Crichton b26daf3a67 std: Second pass stabilization for `string`
This commit performs a second pass over the `std::string` module, performing the
following actions:

* The name `std::string` is now stable.
* The `String::from_utf8` function is now stable after having been altered to
  return a new `FromUtf8Error` structure. The `FromUtf8Error` structure is now
  stable as well as its `into_bytes` and `utf8_error` methods.
* The `String::from_utf8_lossy` function is now stable.
* The `String::from_chars` method is now deprecated in favor of `.collect()`
* The `String::from_raw_parts` method is now stable
* The `String::from_str` function remains experimental
* The `String::from_raw_buf` function remains experimental
* The `String::from_raw_buf_len` function remains experimental
* The `String::from_utf8_unchecked` function is now stable
* The `String::from_char` function is now deprecated in favor of
  `repeat(c).take(n).collect()`
* The `String::grow` function is now deprecated in favor of
  `.extend(repeat(c).take(n)`
* The `String::capacity` method is now stable
* The `String::reserve` method is now stable
* The `String::reserve_exact` method is now stable
* The `String::shrink_to_fit` method is now stable
* The `String::pop` method is now stable
* The `String::as_mut_vec` method is now stable
* The `String::is_empty` method is now stable
* The `IntoString` trait is now deprecated (there are no implementors)
* The `String::truncate` method is now stable
* The `String::insert` method is now stable
* The `String::remove` method is now stable
* The `String::push` method is now stable
* The `String::push_str` method is now stable
* The `String::from_utf16` function is now stable after its error type has now
  become an opaque structure to carry more semantic information in the future.

A number of these changes are breaking changes, but the migrations should be
fairly straightforward on a case-by-case basis (outlined above where possible).

[breaking-change]
2014-12-29 14:11:16 -08:00
Alex Crichton bc83a009f6 std: Second pass stabilization for `comm`
This commit is a second pass stabilization for the `std::comm` module,
performing the following actions:

* The entire `std::comm` module was moved under `std::sync::mpsc`. This movement
  reflects that channels are just yet another synchronization primitive, and
  they don't necessarily deserve a special place outside of the other
  concurrency primitives that the standard library offers.
* The `send` and `recv` methods have all been removed.
* The `send_opt` and `recv_opt` methods have been renamed to `send` and `recv`.
  This means that all send/receive operations return a `Result` now indicating
  whether the operation was successful or not.
* The error type of `send` is now a `SendError` to implement a custom error
  message and allow for `unwrap()`. The error type contains an `into_inner`
  method to extract the value.
* The error type of `recv` is now `RecvError` for the same reasons as `send`.
* The `TryRecvError` and `TrySendError` types have had public reexports removed
  of their variants and the variant names have been tweaked with enum
  namespacing rules.
* The `Messages` iterator is renamed to `Iter`

This functionality is now all `#[stable]`:

* `Sender`
* `SyncSender`
* `Receiver`
* `std::sync::mpsc`
* `channel`
* `sync_channel`
* `Iter`
* `Sender::send`
* `Sender::clone`
* `SyncSender::send`
* `SyncSender::try_send`
* `SyncSender::clone`
* `Receiver::recv`
* `Receiver::try_recv`
* `Receiver::iter`
* `SendError`
* `RecvError`
* `TrySendError::{mod, Full, Disconnected}`
* `TryRecvError::{mod, Empty, Disconnected}`
* `SendError::into_inner`
* `TrySendError::into_inner`

This is a breaking change due to the modification of where this module is
located, as well as the changing of the semantics of `send` and `recv`. Most
programs just need to rename imports of `std::comm` to `std::sync::mpsc` and
add calls to `unwrap` after a send or a receive operation.

[breaking-change]
2014-12-29 12:16:49 -08:00
bors 19f73b4ef6 auto merge of #20058 : Kimundi/rust/str_pattern_pre, r=alexcrichton
This stabilizes most methods on `&str` working with patterns in a way that is forwards-compatible with a generic string pattern matching API:
- Methods that are using the primary name for their operation are marked as `#[stable]`, as they can be upgraded to a full `Pattern` API later without existing code breaking. Example: `contains(&str)`
- Methods that are using a more specific name in order to not clash with the primary one are marked as `#[unstable]`, as they will likely be removed once their functionality is merged into the primary one. Example: `contains_char<C: CharEq>(C)`
- The method docs got changed to consistently refer to the pattern types as a pattern.
- Methods whose names do not match in the context of the more generic API got renamed. Example: `trim_chars -> trim_matches` 

Additionally, all methods returning iterators got changed to return unique new types with changed names in accordance with the new naming guidelines.

See also https://github.com/rust-lang/rfcs/pull/528

Due to some deprecations and type changes, this is a 

[breaking-change]
2014-12-29 18:02:30 +00:00
Alex Crichton 76e5ed655c std: Return Result from RWLock/Mutex methods
All of the current std::sync primitives have poisoning enable which means that
when a task fails inside of a write-access lock then all future attempts to
acquire the lock will fail. This strategy ensures that stale data whose
invariants are possibly not upheld are never viewed by other tasks to help
propagate unexpected panics (bugs in a program) among tasks.

Currently there is no way to test whether a mutex or rwlock is poisoned. One
method would be to duplicate all the methods with a sister foo_catch function,
for example. This pattern is, however, against our [error guidelines][errors].
As a result, this commit exposes the fact that a task has failed internally
through the return value of a `Result`.

[errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

All methods now return a `LockResult<T>` or a `TryLockResult<T>` which
communicates whether the lock was poisoned or not. In a `LockResult`, both the
`Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in
order to allow access to the data if poisoning is not desired. This also means
that the lock is *always* held upon returning from `.lock()`.

A new type, `PoisonError`, was added with one method `into_guard` which can
consume the assertion that a lock is poisoned to gain access to the underlying
data.

This is a breaking change because the signatures of these methods have changed,
often incompatible ways. One major difference is that the `wait` methods on a
condition variable now consume the guard and return it in as a `LockResult` to
indicate whether the lock was poisoned while waiting. Most code can be updated
by calling `.unwrap()` on the return value of `.lock()`.

[breaking-change]
2014-12-29 09:18:09 -08:00
Alex Crichton c32d03f417 std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization
story for the prelude. Most of the RFC was directly applied, removing reexports.
Some reexports are kept around, however:

* `range` remains until range syntax has landed to reduce churn.
* `Path` and `GenericPath` remain until path reform lands. This is done to
  prevent many imports of `GenericPath` which will soon be removed.
* All `io` traits remain until I/O reform lands so imports can be rewritten all
  at once to `std::io::prelude::*`.

This is a breaking change because many prelude reexports have been removed, and
the RFC can be consulted for the exact list of removed reexports, as well as to
find the locations of where to import them.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md
[breaking-change]

Closes #20068
2014-12-29 08:58:21 -08:00
Nick Cameron ac095351fb Fallout from globs/re-export/shadowing change 2014-12-29 19:10:08 +13:00
Nick Cameron 9c1567e622 Fallout from glob shadowing 2014-12-29 18:20:38 +13:00
Murarth e6c8b8f480 Added `get_address_name`, an interface to `getnameinfo` 2014-12-28 15:45:43 -07:00
arturo a4549972f2 src/libstd/thread_local/scoped.rs: fixes scoped_thread_local! macro
was missing a ;
2014-12-28 19:43:04 +01:00
Simonas Kazlauskas 1e89bbcb67 Rename TaskRng to ThreadRng
Since runtime is removed, rust has no tasks anymore and everything is moving
from being task-* to thread-*. Let’s rename TaskRng as well!

* Rename TaskRng to ThreadRng
* Rename task_rng to thread_rng

[breaking-change]
2014-12-28 13:46:35 +02:00
bors 3e6b29f8ad auto merge of #20136 : eddyb/rust/format-args, r=alexcrichton
We have the technology: no longer do you need to write closures to use `format_args!`.
This is a `[breaking-change]`, as it forces you to clean up old hacks - if you had code like this:
```rust
format_args!(fmt::format, "{} {} {}", a, b, c)
format_args!(|args| { w.write_fmt(args) }, "{} {} {}", x, y, z)
```
change it to this: 
```rust
fmt::format(format_args!("{} {} {}", a, b, c))
w.write_fmt(format_args!("{} {} {}", x, y, z))
```
To allow them to be called with `format_args!(...)` directly, several functions were modified to
take `fmt::Arguments` by value instead of by reference. Also, `fmt::Arguments` derives `Copy`
now in order to preserve all usecases that were previously possible.
2014-12-28 03:11:48 +00:00
Nicholas Bishop ad39c0a8a1 Update docstring for bitflags macro to cover all generated methods
The methods `from_bits` and `from_bits_truncate` were missing from the
list of generated methods. Didn't see a useful way to abbreviate, so
added with the same docstrings used in the macro definition.
2014-12-27 20:13:32 -05:00
Eduard Burtescu 647e54d6d1 Fallout of changing format_args!(f, args) to f(format_args!(args)). 2014-12-27 23:57:43 +02:00
bors 070ab63807 auto merge of #19916 : SimonSapin/rust/ascii-reform, r=sfackler
Implements [RFC 486](https://github.com/rust-lang/rfcs/pull/486). Fixes #19908.

* Rename `to_ascii_{lower,upper}` to `to_ascii_{lower,upper}case`, per #14401
* Remove the `Ascii` type and associated traits: `AsciiCast`, `OwnedAsciiCast`, `AsciiStr`, `IntoBytes`, and `IntoString`.
* As a replacement, add `.is_ascii()` to `AsciiExt`, and implement `AsciiExt` for `u8` and `char`.

[breaking-change]
2014-12-27 21:51:43 +00:00
bors 4a4c89c7a4 auto merge of #20119 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis
More work on opt-in built in traits. `Send` and `Sync` are not opt-in, `OwnedPtr` renamed to `UniquePtr` and the `Send` and `Sync` traits are now unsafe.

NOTE: This likely needs to be rebased on top of the yet-to-land snapshot.

r? @nikomatsakis 

cc #13231
2014-12-27 13:11:48 +00:00
Flavio Percoco 1a73ccc8db Make trait's impls consistent for unix/windows 2014-12-27 13:00:20 +01:00
Flavio Percoco 11f71ec701 Implement Sync/Send for windows' UnixStream 2014-12-27 12:40:25 +01:00
Nick Cameron 4b92a5a229 Rebasing changes 2014-12-27 12:30:36 +13:00
Flavio Percoco f5d619caf9 Implement Sync/Send for windows TCP types 2014-12-26 23:01:47 +01:00
Steve Klabnik b8ffad5964 s/task/thread/g
A part of #20038
2014-12-26 16:04:27 -05:00
Nick Cameron dbde7419cc Fix fallout 2014-12-27 09:55:25 +13:00
Ivan Petkov 3358e64b8e Derive Clone, PartialEq, and Eq for std::io::{FileAccess, FileMode}
* Both enums already derived `Copy`, but storing them in any
  struct/container would prevent implementing `Clone` for said
  struct/container even though they should be clonable.
* Also add PartialEq and Eq for good measure.
2014-12-26 11:07:24 -08:00
Flavio Percoco bb315f25f8 Implement RaceBox for StdinReader 2014-12-26 17:26:33 +01:00
Flavio Percoco d35ebcb483 Make Barrier and Condvar Sync/Send 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 51d2fefd91 Implement `Sync` for some windows sys types 2014-12-26 17:26:33 +01:00
Flavio Percoco e2116c8fba Move RacyCell to `std::comm`
RacyCell is not exactly what we'd like as a final implementation for
this. Therefore, we're moving it under `std::comm` and also making it
private.
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
Florian Hahn eb4b20288e Map EEXIST to PathAlreadyExists error, closes #20226 2014-12-25 22:22:44 +01:00
Marvin Löbel 72c8f3772b Prepared most `StrExt` pattern using methods for stabilization
Made iterator-returning methods return newtypes
Adjusted some docs to be forwards compatible with a generic pattern API
2014-12-25 17:08:29 +01:00
Adolfo Ochagavía 7fcd2c2691 Fix typo in std::thread comments 2014-12-25 13:38:50 +01:00
Simon Sapin c82e59d774 std::ascii: Use u8 methods rather than the maps directly. 2014-12-25 12:19:37 +01:00
Simon Sapin 3a6ccdc263 Remove Ascii, AsciiCast, OwnedAsciiCast, AsciiStr, IntoBytes, IntoString.
As a replacement, add is_ascii() to AsciiExt, and implement AsciiExt for u8 and char.

[breaking-change]
2014-12-25 12:19:37 +01:00
P1start d9769ec383 Parse fully-qualified associated types in generics without whitespace
This breaks code that looks like this:

    let x = foo as bar << 13;

Change such code to look like this:

    let x = (foo as bar) << 13;

Closes #17362.

[breaking-change]
2014-12-25 18:58:47 +13:00
bors ead198c513 auto merge of #20024 : mneumann/rust/dragonfly-fixes3, r=alexcrichton 2014-12-25 05:11:36 +00:00
Steven Fackler e8b151b791 Fix backtrace demangling
Closes #20209
2014-12-24 21:41:09 -05:00
Chase Southwood 625697354d Rename remaining hashmap and hashtable iterators to match naming
conventions.

This is a [breaking-change].
2014-12-24 20:19:48 -06:00
bluss 1114685696 hashmap: Fix the example using derived Hash + Eq
The example derived Hash + Eq on a type that was used as *values* for
a hashmap.. for the example to make sense, we have to use a custom *key*
type.

Write a slightly more involved example, still using Vikings, but this
time as key.

I preferred using String over &str here, since that's the typical usage
and we might want to lead users down that path.
2014-12-25 02:17:48 +01:00
bors 7e11b22713 auto merge of #20117 : lfairy/rust/rename-include-bin, r=alexcrichton
According to [RFC 344][], methods that return `&[u8]` should have names ending in `bytes`. Though `include_bin!` is a macro not a method, it seems reasonable to follow the convention anyway.

We keep the old name around for now, but trigger a deprecation warning when it is used.

[RFC 344]: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md

[breaking-change]
2014-12-24 20:47:12 +00:00
Simon Sapin 1e5811ef92 Rename to_ascii_{lower,upper} to to_ascii_{lower,upper}case, per #14401
[breaking-change]
2014-12-24 19:33:04 +01:00
Tobias Bucher 16f01cc13f Rename and namespace `FPCategory`
Rename `FPCategory` to `FpCategory` and `Fp* to `*` in order to adhere to the
naming convention

This is a [breaking-change].

Existing code like this:
```
use std::num::{FPCategory, FPNaN};
```
should be adjusted to this:
```
use std::num::FpCategory as Fp
```

In the following code you can use the constants `Fp::Nan`, `Fp::Normal`, etc.
2014-12-23 13:42:09 +01:00
Chris Wong 85c1a4b1ba Rename include_bin! to include_bytes!
According to [RFC 344][], methods that return `&[u8]` should have names
ending in `bytes`. Though `include_bin!` is a macro not a method, it
seems reasonable to follow the convention anyway.

We keep the old name around for now, but trigger a deprecation warning
when it is used.

[RFC 344]: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md

[breaking-change]
2014-12-23 22:06:32 +13:00
Huon Wilson 832c3e3cd7 Fix some spelling errors. 2014-12-23 16:13:15 +11:00
Alex Crichton 3583d613b9 Test fixes and rebase conflicts 2014-12-22 15:17:26 -08:00
Alex Crichton de11710d80 rollup merge of #19891: nikomatsakis/unique-fn-types-3
Conflicts:
	src/libcore/str.rs
	src/librustc_trans/trans/closure.rs
	src/librustc_typeck/collect.rs
	src/libstd/path/posix.rs
	src/libstd/path/windows.rs
2014-12-22 12:51:23 -08:00
Alex Crichton 459f3b2cfa rollup merge of #20056: MrFloya/iter_rename
Conflicts:
	src/libcollections/bit.rs
	src/libcore/str.rs
2014-12-22 12:49:57 -08:00
Alex Crichton 2cc9baccc7 rollup merge of #20125: csouth3/hashset-bitops
Now that #19448 has landed in a snapshot, we can add proper by-value operator overloads for `HashSet`.  The behavior of these operator overloads is consistent with rust-lang/rfcs#235.
2014-12-22 12:48:09 -08:00
Niko Matsakis 8fe9e4dff6 Insert coercions to fn pointer types required for the new types
post-unboxed-closure-conversion. This requires a fair amount of
annoying coercions because all the `map` etc types are defined
generically over the `F`, so the automatic coercions don't propagate;
this is compounded by the need to use `let` and not `as` due to
stage0. That said, this pattern is to a large extent temporary and
unusual.
2014-12-22 12:27:07 -05:00
Niko Matsakis 7f6177e646 Fix fallout from changes. In cases where stage0 compiler is needed, we
cannot use an `as` expression to coerce, so I used a one-off function
instead (this is a no-op in stage0, but in stage1+ it triggers
coercion from the fn pointer to the fn item type).
2014-12-22 12:27:07 -05:00
Florian Wilkens 22050e3ed4 Added missing renames:
libcollections:
    AbsEntries -> AbsIter, Entries -> Iter, MoveEntries -> IntoIter, MutEntries -> IterMut
    DifferenceItems -> Difference, SymDifferenceItems -> SymmetricDifference, IntersectionItems -> Intersection, UnionItems -> Union

libstd/hash/{table, map}:
    Entries -> Iter, MoveItems -> IntoIter, MutEntries -> IterMut

Also a [breaking-change].
2014-12-22 17:45:34 +01:00
Alex Crichton 082bfde412 Fallout of std::str stabilization 2014-12-21 23:31:42 -08:00
Chase Southwood db3989c3db Implement BitOps for HashSet 2014-12-21 22:38:37 -06:00
Alex Crichton 4908017d59 std: Stabilize the std::str module
This commit starts out by consolidating all `str` extension traits into one
`StrExt` trait to be included in the prelude. This means that
`UnicodeStrPrelude`, `StrPrelude`, and `StrAllocating` have all been merged into
one `StrExt` exported by the standard library. Some functionality is currently
duplicated with the `StrExt` present in libcore.

This commit also currently avoids any methods which require any form of pattern
to operate. These functions will be stabilized via a separate RFC.

Next, stability of methods and structures are as follows:

Stable

* from_utf8_unchecked
* CowString - after moving to std::string
* StrExt::as_bytes
* StrExt::as_ptr
* StrExt::bytes/Bytes - also made a struct instead of a typedef
* StrExt::char_indices/CharIndices - CharOffsets was renamed
* StrExt::chars/Chars
* StrExt::is_empty
* StrExt::len
* StrExt::lines/Lines
* StrExt::lines_any/LinesAny
* StrExt::slice_unchecked
* StrExt::trim
* StrExt::trim_left
* StrExt::trim_right
* StrExt::words/Words - also made a struct instead of a typedef

Unstable

* from_utf8 - the error type was changed to a `Result`, but the error type has
              yet to prove itself
* from_c_str - this function will be handled by the c_str RFC
* FromStr - this trait will have an associated error type eventually
* StrExt::escape_default - needs iterators at least, unsure if it should make
                           the cut
* StrExt::escape_unicode - needs iterators at least, unsure if it should make
                           the cut
* StrExt::slice_chars - this function has yet to prove itself
* StrExt::slice_shift_char - awaiting conventions about slicing and shifting
* StrExt::graphemes/Graphemes - this functionality may only be in libunicode
* StrExt::grapheme_indices/GraphemeIndices - this functionality may only be in
                                             libunicode
* StrExt::width - this functionality may only be in libunicode
* StrExt::utf16_units - this functionality may only be in libunicode
* StrExt::nfd_chars - this functionality may only be in libunicode
* StrExt::nfkd_chars - this functionality may only be in libunicode
* StrExt::nfc_chars - this functionality may only be in libunicode
* StrExt::nfkc_chars - this functionality may only be in libunicode
* StrExt::is_char_boundary - naming is uncertain with container conventions
* StrExt::char_range_at - naming is uncertain with container conventions
* StrExt::char_range_at_reverse - naming is uncertain with container conventions
* StrExt::char_at - naming is uncertain with container conventions
* StrExt::char_at_reverse - naming is uncertain with container conventions
* StrVector::concat - this functionality may be replaced with iterators, but
                      it's not certain at this time
* StrVector::connect - as with concat, may be deprecated in favor of iterators

Deprecated

* StrAllocating and UnicodeStrPrelude have been merged into StrExit
* eq_slice - compiler implementation detail
* from_str - use the inherent parse() method
* is_utf8 - call from_utf8 instead
* replace - call the method instead
* truncate_utf16_at_nul - this is an implementation detail of windows and does
                          not need to be exposed.
* utf8_char_width - moved to libunicode
* utf16_items - moved to libunicode
* is_utf16 - moved to libunicode
* Utf16Items - moved to libunicode
* Utf16Item - moved to libunicode
* Utf16Encoder - moved to libunicode
* AnyLines - renamed to LinesAny and made a struct
* SendStr - use CowString<'static> instead
* str::raw - all functionality is deprecated
* StrExt::into_string - call to_string() instead
* StrExt::repeat - use iterators instead
* StrExt::char_len - use .chars().count() instead
* StrExt::is_alphanumeric - use .chars().all(..)
* StrExt::is_whitespace - use .chars().all(..)

Pending deprecation -- while slicing syntax is being worked out, these methods
are all #[unstable]

* Str - while currently used for generic programming, this trait will be
        replaced with one of [], deref coercions, or a generic conversion trait.
* StrExt::slice - use slicing syntax instead
* StrExt::slice_to - use slicing syntax instead
* StrExt::slice_from - use slicing syntax instead
* StrExt::lev_distance - deprecated with no replacement

Awaiting stabilization due to patterns and/or matching

* StrExt::contains
* StrExt::contains_char
* StrExt::split
* StrExt::splitn
* StrExt::split_terminator
* StrExt::rsplitn
* StrExt::match_indices
* StrExt::split_str
* StrExt::starts_with
* StrExt::ends_with
* StrExt::trim_chars
* StrExt::trim_left_chars
* StrExt::trim_right_chars
* StrExt::find
* StrExt::rfind
* StrExt::find_str
* StrExt::subslice_offset
2014-12-21 19:09:55 -08:00
Alex Crichton fb7c08876e Test fixes and rebase conflicts 2014-12-21 13:49:04 -08:00
Alex Crichton dbeef0edb2 rollup merge of #19972: alexcrichton/snapshots
Conflicts:
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/snapshots.txt
2014-12-21 09:28:07 -08:00
Alex Crichton b084cda4e9 rollup merge of #20100: alexcrichton/issue-20091
Instead, just pass everything through as a Vec<u8> to get worried about later.

Closes #20091
2014-12-21 09:27:38 -08:00
Alex Crichton a666105b4c std: Don't parse argv as a String
Instead, just pass everything through as a Vec<u8> to get worried about later.

Closes #20091
2014-12-21 09:27:38 -08:00
Alex Crichton 2135712a82 rollup merge of #20086: shepmaster/random-typo 2014-12-21 09:27:37 -08:00
Alex Crichton 0191dce41d rollup merge of #20077: shepmaster/stdin-typo 2014-12-21 09:27:36 -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 6495c27ee6 rollup merge of #20069: jarod/bitflags
Although using hex literals is not wrong, but I think use binary literals will be better.(especially in examples)
2014-12-21 09:27:36 -08:00
Alex Crichton f6a7388210 rollup merge of #20062: aturon/stab-2-ints
This small patch stabilizes the names of all integer modules (including
`int` and `uint`) and the `MIN` and `MAX` constants. The `BITS` and
`BYTES` constants are left unstable for now.

r? @alexcrichton
2014-12-21 09:27:35 -08:00
Alex Crichton cfc815bef4 rollup merge of #20029: vhbit/ios-no-rt 2014-12-21 09:27:34 -08:00
Alex Crichton fc40812b0f rollup merge of #20006: alexcrichton/no-more-empty-modules
This commit modifies rustdoc to not require these empty modules to be public in
the standard library. The modules still remain as a location to attach
documentation to, but the modules themselves are now private (don't have to
commit to an API). The documentation for the standard library now shows all of
the primitive types on the main index page.
2014-12-21 09:27:33 -08:00
Alex Crichton 91b3232764 rollup merge of #19993: bluss/setalgebraitems
This removes the type SetAlgebraItems and replaces it with the
structs Intersection and Difference.

Rename the existing HashSet iterators according to RFC #344:

* SetItems -> Iter
* SetMoveItems -> IntoIter
* Remaining set combination iterators renamed to Union and SymmetricDifference
2014-12-21 09:27:31 -08:00
Alex Crichton 31800b38e6 rollup merge of #19973: vhbit/ios-no-copy 2014-12-21 09:26:43 -08:00
Alex Crichton 264088c1ee rollup merge of #19932: elszben/master
First attempt to contribute to rust (and using github). This commit adds a few examples to std::io::TempDir. The examples seem to look okay (in my browser) and make check also passes.
2014-12-21 09:26:42 -08:00
Corey Farwell 98af642f5c Remove a ton of public reexports
Remove most of the public reexports mentioned in #19253

These are all leftovers from the enum namespacing transition

In particular:

* src/libstd/num/strconv.rs
 * ExponentFormat
 * SignificantDigits
 * SignFormat
* src/libstd/path/windows.rs
 * PathPrefix
* src/libstd/sys/windows/timer.rs
 * Req
* src/libcollections/str.rs
 * MaybeOwned
* src/libstd/collections/hash/map.rs
 * Entry
* src/libstd/collections/hash/table.rs
 * BucketState
* src/libstd/dynamic_lib.rs
 * Rtld
* src/libstd/io/net/ip.rs
 * IpAddr
* src/libstd/os.rs
 * MemoryMapKind
 * MapOption
 * MapError
* src/libstd/sys/common/net.rs
 * SocketStatus
 * InAddr
* src/libstd/sys/unix/timer.rs
 * Req

[breaking-change]
2014-12-21 09:26:41 -08:00
bors ce468e643a auto merge of #19946 : cgaebel/rust/hashmap-drain-iter, r=gankro
It is useful to move all the elements out of a hashmap without deallocating
the underlying buffer. It came up in IRC, and this patch implements it as
`drain`.

r? @Gankro
cc: @frankmcsherry
2014-12-21 07:22:45 +00:00
Jake Goulding bffd802a3f Fix small typos in std::rand documentation 2014-12-20 17:13:13 -05:00
Jake Goulding b4a065a3a0 Correct typo in doc for StdinReaderGuard 2014-12-20 11:08:51 -05: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
Jarod Liu a7f1ce37bf use binary literals to better reflect "bitflags" 2014-12-20 16:07:03 +08:00
Aaron Turon 89f75a6e81 Stabilize integer modules
This small patch stabilizes the names of all integer modules (including
`int` and `uint`) and the `MIN` and `MAX` constants. The `BITS` and
`BYTES` constants are left unstable for now.
2014-12-19 22:28:12 -08:00
Eduard Burtescu b45d30da34 Fix fallout of removing import_shadowing in tests. 2014-12-20 07:49:37 +02:00
Eduard Burtescu f95e0c21aa Fix more import_shadowing fallout in collections. 2014-12-20 07:49:37 +02:00
Eduard Burtescu 5193d542f6 Fix the fallout of removing feature(import_shadowing). 2014-12-20 07:49:37 +02:00
Eduard Burtescu d5267d5845 Remove feature(import_shadowing) from all crates. 2014-12-20 06:37:14 +02:00
bors 1c2df5cc3c auto merge of #19640 : aliblong/rust/power_of_two_reform, r=Gankro
The `is_power_of_two()` method of the `UnsignedInt` trait currently returns `true` for `self == 0`. Zero is not a power of two, assuming an integral exponent `k >= 0`. I've therefore moved this functionality to the new method `is_power_of_two_or_zero()` and reformed `is_power_of_two()` to return false for `self == 0`.

To illustrate the usefulness of the existence of both functions, consider `HashMap`. Its capacity must be zero or a power of two; conversely, it also requires a (non-zero) power of two for key and val alignment.

Also, added a small amount of documentation regarding #18604.
2014-12-20 01:12:19 +00:00
Aaron Liblong f6328b60da Reform power_of_two methods for perf increase & semantic change to consider 0 not a power of 2.
Vec panics when attempting to reserve capacity > int::MAX (uint::MAX / 2).
2014-12-19 18:21:24 -05:00
Michael Neumann 4c3a8f17cc load_self() needs to be public 2014-12-19 22:19:37 +01:00
bluss cf350ea5eb hashset: Clean up and rename the HashSet iterators
This removes the type SetAlgebraItems and replaces it with the
structs Intersection and Difference.

Rename the existing HashSet iterators according to RFC #344:

* SetItems -> Iter
* SetMoveItems -> IntoIter
* Remaining set combination iterators renamed to Union and SymmetricDifference

[breaking-change]
2014-12-19 21:54:50 +01:00
Alex Crichton 84086c464f Register new snapshots
This does not yet start the movement to rustc-serialize. That detail is left to
a future PR.
2014-12-19 08:58:10 -08:00
Jorge Aparicio f975b10310 windows: remove unused import 2014-12-19 10:51:01 -05:00
Jorge Aparicio a77e8a63d5 libstd: use `#[deriving(Copy)]` 2014-12-19 10:51:00 -05:00
Jorge Aparicio 1d25271e05 librustrt: use `#[deriving(Copy)]` 2014-12-19 10:51:00 -05:00
Valerii Hiora e5d8c85507 iOS: fallout of runtime removal 2014-12-19 16:34:01 +02:00
Michael Neumann 25c1bfe175 Several fixes for DragonFly (rebase) 2014-12-19 13:05:06 +01:00
bors 0efafac398 auto merge of #19654 : aturon/rust/merge-rt, r=alexcrichton
This PR substantially narrows the notion of a "runtime" in Rust, and allows calling into Rust code directly without any setup or teardown. 

After this PR, the basic "runtime support" in Rust will consist of:

* Unwinding and backtrace support
* Stack guards

Other support, such as helper threads for timers or the notion of a "current thread" are initialized automatically upon first use.

When using Rust in an embedded context, it should now be possible to call a Rust function directly as a C function with absolutely no setup, though in that case panics will cause the process to abort. In this regard, the C/Rust interface will look much like the C/C++ interface.

In more detail, this PR:

* Merges `librustrt` back into `std::rt`, undoing the facade. While doing so, it removes a substantial amount of redundant functionality (such as mutexes defined in the `rt` module). Code using `librustrt` can now call into `std::rt` to e.g. start executing Rust code with unwinding support.

* Allows all runtime data to be initialized lazily, including the "current thread", the "at_exit" infrastructure, and the "args" storage.

* Deprecates and largely removes `std::task` along with the widespread requirement that there be a "current task" for many APIs in `std`. The entire task infrastructure is replaced with `std::thread`, which provides a more standard API for manipulating and creating native OS threads. In particular, it's possible to join on a created thread, and to get a handle to the currently-running thread. In addition, threads are equipped with some basic blocking support in the form of `park`/`unpark` operations (following a tradition in some OSes as well as the JVM). See the `std::thread` documentation for more details.

* Channels are refactored to use a new internal blocking infrastructure that itself sits on top of `park`/`unpark`.

One important change here is that a Rust program ends when its main thread does, following most threading models. On the other hand, threads will often be created with an RAII-style join handle that will re-institute blocking semantics naturally (and with finer control).

This is very much a:

[breaking-change]

Closes #18000
r? @alexcrichton
2014-12-19 08:28:52 +00:00
Aaron Turon 903c5a8f69 Disable at_exit handlers
The [final step](https://github.com/rust-lang/rust/pull/19654) of
runtime removal changes the threading/process model so that the process
shuts down when the main thread exits. But several shared resources,
like the helper thread for timeouts, are shut down when the main thread
exits (but before the process ends), and they are not prepared to be
used after shut down, but other threads may try to access them during
the shutdown sequence of the main thread.

As an interim solution, the `at_exit` cleanup routine is simply skipped.

Ultimately, these resources should be made to safely handle asynchronous
shutdown, usually by panicking if called from a detached thread when the
main thread is ending.

See issue for details https://github.com/rust-lang/rust/issues/20012

This is a [breaking-change] for anyone relying on `at_exit`.
2014-12-18 23:35:53 -08:00
Aaron Turon a9e7669cdc Rebasing fixes. 2014-12-18 23:35:53 -08:00
Aaron Turon 0ce5faaa7b Delete rest of rustrt
... and address other rebasing fallout.
2014-12-18 23:35:52 -08:00
Alex Crichton d08600b189 std: Move the panic flag to its own thread local
This flag is somewhat tied to the `unwind` module rather than the `thread_info`
module, so this commit moves it into that module as well as allowing the same OS
thread to call `unwind::try` multiple times. Previously once a thread panicked
its panic flag was never reset, even after exiting the panic handler.
2014-12-18 23:35:52 -08:00
Alex Crichton 5759cff48e std: Lower abstractions for thread_local/at_exit
The current implementations use `std::sync` primitives, but these primitives
currently end up relying on `thread_info` and a local `Thread` being available
(mainly for checking the panicking flag).

To get around this, this commit lowers the abstractions used by the windows
thread_local implementation as well as the at_exit_imp module. Both of these
modules now use a `sys::Mutex` and a `static mut` and manage the
allocation/locking manually.
2014-12-18 23:35:52 -08: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
Aaron Turon 13f302d0c5 Update doc comment for std::rt 2014-12-18 23:31:52 -08:00
Alex Crichton 4ffd9f49c3 Avoid .take().unwrap() with FnOnce closures 2014-12-18 23:31:52 -08:00
Alex Crichton a7061d02e1 Tweak the startup routine to pass on linux
We need to be sure to init thread_info before we init args for example because
args is grabbing locks which may entail looking at the local thread eventually.
2014-12-18 23:31:52 -08:00
Alex Crichton 7a6c54c46e Fix compilation on linux 2014-12-18 23:31:52 -08:00
Alex Crichton 9644d60cc4 Fix the capture_stderr test
There's always a fun time having two sets of standard libraries when testing!
2014-12-18 23:31:52 -08:00
Aaron Turon ced2239852 Disable capture_stderr test for now 2014-12-18 23:31:51 -08:00
Aaron Turon 43ae4b3301 Fallout from new thread API 2014-12-18 23:31:51 -08:00
Aaron Turon 14c1a103bc Revise rt::unwind 2014-12-18 23:31:51 -08:00
Aaron Turon d8e4780b0b Remove rt::{mutex, exclusive} 2014-12-18 23:31:51 -08:00
Aaron Turon 7fd7ce682d Add blocking support module for channels 2014-12-18 23:31:51 -08:00
Aaron Turon 84cb6cd938 Remove rt::{local, local_data, thread_local_storage} 2014-12-18 23:31:51 -08:00
Aaron Turon cac133c9a8 Introduce std::thread
Also removes:

* `std::task`
* `std::rt::task`
* `std::rt::thread`

Notes for the new API are in a follow-up commit.

Closes #18000
2014-12-18 23:31:35 -08:00
Aaron Turon 9b03b72d7f Remove rt::bookkeeping
This commit removes the runtime bookkeeping previously used to ensure
that all Rust tasks were joined before the runtime was shut down.

This functionality will be replaced by an RAII style `Thread` API, that
will also offer a detached mode.

Since this changes the semantics of shutdown, it is a:

[breaking-change]
2014-12-18 23:31:35 -08:00
Aaron Turon c009bfdf94 Make at_exit initialize lazily 2014-12-18 23:31:34 -08:00
Aaron Turon b66681cd31 Allow args to work without rt initialization 2014-12-18 23:31:34 -08:00
Aaron Turon 74d0769993 Refactor std::os to use sys::os 2014-12-18 23:31:34 -08:00
Aaron Turon 2b3477d373 libs: merge librustrt into libstd
This commit merges the `rustrt` crate into `std`, undoing part of the
facade. This merger continues the paring down of the runtime system.

Code relying on the public API of `rustrt` will break; some of this API
is now available through `std::rt`, but is likely to change and/or be
removed very soon.

[breaking-change]
2014-12-18 23:31:34 -08:00
bors 6bdce25e15 auto merge of #19899 : japaric/rust/unops-by-value, r=nikomatsakis
- The following operator traits now take their argument by value: `Neg`, `Not`. This breaks all existing implementations of these traits.

- The unary operation `OP a` now "desugars" to `OpTrait::op_method(a)` and consumes its argument.

[breaking-change]

---

r? @nikomatsakis This PR is very similar to the binops-by-value PR
cc @aturon
2014-12-19 06:12:01 +00:00
Clark Gaebel d57f25907b [collections] Adds `drain`: a way to sneak out the elements while clearing.
It is useful to move all the elements out of some collections without
deallocating the underlying buffer. It came up in IRC, and this patch
implements it as `drain`. This has been discussed as part of RFC 509.

r? @Gankro
cc: @frankmcsherry
2014-12-18 22:16:51 -05:00
Alex Crichton 1b42e890bf std: Remove public bool,tuple,unit modules
This commit modifies rustdoc to not require these empty modules to be public in
the standard library. The modules still remain as a location to attach
documentation to, but the modules themselves are now private (don't have to
commit to an API). The documentation for the standard library now shows all of
the primitive types on the main index page.
2014-12-18 19:13:32 -08:00
Alexis Beingessner 6c00f9c5ff remove TreeMap, TreeSet, TrieMap, TrieSet, LruCache. deprecate EnumSet's std re-export 2014-12-18 16:20:31 -05:00
Jorge Aparicio 5f347d7708 libstd: convert `Duration` unops to by value 2014-12-18 15:02:29 -05:00
Jorge Aparicio 340f042e03 libstd: convert `BitFlags` unops to by value 2014-12-18 15:02:28 -05:00
bors f9a48492a8 auto merge of #19984 : japaric/rust/macro-expressions, r=alexcrichton
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]

---

Rebased version of #18958
r? @alexcrichton 
cc @pcwalton
2014-12-18 17:32:07 +00:00
Patrick Walton ddb2466f6a librustc: Always parse `macro!()`/`macro![]` as expressions if not
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
2014-12-18 12:09:07 -05:00
bors c4d58ce15b auto merge of #19819 : vadimcn/rust/fix-demangle, r=alexcrichton
Windows dbghelp strips leading underscores from symbols, and I could not find a way to turn this off.  So let's accept  "ZN...E" form too.
Also, print PC displacement from symbols.  This is helpful in gauging whether the PC was indeed within the function displayed in the backtrace, or whether it just happened to be the closest public symbol in the module.
2014-12-18 14:42:06 +00:00
Valerii Hiora 6746b94f78 iOS: fallout of `marker::NoCopy` removal 2014-12-18 11:09:43 +02:00
Alex Crichton a7bb4795d3 rollup merge of #19935: cgaebel/hashmap-tuple-indexing
r? @Gankro @pczarn
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
Alex Crichton cd07efd264 rollup merge of #19873: drewm1980/master
In US english, "that" is used in restrictive clauses in place of
"which", and often affects the meaning of sentences.

In UK english and many dialects, no distinction is
made.

While Rust devs want to avoid unproductive pedanticism, it is worth at
least being uniform in documentation such as:

http://doc.rust-lang.org/std/iter/index.html

and also in cases where correct usage of US english clarifies the
sentence.
2014-12-17 11:50:28 -08:00
Alex Crichton 64faa74d08 rollup merge of #19869: sfackler/free-stdin
r? @aturon
2014-12-17 11:50:27 -08:00
Alex Crichton 03e970f043 rollup merge of #19868: sourcefrog/master
The rendered form in http://doc.rust-lang.org/nightly/std/rand/struct.OsRng.html looks wrong.
2014-12-17 11:50:27 -08:00
Alex Crichton de0570de21 rollup merge of #19859: alexcrichton/flaky-test
This test would read with a timeout and then send a UDP message, expecting the
message to be received. The receiving port, however, was bound in the child
thread so it could be the case that the timeout and send happens before the
child thread runs. To remedy this we just bind the port before the child thread
runs, moving it into the child later on.

cc #19120
2014-12-17 11:50:27 -08:00
Alex Crichton dbd68c70cd rollup merge of #19832: japaric/no-nocopy
r? @aturon / @alexcrichton
2014-12-17 11:50:25 -08:00
Alex Crichton 974e17b9ea rollup merge of #19770: csouth3/iterator-wrapperstructs
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code.

This PR changes the iterators of `BTreeMap`, `BTreeSet`, `HashMap`, and `HashSet` to use proper new types, rather than type aliases.  However, since it is fair-game to treat a type-alias as the aliased type, this is a:

[breaking-change].
2014-12-17 11:50:24 -08:00
bors 66c297d847 auto merge of #19800 : sfackler/rust/core-hash, r=alexcrichton
r? @alexcrichton
2014-12-17 16:43:20 +00:00
elszben c910252769 Replaced wrapper functions with no_run and as_str().unwrap() with display() 2014-12-17 07:21:29 +01:00
Vadim Chugunov b3b7185bed Fix typo 2014-12-16 21:44:54 -08:00
bors 4265e86844 auto merge of #19761 : nick29581/rust/coerce-double, r=nikomatsakis
Part of #18469

[breaking-change]

A receiver will only ever get a single auto-reference. Previously arrays and strings would get two, e.g., [T] would be auto-ref'ed to &&[T]. This is usually apparent when a trait is implemented for `&[T]` and has a method takes self by reference. The usual solution is to implement the trait for `[T]` (the DST form).

r? @nikomatsakis (or anyone else, really)
2014-12-17 02:42:57 +00:00
Clark Gaebel c42e2f604e Small cleanups in HashMap based off of new rust features. 2014-12-16 17:45:16 -05:00
elszben c0e8dc6dce Added example to TempDir 2014-12-16 19:23:06 +01:00
bors 4375be65a4 auto merge of #19647 : nielsegberts/rust/master, r=pnkfelix
The names expected and actual are not used anymore in the output. It also
removes the confusion that the argument order is the opposite of junit.

Bug #7330 is relevant.
2014-12-16 14:50:58 +00:00
bors 41f5907fa6 auto merge of #19777 : nikomatsakis/rust/warn-on-shadowing, r=acrichto
per rfc 459
cc https://github.com/rust-lang/rust/issues/19390

One question is: should we start by warning, and only switch to hard error later? I think we discussed something like this in the meeting. 

r? @alexcrichton
2014-12-16 08:42:40 +00:00
Steven Fackler 24a8ef63ff Move hash module from collections to core 2014-12-15 22:48:54 -08:00
Nick Cameron 769aa0a7b3 Remove the double auto-ref on arrays/strings as receivers
Part of #18469

[breaking-change]

A receiver will only ever get a single auto-reference. Previously arrays and strings would get two, e.g., [T] would be auto-ref'ed to &&[T]. This is usually apparent when a trait is implemented for `&[T]` and has a method takes self by reference. The usual solution is to implement the trait for `[T]` (the DST form).
2014-12-16 17:05:33 +13: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
bors b497f05008 auto merge of #19747 : alexcrichton/rust/slice-one-trait, r=brson
This commit collapses the various prelude traits for slices into just one trait:

* SlicePrelude/SliceAllocPrelude => SliceExt
* CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt
* OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt
* PartialEqSlicePrelude => PartialEqSliceExt
2014-12-16 01:32:33 +00:00
Chase Southwood 341cf405e5 Use wrapper structs for `HashSet`'s iterators.
Using a type alias for iterator implementations is fragile since this
exposes the implementation to users of the iterator, and any changes
could break existing code.

This commit changes the iterators of `HashSet` to use
proper new types, rather than type aliases.  However, since it is
fair-game to treat a type-alias as the aliased type, this is a:

[breaking-change].
2014-12-15 19:31:07 -06:00
Chase Southwood 85fe141fb7 Use wrapper structs for `HashMap`'s iterators.
Using a type alias for iterator implementations is fragile since this
exposes the implementation to users of the iterator, and any changes
could break existing code.

This commit changes the keys and values iterators of `HashMap` to use
proper new types, rather than type aliases.  However, since it is
fair-game to treat a type-alias as the aliased type, this is a:

[breaking-change].
2014-12-15 19:28:45 -06:00
bors 0669a432a2 auto merge of #19448 : japaric/rust/binops-by-value, r=nikomatsakis
- The following operator traits now take their arguments by value: `Add`, `Sub`, `Mul`, `Div`, `Rem`, `BitAnd`, `BitOr`, `BitXor`, `Shl`, `Shr`. This breaks all existing implementations of these traits.

- The binary operation `a OP b` now "desugars" to `OpTrait::op_method(a, b)` and consumes both arguments.

- `String` and `Vec` addition have been changed to reuse the LHS owned value, and to avoid internal cloning. Only the following asymmetric operations are available: `String + &str` and `Vec<T> + &[T]`, which are now a short-hand for the "append" operation.

[breaking-change]

---

This passes `make check` locally. I haven't touch the unary operators in this PR, but converting them to by value should be very similar to this PR. I can work on them after this gets the thumbs up.

@nikomatsakis r? the compiler changes
@aturon r? the library changes. I think the only controversial bit is the semantic change of the `Vec`/`String` `Add` implementation.
cc #19148
2014-12-15 22:11:44 +00:00
Jorge Aparicio c3778fae6f libstd: add a dummy field to `OsRng` to avoid out of module construction 2014-12-15 15:35:34 -05:00
Jorge Aparicio 556d971f83 Remove internal uses of `marker::NoCopy` 2014-12-15 15:33:37 -05:00
Niko Matsakis 1718cd6ee0 Remove all shadowed lifetimes. 2014-12-15 10:23:48 -05:00
Brian Anderson 53982b64f3 rollup merge of #19787: akiss77/fix-i8-c_char
On AArch64, libc::c_char is u8. There are some places in the code where i8 is assumed, which causes compilation errors.

(AArch64 is not officially supported yet, but this change does not hurt any other targets and makes the code future-proof.)
2014-12-15 06:45:35 -08:00
Brian Anderson 6c4a2bc55f rollup merge of #19710: steveklabnik/gh15449
Fixes #15499.
2014-12-15 06:44:20 -08:00
Andrew Wagner 8fcc832198 Standardize some usages of "which" in docstrings
In US english, "that" is used in restrictive clauses in place of
"which", and often affects the meaning of sentences.

In UK english and many dialects, no distinction is
made.

While Rust devs want to avoid unproductive pedanticism, it is worth at
least being uniform in documentation such as:

http://doc.rust-lang.org/std/iter/index.html

and also in cases where correct usage of US english clarifies the
sentence.
2014-12-15 10:50:42 +01:00
Steven Fackler 8d6895a9c0 Free stdin on exit 2014-12-14 23:36:50 -08:00
Martin Pool c270390f1b Fix Markdown syntax in docs for OsRng 2014-12-14 22:26:09 -08:00
Alex Crichton 7741516a8b std: Collapse SlicePrelude traits
This commit collapses the various prelude traits for slices into just one trait:

* SlicePrelude/SliceAllocPrelude => SliceExt
* CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt
* OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt
* PartialEqSlicePrelude => PartialEqSliceExt
2014-12-14 19:03:56 -08:00
Alex Crichton 0d38cae0b9 std: Bind port early to make a test more reliable
This test would read with a timeout and then send a UDP message, expecting the
message to be received. The receiving port, however, was bound in the child
thread so it could be the case that the timeout and send happens before the
child thread runs. To remedy this we just bind the port before the child thread
runs, moving it into the child later on.

cc #19120
2014-12-14 18:58:13 -08:00
bors 126db549b0 auto merge of #19742 : vhbit/rust/copy-for-bitflags, r=alexcrichton 2014-12-15 00:07:35 +00:00
Niko Matsakis 5c3d398919 Mostly rote conversion of `proc()` to `move||` (and occasionally `Thunk::new`) 2014-12-14 04:21:56 -05:00
Niko Matsakis d61338172f Rewrite threading infrastructure, introducing `Thunk` to represent
boxed `FnOnce` closures.
2014-12-14 04:21:56 -05:00
Jorge Aparicio bc23b8ebc6 libstd: fix unit tests 2014-12-13 20:15:39 -05:00
Jorge Aparicio 9126a24e42 libstd: convert `Duration` binops to by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio 32168faf9f libstd: convert `BitFlags` binops to by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio 029789b98c Get rid of all the remaining uses of `refN`/`valN`/`mutN`/`TupleN` 2014-12-13 20:04:41 -05:00
Jorge Aparicio fe48a65aaa libstd: use tuple indexing 2014-12-13 20:04:40 -05:00
Vadim Chugunov 317d91261b Windows dbghelp strips leading underscores from symbols, so let's accept "ZN...E" form too.
Also, print PC displacement from symbols.
2014-12-13 14:16:53 -08:00
Jorge Aparicio db8300ce06 libstd: add missing imports 2014-12-13 17:03:48 -05:00
Jorge Aparicio cdbb3ca9b7 libstd: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio 40b3617035 libstd: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio 43cf7b4e45 libstd: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio cc242bcf47 libstd: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio c3fe7105ba libstd: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio d22acb77b2 libstd: fix fallout 2014-12-13 17:03:44 -05:00
Valerii Hiora 319c379bac Add `Copy` to bitflags-generated structures 2014-12-13 07:52:00 +02:00
bors 8c66927242 auto merge of #19664 : tbu-/rust/pr_oibit2_fix, r=Gankro
These probably happened during the merge of the commit that made `Copy` opt-in.

Also, convert the last occurence of `/**` to `///` in `src/libstd/num/strconv.rs`
2014-12-13 00:27:15 +00:00
Akos Kiss a28d16a751 libc::c_char is not necessarily i8 2014-12-12 22:41:14 +00:00
Alex Crichton 52edb2ecc9 Register new snapshots 2014-12-11 11:30:38 -08:00
Steve Klabnik 6780031540 Fix inappropriate ## headings
Fixes #15499.
2014-12-10 13:54:56 -05:00
Alex Crichton 1a61fe4280 Test fixes and rebase conflicts from the rollup 2014-12-09 10:26:04 -08:00
Tobias Bucher deabeb0276 Rollback accidental documentation changes
These probably happened during the merge of the commit that made `Copy` opt-in.

Also, convert the last occurence of `/**` to `///` in `src/libstd/num/strconv.rs`
2014-12-09 18:50:31 +01:00
Alex Crichton 2457375534 rollup merge of #19653: frewsxcv/rm-reexports
Brief note: This does *not* affect anything in the prelude

Part of #19253

All this does is remove the reexporting of Result and Option from their
respective modules. More core reexports might be removed, but these ones
are the safest to remove since these enums (and their variants) are included in
the prelude.

Depends on https://github.com/rust-lang/rust/pull/19407 which is merged, but might need a new snapshot

[breaking-change]
2014-12-09 09:25:14 -08:00
Alex Crichton 4a49912cfe rollup merge of #19620: retep998/memorymap 2014-12-09 09:25:07 -08:00
Alex Crichton fb587f1f9b rollup merge of #19614: steveklabnik/gh19599
Fixes #19599
2014-12-09 09:25:04 -08:00
Alex Crichton 39b57115fb rollup merge of #19577: aidancully/master
pthread_key_create can be 0.
addresses issue #19567.
2014-12-09 09:24:39 -08:00
Corey Farwell 9af324a673 Remove Result and Option reexports
Brief note: This does *not* affect anything in the prelude

Part of #19253

All this does is remove the reexporting of Result and Option from their
respective modules. More core reexports might be removed, but these ones
are the safest to remove since these enums (and their variants) are included in
the prelude.

[breaking-change]
2014-12-08 21:40:16 -05:00
Niels Egberts 2dc338dfdb Rename assert_eq arguments to left and right.
The names expected and actual are not used anymore in the output. It also
removes the confusion that the argument order is the opposite of junit.
2014-12-09 00:09:42 +00:00
Niko Matsakis 096a28607f librustc: Make `Copy` opt-in.
This change makes the compiler no longer infer whether types (structures
and enumerations) implement the `Copy` trait (and thus are implicitly
copyable). Rather, you must implement `Copy` yourself via `impl Copy for
MyType {}`.

A new warning has been added, `missing_copy_implementations`, to warn
you if a non-generic public type has been added that could have
implemented `Copy` but didn't.

For convenience, you may *temporarily* opt out of this behavior by using
`#![feature(opt_out_copy)]`. Note though that this feature gate will never be
accepted and will be removed by the time that 1.0 is released, so you should
transition your code away from using it.

This breaks code like:

    #[deriving(Show)]
    struct Point2D {
        x: int,
        y: int,
    }

    fn main() {
        let mypoint = Point2D {
            x: 1,
            y: 1,
        };
        let otherpoint = mypoint;
        println!("{}{}", mypoint, otherpoint);
    }

Change this code to:

    #[deriving(Show)]
    struct Point2D {
        x: int,
        y: int,
    }

    impl Copy for Point2D {}

    fn main() {
        let mypoint = Point2D {
            x: 1,
            y: 1,
        };
        let otherpoint = mypoint;
        println!("{}{}", mypoint, otherpoint);
    }

This is the backwards-incompatible part of #13231.

Part of RFC #3.

[breaking-change]
2014-12-08 13:47:44 -05:00
Eduard Burtescu c75e8d46c2 core: remove the dead function fmt::argumentstr. 2014-12-08 09:14:21 +02: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
Peter Atashian 58f12743c2 Make MemoryMap use HANDLE on Windows.
Also fixes some conflicting module names.

Signed-off-by: Peter Atashian <retep998@gmail.com>
2014-12-07 13:25:51 -05:00
Jorge Aparicio 1fea900de7 Fix syntax error on android tests 2014-12-07 08:49:17 -05:00
Steve Klabnik 8ba5605233 remove usage of notrust from the docs
Fixes #19599
2014-12-07 04:18:56 -05:00
Jorge Aparicio c2da923fc9 libstd: remove unnecessary `to_string()` calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio 6132a90788 libstd: remove unnecessary `as_mut_slice` calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio 60338d91c4 libstd: remove unnecessary `as_slice()` calls 2014-12-06 23:53:00 -05:00
bors f7d18b92f8 auto merge of #19407 : frewsxcv/rust/rm-reexports, r=cmr
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::\*, Result::\*, and Ordering::\*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
2014-12-07 04:12:20 +00:00
bors de83d7dd19 auto merge of #19431 : erickt/rust/buf-writer-error, r=alexcrichton
Previously, `BufWriter::write` would just return an `std::io::OtherIoError` if someone attempted to write past the end of the wrapped buffer. This pull request changes the error to support partial writes and return a `std::io::ShortWrite`, or an `io::io::EndOfFile` if it's been fully exhausted.

 I've also optimized away a bounds check inside `BufWriter::write`, which should help shave off some nanoseconds in an inner loops.
2014-12-06 20:12:13 +00:00
Aidan Cully c394a6c238 prefer "FIXME" to "TODO". 2014-12-05 18:39: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
Aidan Cully 7bf7bd6a75 work around portability issue on FreeBSD, in which the key returned from
pthread_key_create can be 0.
2014-12-05 17:20:44 -05:00
Corey Richardson 64d58dcac2 rollup merge of #19454: nodakai/libstd-reap-failed-child
After the library successfully called `fork(2)`, the child does several
setup works such as setting UID, GID and current directory before it
calls `exec(2)`.  When those setup works failed, the child exits but the
parent didn't call `waitpid(2)` and left it as a zombie.

This patch also add several sanity checks.  They shouldn't make any
noticeable impact to runtime performance.

The new test case in `libstd/io/process.rs` calls the ps command to check
if the new code can really reap a zombie.
The output of `ps -A -o pid,sid,command` should look like this:

```
  PID   SID COMMAND
    1     1 /sbin/init
    2     0 [kthreadd]
    3     0 [ksoftirqd/0]
...
12562  9237 ./spawn-failure
12563  9237 [spawn-failure] <defunct>
12564  9237 [spawn-failure] <defunct>
...
12592  9237 [spawn-failure] <defunct>
12593  9237 ps -A -o pid,sid,command
12884 12884 /bin/zsh
12922 12922 /bin/zsh
...
```

where `./spawn-failure` is my test program which intentionally leaves many
zombies.  Filtering the output with the "SID" (session ID) column is
a quick way to tell if a process (zombie) was spawned by my own test
program.  Then the number of "defunct" lines is the number of zombie
children.
2014-12-05 10:07:02 -08:00
Corey Richardson a6ce402401 rollup merge of #19416: sfackler/global-stdin
io::stdin returns a new `BufferedReader` each time it's called, which
results in some very confusing behavior with disappearing output. It now
returns a `StdinReader`, which wraps a global singleton
`Arc<Mutex<BufferedReader<StdReader>>`. `Reader` is implemented directly
on `StdinReader`. However, `Buffer` is not, as the `fill_buf` method is
fundamentaly un-thread safe. A `lock` method is defined on `StdinReader`
which returns a smart pointer wrapping the underlying `BufferedReader`
while guaranteeing mutual exclusion.

Code that treats the return value of io::stdin as implementing `Buffer`
will break. Add a call to `lock`:

```rust
io::stdin().read_line();
// =>
io::stdin().lock().read_line();
```

Closes #14434

[breaking-change]
2014-12-05 10:06:52 -08:00
Corey Richardson d066b5c4be rollup merge of #19364: steveklabnik/doc_buffered_reader
We don't need this &mut, and vec could use []s
2014-12-05 10:06:42 -08:00
Corey Richardson 08ce178866 rollup merge of #19274: alexcrichton/rewrite-sync
This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.

The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:

* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
  A condition variable is now an entirely separate type. This separation
  benefits users who only use one mutex, and provides a clearer distinction of
  who's responsible for managing condition variables (the application).

* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
  system primitives rather than using a custom implementation. The `Once`,
  `Barrier`, and `Semaphore` types are still built upon these abstractions of
  the system primitives.

* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
  constant initializer corresponding to them. These are provided primarily for C
  FFI interoperation, but are often useful to otherwise simply have a global
  lock. The types, however, will leak memory unless `destroy()` is called on
  them, which is clearly documented.

* The fundamental architecture of this design is to provide two separate layers.
  The first layer is that exposed by `sys_common` which is a cross-platform
  bare-metal abstraction of the system synchronization primitives. No attempt is
  made at making this layer safe, and it is quite unsafe to use! It is currently
  not exported as part of the API of the standard library, but the stabilization
  of the `sys` module will ensure that these will be exposed in time. The
  purpose of this layer is to provide the core cross-platform abstractions if
  necessary to implementors.

  The second layer is the layer provided by `std::sync` which is intended to be
  the thinnest possible layer on top of `sys_common` which is entirely safe to
  use. There are a few concerns which need to be addressed when making these
  system primitives safe:

    * Once used, the OS primitives can never be **moved**. This means that they
      essentially need to have a stable address. The static primitives use
      `&'static self` to enforce this, and the non-static primitives all use a
      `Box` to provide this guarantee.

    * Poisoning is leveraged to ensure that invalid data is not accessible from
      other tasks after one has panicked.

  In addition to these overall blanket safety limitations, each primitive has a
  few restrictions of its own:

    * Mutexes and rwlocks can only be unlocked from the same thread that they
      were locked by. This is achieved through RAII lock guards which cannot be
      sent across threads.

    * Mutexes and rwlocks can only be unlocked if they were previously locked.
      This is achieved by not exposing an unlocking method.

    * A condition variable can only be waited on with a locked mutex. This is
      achieved by requiring a `MutexGuard` in the `wait()` method.

    * A condition variable cannot be used concurrently with more than one mutex.
      This is guaranteed by dynamically binding a condition variable to
      precisely one mutex for its entire lifecycle. This restriction may be able
      to be relaxed in the future (a mutex is unbound when no threads are
      waiting on the condvar), but for now it is sufficient to guarantee safety.

* Condvars support timeouts for their blocking operations. The
  implementation for these operations is provided by the system.

Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.

[breaking-change]

Closes #17094
Closes #18003
2014-12-05 10:06:39 -08:00
Erick Tryzelaar 72bc461ce3 std: change BufWriter to return ShortWrite/EndOfFile 2014-12-05 09:42:48 -08:00
Alex Crichton c3adbd34c4 Fall out of the std::sync rewrite 2014-12-05 09:12:25 -08:00
Alex Crichton 71d4e77db8 std: Rewrite the `sync` module
This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.

The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:

* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
  A condition variable is now an entirely separate type. This separation
  benefits users who only use one mutex, and provides a clearer distinction of
  who's responsible for managing condition variables (the application).

* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
  system primitives rather than using a custom implementation. The `Once`,
  `Barrier`, and `Semaphore` types are still built upon these abstractions of
  the system primitives.

* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
  constant initializer corresponding to them. These are provided primarily for C
  FFI interoperation, but are often useful to otherwise simply have a global
  lock. The types, however, will leak memory unless `destroy()` is called on
  them, which is clearly documented.

* The `Condvar` implementation for an `RWLock` write lock has been removed. This
  may be added back in the future with a userspace implementation, but this
  commit is focused on exposing the system primitives first.

* The fundamental architecture of this design is to provide two separate layers.
  The first layer is that exposed by `sys_common` which is a cross-platform
  bare-metal abstraction of the system synchronization primitives. No attempt is
  made at making this layer safe, and it is quite unsafe to use! It is currently
  not exported as part of the API of the standard library, but the stabilization
  of the `sys` module will ensure that these will be exposed in time. The
  purpose of this layer is to provide the core cross-platform abstractions if
  necessary to implementors.

  The second layer is the layer provided by `std::sync` which is intended to be
  the thinnest possible layer on top of `sys_common` which is entirely safe to
  use. There are a few concerns which need to be addressed when making these
  system primitives safe:

    * Once used, the OS primitives can never be **moved**. This means that they
      essentially need to have a stable address. The static primitives use
      `&'static self` to enforce this, and the non-static primitives all use a
      `Box` to provide this guarantee.

    * Poisoning is leveraged to ensure that invalid data is not accessible from
      other tasks after one has panicked.

  In addition to these overall blanket safety limitations, each primitive has a
  few restrictions of its own:

    * Mutexes and rwlocks can only be unlocked from the same thread that they
      were locked by. This is achieved through RAII lock guards which cannot be
      sent across threads.

    * Mutexes and rwlocks can only be unlocked if they were previously locked.
      This is achieved by not exposing an unlocking method.

    * A condition variable can only be waited on with a locked mutex. This is
      achieved by requiring a `MutexGuard` in the `wait()` method.

    * A condition variable cannot be used concurrently with more than one mutex.
      This is guaranteed by dynamically binding a condition variable to
      precisely one mutex for its entire lifecycle. This restriction may be able
      to be relaxed in the future (a mutex is unbound when no threads are
      waiting on the condvar), but for now it is sufficient to guarantee safety.

* Condvars now support timeouts for their blocking operations. The
  implementation for these operations is provided by the system.

Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.

[breaking-change]

Closes #17094
Closes #18003
2014-12-05 00:53:22 -08:00
Alex Crichton d6d4088bbf std: Close TcpListener with closesocket()
This may have inadvertently switched during the runtime overhaul, so this
switches TcpListener back to using sockets instead of file descriptors. This
also renames a bunch of variables called `fd` to `socket` to clearly show that
it's not a file descriptor.

Closes #19333
2014-12-05 00:49:31 -08:00
NODA, Kai 74fb798a20 libstd/sys/unix/process.rs: reap a zombie who didn't get through to exec(2).
After the library successfully called fork(2), the child does several
setup works such as setting UID, GID and current directory before it
calls exec(2).  When those setup works failed, the child exits but the
parent didn't call waitpid(2) and left it as a zombie.

This patch also add several sanity checks.  They shouldn't make any
noticeable impact to runtime performance.

The new test case run-pass/wait-forked-but-failed-child.rs calls the ps
command to check if the new code can really reap a zombie.  When
I intentionally create many zombies with my test program
./spawn-failure, The output of "ps -A -o pid,sid,command" should look
like this:

  PID   SID COMMAND
    1     1 /sbin/init
    2     0 [kthreadd]
    3     0 [ksoftirqd/0]
...
12562  9237 ./spawn-failure
12563  9237 [spawn-failure] <defunct>
12564  9237 [spawn-failure] <defunct>
...
12592  9237 [spawn-failure] <defunct>
12593  9237 ps -A -o pid,sid,command
12884 12884 /bin/zsh
12922 12922 /bin/zsh
...

Filtering the output with the "SID" (session ID) column is a quick way
to tell if a process (zombie) was spawned by my own test program.  Then
the number of "defunct" lines is the number of zombie children.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-12-05 10:04:06 +08:00
bors 361baabb07 auto merge of #19303 : nodakai/rust/libsyntax-reject-dirs, r=alexcrichton
On *BSD systems, we can `open(2)` a directory and directly `read(2)` from it due to an old tradition.  We should avoid doing so by explicitly calling `fstat(2)` to check the type of the opened file.

Opening a directory as a module file can't always be avoided.  Even when there's no "path" attribute trick involved, there can always be a *directory* named `my_module.rs`.

Incidentally, remove unnecessary mutability of `&self` from `io::fs::File::stat()`.
2014-12-05 00:22:58 +00:00
bors d9c7c00b9a auto merge of #18980 : erickt/rust/reader, r=erickt
This continues the work @thestinger started in #18885 (which hasn't landed yet, so wait for that to land before landing this one). Instead of adding more methods to `BufReader`, this just allows a `&[u8]` to be used directly as a `Reader`. It also adds an impl of `Writer` for `&mut [u8]`.
2014-12-04 21:33:07 +00:00
bors 6d965cc2c9 auto merge of #19167 : japaric/rust/rhs-cmp, r=aturon
Comparison traits have gained an `Rhs` input parameter that defaults to `Self`. And now the comparison operators can be overloaded to work between different types. In particular, this PR allows the following operations (and their commutative versions):

- `&str` == `String` == `CowString`
- `&[A]` == `&mut [B]` == `Vec<C>` == `CowVec<D>` == `[E, ..N]` (for `N` up to 32)
- `&mut A` == `&B` (for `Sized` `A` and `B`)

Where `A`, `B`, `C`, `D`, `E` may be different types that implement `PartialEq`. For example, these comparisons are now valid: `string == "foo"`, and `vec_of_strings == ["Hello", "world"]`.

[breaking-change]s

Since the `==` may now work on different types, operations that relied on the old "same type restriction" to drive type inference, will need to be type annotated. These are the most common fallout cases:

- `some_vec == some_iter.collect()`: `collect` needs to be type annotated: `collect::<Vec<_>>()`
- `slice == &[a, b, c]`: RHS doesn't get coerced to an slice, use an array instead `[a, b, c]`
- `lhs == []`: Change expression to `lhs.is_empty()`
- `lhs == some_generic_function()`: Type annotate the RHS as necessary

cc #19148

r? @aturon
2014-12-04 12:02:56 +00:00
Steven Fackler e7c1f57d6c Back io::stdin with a global singleton BufferedReader
io::stdin returns a new `BufferedReader` each time it's called, which
results in some very confusing behavior with disappearing output. It now
returns a `StdinReader`, which wraps a global singleton
`Arc<Mutex<BufferedReader<StdReader>>`. `Reader` is implemented directly
on `StdinReader`. However, `Buffer` is not, as the `fill_buf` method is
fundamentaly un-thread safe. A `lock` method is defined on `StdinReader`
which returns a smart pointer wrapping the underlying `BufferedReader`
while guaranteeing mutual exclusion.

Code that treats the return value of io::stdin as implementing `Buffer`
will break. Add a call to `lock`:

```rust
io::stdin().lines()
// =>
io::stdin().lock().lines()
```

Closes #14434

[breaking-change]
2014-12-03 23:18:52 -08:00
NODA, Kai 3980cdecd0 libstd: explicitly disallow io::fs::File to open a directory.
On *BSD systems, we can open(2) a directory and directly read(2) from
it due to an old tradition.  We should avoid doing so by explicitly
calling fstat(2) to check the type of the opened file.

Opening a directory as a module file can't always be avoided.
Even when there's no "path" attribute trick involved, there can always
be a *directory* named "my_module.rs".

Fix #12460

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-12-04 11:19:55 +08:00
NODA, Kai 805a06ca6a libstd: io::fs::File::stat() need not to take &mut self.
The same goes for sys::fs::FileDesc::fstat() on Windows.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-12-04 11:19:55 +08:00
Jorge Aparicio 5cfac94201 Deprecate Equiv 2014-12-03 10:41:48 -05:00
Jorge Aparicio 09707d70a4 Fix fallout 2014-12-03 10:41:48 -05:00
Jorge Aparicio eac635de01 Remove unused transmutes from tests 2014-12-03 10:41:48 -05:00
Erick Tryzelaar 0d24780793 std: add Reader impl for &[u8] 2014-11-30 16:55:53 -08:00
Erick Tryzelaar 6687b2a6e1 std: add tests for the Vec<u8> Writer impl 2014-11-30 16:55:08 -08:00
Piotr Czarnecki b82624bf20 std: Change the behavior of `reserve` for HashMap.
HashMap's `reserve` method now takes as an argument the *extra* space
to reserve.

[breaking-change]
2014-11-30 22:52:11 +01:00
Piotr Czarnecki 72c96badd2 std: Remove implicit shrinking from hash_map.
Implements fn shrink_to_fit for HashMap.
2014-11-30 22:52:10 +01:00
Steve Klabnik 44abe92d66 small doc fixes
We don't need this &mut, and vec could use []s
2014-11-28 08:59:35 -05:00
bors 832dc619ec auto merge of #19360 : olivren/rust/master, r=Gankro
The previous code was giving an incorrect result (not x/3).

Also, this function does not work with signed integers. It now accepts `u32` instead of `i32`.
2014-11-28 07:31:26 +00:00
bors dbbb722f25 auto merge of #19355 : vhbit/rust/ios-backtrace-fix, r=alexcrichton 2014-11-28 02:46:24 +00:00
bors eb4e0f7704 auto merge of #19354 : barosl/rust/strconv-doc-fix, r=steveklabnik
- `int_to_str_bytes_common()` doesn't have a return value.
- `float_to_str_bytes_common()` has an old-style doc comment.
2014-11-28 00:01:23 +00:00
olivren f01cbaa0ba Fix example code for unreachable!
The previous code was giving an incorrect result (not x/3).
2014-11-27 15:31:11 +01:00
Valerii Hiora 8d1aab1854 Fixed iOS build after Iter stab 2014-11-27 11:34:43 +02:00
Barosl Lee c67dbed11c Documentation fix for std::num::strconv
- int_to_str_bytes_common() doesn't have a return value.
- float_to_str_bytes_common() has an old-style doc comment.
2014-11-27 17:14:00 +09:00
bors 66601647cd auto merge of #19343 : sfackler/rust/less-special-attrs, r=alexcrichton
Descriptions and licenses are handled by Cargo now, so there's no reason
to keep these attributes around.
2014-11-27 06:41:17 +00:00
Alex Crichton 5816d7f530 More test fixes and rebase conflicts! 2014-11-26 18:10:57 -08:00
Alex Crichton e8d743ec1d rollup merge of #19329: steveklabnik/doc_style_cleanup2 2014-11-26 16:51:02 -08:00
Steve Klabnik cd5c8235c5 /*! -> //!
Sister pull request of https://github.com/rust-lang/rust/pull/19288, but
for the other style of block doc comment.
2014-11-26 16:50:14 -08:00
Alex Crichton 60541cdc1e Test fixes and rebase conflicts 2014-11-26 16:50:13 -08:00
Alex Crichton 3a1d538e1c rollup merge of #19328: sfackler/buffered-get-mut
This is necessary to e.g. set a timeout on the underlying stream.

r? @alexcrichton
2014-11-26 16:50:13 -08:00
Alex Crichton 2298084058 rollup merge of #19326: huonw/safer-syntax
This makes it correct (e.g. avoiding null pointers) and safe.
2014-11-26 16:50:12 -08:00
Alex Crichton 8999a7987c rollup merge of #19316: steveklabnik/gh18876
Fixes #18876
2014-11-26 16:50:12 -08:00
Alex Crichton 69e7554a47 rollup merge of #19301: Gankro/take-fix
Was taking the value out correctly, but then not doing anything to actually fix the table. derp.
2014-11-26 16:49:49 -08:00
Alex Crichton f4a775639c rollup merge of #19298: nikomatsakis/unboxed-closure-parse-the-plus
Implements RFC 438.

Fixes #19092.

This is a [breaking-change]: change types like `&Foo+Send` or `&'a mut Foo+'a` to `&(Foo+Send)` and `&'a mut (Foo+'a)`, respectively.

r? @brson
2014-11-26 16:49:46 -08:00
Alex Crichton f40fa8304f rollup merge of #19288: steveklabnik/doc_style_cleanup
This is considered good convention.

This is about half of them in total, I just don't want an impossible to land patch. 😄
2014-11-26 16:49:36 -08:00
Alex Crichton 3649c2a39f rollup merge of #19273: ogham/rename-file-types
All of the enum components had a redundant 'Type' specifier: TypeSymlink, TypeDirectory, TypeFile. This change removes them, replacing them with a namespace: FileType::Symlink, FileType::Directory, and FileType::RegularFile.

RegularFile is used instead of just File, as File by itself could be mistakenly thought of as referring to the struct.

Part of #19253.
2014-11-26 16:49:35 -08: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
bors 1a44875af9 auto merge of #19176 : aturon/rust/stab-iter, r=alexcrichton
This is an initial pass at stabilizing the `iter` module. The module is
fairly large, but is also pretty polished, so most of the stabilization
leaves things as they are.

Some changes:

* Due to the new object safety rules, various traits needs to be split
  into object-safe traits and extension traits. This includes `Iterator`
  itself. While splitting up the traits adds some complexity, it will
  also increase flexbility: once we have automatic impls of `Trait` for
  trait objects over `Trait`, then things like the iterator adapters
  will all work with trait objects.

* Iterator adapters that use up the entire iterator now take it by
  value, which makes the semantics more clear and helps catch bugs. Due
  to the splitting of Iterator, this does not affect trait objects. If
  the underlying iterator is still desired for some reason, `by_ref` can
  be used. (Note: this change had no fallout in the Rust distro except
  for the useless mut lint.)

* In general, extension traits new and old are following an [in-progress
  convention](rust-lang/rfcs#445). As such, they
  are marked `unstable`.

* As usual, anything involving closures is `unstable` pending unboxed
  closures.

* A few of the more esoteric/underdeveloped iterator forms (like
  `RandomAccessIterator` and `MutableDoubleEndedIterator`, along with
  various unfolds) are left experimental for now.

* The `order` submodule is left `experimental` because it will hopefully
  be replaced by generalized comparison traits.

* "Leaf" iterators (like `Repeat` and `Counter`) are uniformly
  constructed by free fns at the module level. That's because the types
  are not otherwise of any significance (if we had `impl Trait`, you
  wouldn't want to define a type at all).

Closes #17701

Due to renamings and splitting of traits, this is a:

[breaking-change]
2014-11-26 17:42:07 +00:00
Niko Matsakis f4e29e7e9a Fixup various places that were doing `&T+'a` and do `&(T+'a)` 2014-11-26 11:42:06 -05:00
bors 8fb027e398 auto merge of #19252 : japaric/rust/cow, r=aturon
- Add `IntoCow` trait, and put it in the prelude
- Add `is_owned`/`is_borrowed` methods to `Cow`
- Add `CowString`/`CowVec` type aliases (to `Cow<'_, String, str>`/`Cow<'_, Vec, [T]>` respectively)
- `Cow` implements: `Show`, `Hash`, `[Partial]{Eq,Ord}`
- `impl BorrowFrom<Cow<'a, T, B>> for B`

[breaking-change]s:

- `IntoMaybeOwned` has been removed from the prelude
- libcollections: `SendStr` is now an alias to `CowString<'static>` (it was aliased to `MaybeOwned<'static>`)
- libgraphviz:
  - `LabelText` variants now wrap `CowString` instead of `MaybeOwned`
  - `Nodes` and `Edges` are now type aliases to `CowVec` (they were aliased to `MaybeOwnedVec`)
- libstd/path: `Display::as_maybe_owned` has been renamed to `Display::as_cow` and now returns a `CowString`
- These functions now accept/return `Cow` instead of `MaybeOwned[Vector]`:
  - libregex: `Replacer::reg_replace`
  - libcollections: `str::from_utf8_lossy`
  - libgraphviz: `Id::new`, `Id::name`, `LabelText::pre_escaped_content`
  - libstd: `TaskBuilder::named`

r? @aturon
2014-11-26 12:02:16 +00:00
bors 61af402789 auto merge of #19169 : aturon/rust/fds, r=alexcrichton
This PR adds some internal infrastructure to allow the private `std::sys` module to access internal representation details of `std::io`.

It then exposes those details in two new, platform-specific API surfaces: `std::os::unix` and `std::os::windows`.

To start with, these will provide the ability to extract file descriptors, HANDLEs, SOCKETs, and so on from `std::io` types.

More functionality, and more specific platforms (e.g. `std::os::linux`) will be added over time.

Closes #18897
2014-11-26 08:42:09 +00:00
bors 8d7b3199d9 auto merge of #19212 : steveklabnik/rust/doc_format_specifiers, r=alexcrichton
Fixes #19209
2014-11-26 06:42:06 +00:00
Steve Klabnik f38e4e6d97 /** -> ///
This is considered good convention.
2014-11-25 21:24:16 -05:00
Steve Klabnik 7dadb14fb2 remove deprecated stuff from std::fmt docs
Fixes #19209
2014-11-25 21:19:28 -05:00
Aaron Turon b299c2b57d Fallout from stabilization 2014-11-25 17:41:54 -08:00
Steven Fackler 945b4edd67 Allow mutable access to wrapped internal type in Buffered*
This is necessary to e.g. set a timeout on the underlying stream.
2014-11-25 17:39:53 -08:00
Huon Wilson 4653ad0205 Make syntax::owned_slice a Box<[T]> wrapper.
This makes it correct (e.g. avoiding null pointers) and safe.
2014-11-26 11:55:39 +11:00
bors 689ef2dabf auto merge of #19255 : aturon/rust/merge-sync, r=alexcrichton,alexcrichton
This patch merges the `libsync` crate into `libstd`, undoing part of the
facade. This is in preparation for ultimately merging `librustrt`, as
well as the upcoming rewrite of `sync`.

Because this removes the `libsync` crate, it is a:

[breaking-change]

However, all uses of `libsync` should be able to reroute through
`std::sync` and `std::comm` instead.

r? @alexcrichton
2014-11-25 20:32:20 +00:00
Steve Klabnik 4ce3ba484b Improve documentation for unreachable
Fixes #18876
2014-11-25 15:04:27 -05:00
Jorge Aparicio 3293ab14e2 Deprecate MaybeOwned[Vector] in favor of Cow 2014-11-25 11:22:23 -05:00
Alexis Beingessner b1e720fb7e Make HashMap::take not corrupt the map. Fixes #19292 2014-11-25 08:41:55 -05:00
bors f6cb58caee auto merge of #19149 : alexcrichton/rust/issue-19091, r=aturon
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename
non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all
`unwrap` methods are retained as `#[deprecated]` for the near future. To update
code rename `unwrap` method calls to `into_inner`.

[rfc]: https://github.com/rust-lang/rfcs/pull/430
[breaking-change]

cc #19091
2014-11-25 09:21:45 +00:00
bors 5f9741e62d auto merge of #19285 : alexcrichton/rust/issue-19280, r=aturon
It turns out that rustrt::at_exit() doesn't actually occur after all pthread
threads have exited (nor does atexit()), so there's not actually a known point
at which we can deallocate these keys. It's not super critical that we do so,
however, because we're about to exit anyway!

Closes #19280
2014-11-25 01:06:41 +00:00