Commit Graph

6832 Commits

Author SHA1 Message Date
Alex Crichton 6301c7878e rollup merge of #20680: nick29581/target-word
Closes #20421

[breaking-change]

r? @brson
2015-01-07 17:17:23 -08:00
Alex Crichton f3b67afcab rollup merge of #20663: brson/feature-staging
This partially implements the feature staging described in the
[release channel RFC][rc]. It does not yet fully conform to the RFC as
written, but does accomplish its goals sufficiently for the 1.0 alpha
release.

It has three primary user-visible effects:

* On the nightly channel, use of unstable APIs generates a warning.
* On the beta channel, use of unstable APIs generates a warning.
* On the beta channel, use of feature gates generates a warning.

Code that does not trigger these warnings is considered 'stable',
modulo pre-1.0 bugs.

Disabling the warnings for unstable APIs continues to be done in the
existing (i.e. old) style, via `#[allow(...)]`, not that specified in
the RFC. I deem this marginally acceptable since any code that must do
this is not using the stable dialect of Rust.

Use of feature gates is itself gated with the new 'unstable_features'
lint, on nightly set to 'allow', and on beta 'warn'.

The attribute scheme used here corresponds to an older version of the
RFC, with the `#[staged_api]` crate attribute toggling the staging
behavior of the stability attributes, but the user impact is only
in-tree so I'm not concerned about having to make design changes later
(and I may ultimately prefer the scheme here after all, with the
`#[staged_api]` crate attribute).

Since the Rust codebase itself makes use of unstable features the
compiler and build system do a midly elaborate dance to allow it to
bootstrap while disobeying these lints (which would otherwise be
errors because Rust builds with `-D warnings`).

This patch includes one significant hack that causes a
regression. Because the `format_args!` macro emits calls to unstable
APIs it would trigger the lint.  I added a hack to the lint to make it
not trigger, but this in turn causes arguments to `println!` not to be
checked for feature gates. I don't presently understand macro
expansion well enough to fix. This is bug #20661.

Closes #16678

[rc]: https://github.com/rust-lang/rfcs/blob/master/text/0507-release-channels.md

Next steps are to disable the existing out-of-tree behavior for stability attributes, and convert the remaining system to be feature-based per the RFC. During the first beta cycle we will set these lints to 'forbid'.
2015-01-07 17:17:22 -08:00
Alex Crichton 8bf3ee7c5c rollup merge of #20654: alexcrichton/stabilize-hash
This commit aims to prepare the `std::hash` module for alpha by formalizing its
current interface whileholding off on adding `#[stable]` to the new APIs.  The
current usage with the `HashMap` and `HashSet` types is also reconciled by
separating out composable parts of the design. The primary goal of this slight
redesign is to separate the concepts of a hasher's state from a hashing
algorithm itself.

The primary change of this commit is to separate the `Hasher` trait into a
`Hasher` and a `HashState` trait. Conceptually the old `Hasher` trait was
actually just a factory for various states, but hashing had very little control
over how these states were used. Additionally the old `Hasher` trait was
actually fairly unrelated to hashing.

This commit redesigns the existing `Hasher` trait to match what the notion of a
`Hasher` normally implies with the following definition:

    trait Hasher {
        type Output;
        fn reset(&mut self);
        fn finish(&self) -> Output;
    }

This `Hasher` trait emphasizes that hashing algorithms may produce outputs other
than a `u64`, so the output type is made generic. Other than that, however, very
little is assumed about a particular hasher. It is left up to implementors to
provide specific methods or trait implementations to feed data into a hasher.

The corresponding `Hash` trait becomes:

    trait Hash<H: Hasher> {
        fn hash(&self, &mut H);
    }

The old default of `SipState` was removed from this trait as it's not something
that we're willing to stabilize until the end of time, but the type parameter is
always required to implement `Hasher`. Note that the type parameter `H` remains
on the trait to enable multidispatch for specialization of hashing for
particular hashers.

Note that `Writer` is not mentioned in either of `Hash` or `Hasher`, it is
simply used as part `derive` and the implementations for all primitive types.

With these definitions, the old `Hasher` trait is realized as a new `HashState`
trait in the `collections::hash_state` module as an unstable addition for
now. The current definition looks like:

    trait HashState {
        type Hasher: Hasher;
        fn hasher(&self) -> Hasher;
    }

The purpose of this trait is to emphasize that the one piece of functionality
for implementors is that new instances of `Hasher` can be created.  This
conceptually represents the two keys from which more instances of a
`SipHasher` can be created, and a `HashState` is what's stored in a
`HashMap`, not a `Hasher`.

Implementors of custom hash algorithms should implement the `Hasher` trait, and
only hash algorithms intended for use in hash maps need to implement or worry
about the `HashState` trait.

The entire module and `HashState` infrastructure remains `#[unstable]` due to it
being recently redesigned, but some other stability decision made for the
`std::hash` module are:

* The `Writer` trait remains `#[experimental]` as it's intended to be replaced
  with an `io::Writer` (more details soon).
* The top-level `hash` function is `#[unstable]` as it is intended to be generic
  over the hashing algorithm instead of hardwired to `SipHasher`
* The inner `sip` module is now private as its one export, `SipHasher` is
  reexported in the `hash` module.

And finally, a few changes were made to the default parameters on `HashMap`.

* The `RandomSipHasher` default type parameter was renamed to `RandomState`.
  This renaming emphasizes that it is not a hasher, but rather just state to
  generate hashers. It also moves away from the name "sip" as it may not always
  be implemented as `SipHasher`. This type lives in the
  `std::collections::hash_map` module as `#[unstable]`

* The associated `Hasher` type of `RandomState` is creatively called...
  `Hasher`! This concrete structure lives next to `RandomState` as an
  implemenation of the "default hashing algorithm" used for a `HashMap`. Under
  the hood this is currently implemented as `SipHasher`, but it draws an
  explicit interface for now and allows us to modify the implementation over
  time if necessary.

There are many breaking changes outlined above, and as a result this commit is
a:

[breaking-change]
2015-01-07 17:17:19 -08:00
Jorge Aparicio 7d72719efc fix the `&mut _` patterns 2015-01-07 19:26:36 -05:00
Felix S. Klock II 4a31aaddb3 Added `box_syntax` feature gate; added to std and rustc crates for bootstrap.
To avoid using the feauture, change uses of `box <expr>` to
`Box::new(<expr>)` alternative, as noted by the feature gate message.

(Note that box patterns have no analogous trivial replacement, at
least not in general; you need to revise the code to do a partial
match, deref, and then the rest of the match.)

[breaking-change]
2015-01-08 00:41:43 +01:00
Brian Anderson c27133e2ce Preliminary feature staging
This partially implements the feature staging described in the
[release channel RFC][rc]. It does not yet fully conform to the RFC as
written, but does accomplish its goals sufficiently for the 1.0 alpha
release.

It has three primary user-visible effects:

* On the nightly channel, use of unstable APIs generates a warning.
* On the beta channel, use of unstable APIs generates a warning.
* On the beta channel, use of feature gates generates a warning.

Code that does not trigger these warnings is considered 'stable',
modulo pre-1.0 bugs.

Disabling the warnings for unstable APIs continues to be done in the
existing (i.e. old) style, via `#[allow(...)]`, not that specified in
the RFC. I deem this marginally acceptable since any code that must do
this is not using the stable dialect of Rust.

Use of feature gates is itself gated with the new 'unstable_features'
lint, on nightly set to 'allow', and on beta 'warn'.

The attribute scheme used here corresponds to an older version of the
RFC, with the `#[staged_api]` crate attribute toggling the staging
behavior of the stability attributes, but the user impact is only
in-tree so I'm not concerned about having to make design changes later
(and I may ultimately prefer the scheme here after all, with the
`#[staged_api]` crate attribute).

Since the Rust codebase itself makes use of unstable features the
compiler and build system to a midly elaborate dance to allow it to
bootstrap while disobeying these lints (which would otherwise be
errors because Rust builds with `-D warnings`).

This patch includes one significant hack that causes a
regression. Because the `format_args!` macro emits calls to unstable
APIs it would trigger the lint.  I added a hack to the lint to make it
not trigger, but this in turn causes arguments to `println!` not to be
checked for feature gates. I don't presently understand macro
expansion well enough to fix. This is bug #20661.

Closes #16678

[rc]: https://github.com/rust-lang/rfcs/blob/master/text/0507-release-channels.md
2015-01-07 15:34:56 -08:00
Alex Crichton 9851b4fbbf std: Tweak String implementations
This commit performs a pass over the implementations of the new `String` trait
in the formatting module. Some implementations were removed as a conservative
move pending an upcoming convention about `String` implementations, and some
were added in order to retain consistency across the libraries. Specifically:

* All "smart pointers" implement `String` now, adding missing implementations
  for `Arc` and `Rc`.
* The `Vec<T>` and `[T]` types no longer implement `String`.
* The `*const T` and `*mut T` type no longer implement `String`.
* The `()` type no longer implements `String`.
* The `Path` type's `Show` implementation does not surround itself with `Path
  {}` (a minor tweak).

All implementations of `String` in this PR were also marked `#[stable]` to
indicate that the types will continue to implement the `String` trait regardless
of what it looks like.
2015-01-07 15:24:21 -08:00
Jorge Aparicio 517f1cc63c use slicing sugar 2015-01-07 17:35:56 -05:00
Jorge Aparicio 6e2bfe4ae8 register new snapshots 2015-01-07 17:15:06 -05:00
Alex Crichton 209c701bf9 std: Stablize the macros module
This commit performs a pass over the `std::macros` module, applying stability
attributes where necessary. In particular, this audits macros for patterns such
as:

* Standard use of forward-to-format-args via `$($arg:tt)*` (or `+`)
* Prevent macro-defined identifiers from leaking into expression arguments as
  hygiene is not perfectly implemented.
* Wherever possible, `$crate` is used now.

Specifically, the following actions were taken:

* The `std::macros` module itself is no longer public.
* The `panic!` macro is stable
* The `assert!` macro is stable
* The `assert_eq!` macro is stable
* The `debug_assert!` macro is stable
* The `debug_assert_eq!` macro is stable
* The `unreachable!` macro is stable after removing the extra forms to bring the
  definition in line with the `unimplemented!` macro.
* The `try!` macro is stable
* The `vec!` macro is stable

[breaking-change]
2015-01-07 12:56:16 -08:00
Alex Crichton 511f0b8a3d std: Stabilize the std::hash module
This commit aims to prepare the `std::hash` module for alpha by formalizing its
current interface whileholding off on adding `#[stable]` to the new APIs.  The
current usage with the `HashMap` and `HashSet` types is also reconciled by
separating out composable parts of the design. The primary goal of this slight
redesign is to separate the concepts of a hasher's state from a hashing
algorithm itself.

The primary change of this commit is to separate the `Hasher` trait into a
`Hasher` and a `HashState` trait. Conceptually the old `Hasher` trait was
actually just a factory for various states, but hashing had very little control
over how these states were used. Additionally the old `Hasher` trait was
actually fairly unrelated to hashing.

This commit redesigns the existing `Hasher` trait to match what the notion of a
`Hasher` normally implies with the following definition:

    trait Hasher {
        type Output;
        fn reset(&mut self);
        fn finish(&self) -> Output;
    }

This `Hasher` trait emphasizes that hashing algorithms may produce outputs other
than a `u64`, so the output type is made generic. Other than that, however, very
little is assumed about a particular hasher. It is left up to implementors to
provide specific methods or trait implementations to feed data into a hasher.

The corresponding `Hash` trait becomes:

    trait Hash<H: Hasher> {
        fn hash(&self, &mut H);
    }

The old default of `SipState` was removed from this trait as it's not something
that we're willing to stabilize until the end of time, but the type parameter is
always required to implement `Hasher`. Note that the type parameter `H` remains
on the trait to enable multidispatch for specialization of hashing for
particular hashers.

Note that `Writer` is not mentioned in either of `Hash` or `Hasher`, it is
simply used as part `derive` and the implementations for all primitive types.

With these definitions, the old `Hasher` trait is realized as a new `HashState`
trait in the `collections::hash_state` module as an unstable addition for
now. The current definition looks like:

    trait HashState {
        type Hasher: Hasher;
        fn hasher(&self) -> Hasher;
    }

The purpose of this trait is to emphasize that the one piece of functionality
for implementors is that new instances of `Hasher` can be created.  This
conceptually represents the two keys from which more instances of a
`SipHasher` can be created, and a `HashState` is what's stored in a
`HashMap`, not a `Hasher`.

Implementors of custom hash algorithms should implement the `Hasher` trait, and
only hash algorithms intended for use in hash maps need to implement or worry
about the `HashState` trait.

The entire module and `HashState` infrastructure remains `#[unstable]` due to it
being recently redesigned, but some other stability decision made for the
`std::hash` module are:

* The `Writer` trait remains `#[experimental]` as it's intended to be replaced
  with an `io::Writer` (more details soon).
* The top-level `hash` function is `#[unstable]` as it is intended to be generic
  over the hashing algorithm instead of hardwired to `SipHasher`
* The inner `sip` module is now private as its one export, `SipHasher` is
  reexported in the `hash` module.

And finally, a few changes were made to the default parameters on `HashMap`.

* The `RandomSipHasher` default type parameter was renamed to `RandomState`.
  This renaming emphasizes that it is not a hasher, but rather just state to
  generate hashers. It also moves away from the name "sip" as it may not always
  be implemented as `SipHasher`. This type lives in the
  `std::collections::hash_map` module as `#[unstable]`

* The associated `Hasher` type of `RandomState` is creatively called...
  `Hasher`! This concrete structure lives next to `RandomState` as an
  implemenation of the "default hashing algorithm" used for a `HashMap`. Under
  the hood this is currently implemented as `SipHasher`, but it draws an
  explicit interface for now and allows us to modify the implementation over
  time if necessary.

There are many breaking changes outlined above, and as a result this commit is
a:

[breaking-change]
2015-01-07 12:18:08 -08:00
Nick Cameron dd3e89aaf2 Rename `target_word_size` to `target_pointer_width`
Closes #20421

[breaking-change]
2015-01-08 09:07:55 +13:00
Aaron Turon 7deb9abd1b Add isize, usize modules, deprecate int, uint modules
This PR introduces `isize` and `usize` modules to `core` and `std`, and
deprecates the existing `int` and `uint` modules. The rustdoc primitive
type links now point to these new modules.

Due to deprecation this is a:

[breaking-change]
2015-01-07 11:40:11 -08:00
Alex Crichton b53e9f17d3 Register new snapshots 2015-01-07 10:27:52 -08:00
bors c0216c8945 Merge pull request #20674 from jbcrail/fix-misspelled-comments
Fix misspelled comments.

Reviewed-by: steveklabnik
2015-01-07 15:35:30 +00:00
Alex Crichton a64000820f More test fixes 2015-01-06 21:26:48 -08:00
Joseph Crail e3b7fedc20 Fix misspelled comments.
I cleaned up comments prior to the 1.0 alpha release.
2015-01-06 20:53:18 -05:00
Alex Crichton 56a9e2fcd5 Test fixes and rebase conflicts 2015-01-06 16:10:37 -08:00
Alex Crichton 26cd8eae48 rollup merge of #20563: cmr/macro-input-future-proofing 2015-01-06 15:49:15 -08:00
Corey Richardson bd4119f965 Minor fallout/update FOLLOW sets 2015-01-06 18:46:37 -05:00
Alex Crichton 0393a1602f rollup merge of #20650: klutzy/omg-windows-error-mode
Believe or not, `CreateProcess()` is racy if several threads create
child processes: [0], [1], [2].

This caused some tests show crash dialogs during
`make check-stage#-rpass`.

More explanation:

On Windows, `SetErrorMode()` controls display of error dialogs: it
accepts new error mode and returns old error mode.
The error mode is process-global and automatically inherited to child
process when created.

MSYS2 bash shell internally sets it to not show error dialogs, therefore
`make check-stage#-rpass` should not show them either.

However, [1] says that `CreateProcess()` internally invokes
`SetErrorMode()` twice: at first it sets mode `0x8001` and saves
original mode, and at second it restores original mode.
So if two threads simultaneously call `CreateProcess()`, the first
thread sets error mode to `0x8001` then the second thread recognizes
that current error mode is `0x8001`. Therefore, The second thread will
create process with wrong error mode.

This really occurs inside `compiletest`: it creates several processes on
each thread, so some `run-pass` tests are invoked with wrong error mode
therefore show crash dialog.

This commit adds `StaticMutex` for `CreateProcess()` call. This seems
to fix the "dialog annoyance" issue.

[0]: http://support.microsoft.com/kb/315939
[1]: https://code.google.com/p/nativeclient/issues/detail?id=2968
[2]: https://ghc.haskell.org/trac/ghc/ticket/2650
2015-01-06 15:38:56 -08:00
Alex Crichton 36f5d122b8 rollup merge of #20615: aturon/stab-2-thread
This commit takes a first pass at stabilizing `std::thread`:

* It removes the `detach` method in favor of two constructors -- `spawn`
  for detached threads, `scoped` for "scoped" (i.e., must-join)
  threads. This addresses some of the surprise/frustrating debug
  sessions with the previous API, in which `spawn` produced a guard that
  on destruction joined the thread (unless `detach` was called).

  The reason to have the division in part is that `Send` will soon not
  imply `'static`, which means that `scoped` thread creation can take a
  closure over *shared stack data* of the parent thread. On the other
  hand, this means that the parent must not pop the relevant stack
  frames while the child thread is running. The `JoinGuard` is used to
  prevent this from happening by joining on drop (if you have not
  already explicitly `join`ed.) The APIs around `scoped` are
  future-proofed for the `Send` changes by taking an additional lifetime
  parameter. With the current definition of `Send`, this is forced to be
  `'static`, but when `Send` changes these APIs will gain their full
  flexibility immediately.

  Threads that are `spawn`ed, on the other hand, are detached from the
  start and do not yield an RAII guard.

  The hope is that, by making `scoped` an explicit opt-in with a very
  suggestive name, it will be drastically less likely to be caught by a
  surprising deadlock due to an implicit join at the end of a scope.

* The module itself is marked stable.

* Existing methods other than `spawn` and `scoped` are marked stable.

The migration path is:

```rust
Thread::spawn(f).detached()
```

becomes

```rust
Thread::spawn(f)
```

while

```rust
let res = Thread::spawn(f);
res.join()
```

becomes

```rust
let res = Thread::scoped(f);
res.join()
```

[breaking-change]
2015-01-06 15:38:38 -08:00
Alex Crichton 0631b466c2 rollup merge of #19430: pczarn/interp_tt-cleanup
Conflicts:
	src/libsyntax/parse/parser.rs
2015-01-06 15:38:10 -08:00
Alex Crichton 771fe9026a rollup merge of #20607: nrc/kinds
Conflicts:
	src/libcore/array.rs
	src/libcore/cell.rs
	src/libcore/prelude.rs
	src/libstd/path/posix.rs
	src/libstd/prelude/v1.rs
	src/test/compile-fail/dst-sized-trait-param.rs
2015-01-06 15:34:10 -08:00
Alex Crichton 3892dd1eaa rollup merge of #20593: nikomatsakis/unused-tps-in-impl
Conflicts:
	src/libcollections/lib.rs
	src/librustc/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
2015-01-06 15:31:39 -08:00
Alex Crichton e3f047c8c5 rollup merge of #20653: alexcrichton/entry-unstable
There's been some debate over the precise form that these APIs should take, and
they've undergone some changes recently, so these APIs are going to be left
unstable for now to be fleshed out during the next release cycle.
2015-01-06 15:29:18 -08:00
Alex Crichton ed61bd8693 rollup merge of #20652: vhbit/thread-key-type
This is a manual merge of #20627 and #20634 to avoid conflicts in rollup and also avoid one roundtrip. I've leave copyright to original author.  If this one is moved to rollup original PR could be closed. cc @mneumann

@alexcrichton r?

Both FreeBSD and DragonFly define pthread_key_t as int, while Linux
defines it as uint. As pthread_key_t is used as an opaque type and
storage size of both int and uint are the same, this is rather a
cosmetic change.

iOS uses ulong (as OS X) so difference is critical on 64bit platforms.
2015-01-06 15:29:17 -08:00
Alex Crichton acc5d7914a rollup merge of #20647: aturon/stab-2-error
This commit is a first past stabilization of `std::error`:

* The module is stable.
* The `FromError` trait and impls are stable
* The `Error` trait itself is left unstable, pending current APIs and
  possible revisions during the alpha cycle.
2015-01-06 15:29:15 -08:00
Alex Crichton 6ccfd3f2c8 rollup merge of #20612: retep998/winsize
This calculates the width and height using the bounding box of the window in the buffer. Bounding box coordinates are inclusive so I have to add 1 to both dimensions.
2015-01-06 15:24:58 -08:00
Piotr Czarnecki d85c017f92 Cleanup and followup to PR #17830: parsing changes
Prevents breaking down `$name` tokens into separate `$` and `name`.
Reports unknown macro variables.

Fixes #18775
Fixes #18839
Fixes #15640
2015-01-07 00:24:48 +01:00
Alex Crichton e2f97f51ad Register new snapshots
Conflicts:
	src/librbml/lib.rs
	src/libserialize/json_stage0.rs
	src/libserialize/serialize_stage0.rs
	src/libsyntax/ast.rs
	src/libsyntax/ext/deriving/generic/mod.rs
	src/libsyntax/parse/token.rs
2015-01-06 15:24:24 -08:00
Alex Crichton 5c3ddcb15d rollup merge of #20481: seanmonstar/fmt-show-string
Conflicts:
	src/compiletest/runtest.rs
	src/libcore/fmt/mod.rs
	src/libfmt_macros/lib.rs
	src/libregex/parse.rs
	src/librustc/middle/cfg/construct.rs
	src/librustc/middle/dataflow.rs
	src/librustc/middle/infer/higher_ranked/mod.rs
	src/librustc/middle/ty.rs
	src/librustc_back/archive.rs
	src/librustc_borrowck/borrowck/fragments.rs
	src/librustc_borrowck/borrowck/gather_loans/mod.rs
	src/librustc_resolve/lib.rs
	src/librustc_trans/back/link.rs
	src/librustc_trans/save/mod.rs
	src/librustc_trans/trans/base.rs
	src/librustc_trans/trans/callee.rs
	src/librustc_trans/trans/common.rs
	src/librustc_trans/trans/consts.rs
	src/librustc_trans/trans/controlflow.rs
	src/librustc_trans/trans/debuginfo.rs
	src/librustc_trans/trans/expr.rs
	src/librustc_trans/trans/monomorphize.rs
	src/librustc_typeck/astconv.rs
	src/librustc_typeck/check/method/mod.rs
	src/librustc_typeck/check/mod.rs
	src/librustc_typeck/check/regionck.rs
	src/librustc_typeck/collect.rs
	src/libsyntax/ext/format.rs
	src/libsyntax/ext/source_util.rs
	src/libsyntax/ext/tt/transcribe.rs
	src/libsyntax/parse/mod.rs
	src/libsyntax/parse/token.rs
	src/test/run-pass/issue-8898.rs
2015-01-06 15:22:24 -08:00
Nick Cameron 9f07d055f7 markers -> marker 2015-01-07 12:10:31 +13:00
Alex Crichton 1afe8a4fb8 rollup merge of #20562: nick29581/arrays-3 2015-01-06 15:05:53 -08:00
Nick Cameron 0c7f7a5fb8 fallout 2015-01-07 12:02:52 +13:00
Aaron Turon caca9b2e71 Fallout from stabilization 2015-01-06 14:57:52 -08:00
Sean McArthur 44440e5c18 core: split into fmt::Show and fmt::String
fmt::Show is for debugging, and can and should be implemented for
all public types. This trait is used with `{:?}` syntax. There still
exists #[derive(Show)].

fmt::String is for types that faithfully be represented as a String.
Because of this, there is no way to derive fmt::String, all
implementations must be purposeful. It is used by the default format
syntax, `{}`.

This will break most instances of `{}`, since that now requires the type
to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the
correct fix. Types that were being printed specifically for users should
receive a fmt::String implementation to fix this.

Part of #20013

[breaking-change]
2015-01-06 14:49:42 -08:00
Niko Matsakis 3ed7f067dc Fix fallout in libs. For the most part I just tagged impls as `#[old_impl_check]`. 2015-01-06 17:17:48 -05:00
Nick Cameron f7ff37e4c5 Replace full slice notation with index calls 2015-01-07 10:46:33 +13:00
Nick Cameron 503709708c Change `std::kinds` to `std::markers`; flatten `std::kinds::marker`
[breaking-change]
2015-01-07 09:45:28 +13:00
Alex Crichton 169fbed251 std: Revert stability of Entry-based APIs
There's been some debate over the precise form that these APIs should take, and
they've undergone some changes recently, so these APIs are going to be left
unstable for now to be fleshed out during the next release cycle.
2015-01-06 11:59:26 -08:00
Dylan Ede 25eada1574 [breaking change] Revert Entry behaviour to take keys by value. 2015-01-06 11:59:26 -08:00
bors ea6f65c5f1 auto merge of #20633 : vhbit/rust/ios-cstring, r=brson 2015-01-06 19:47:08 +00:00
Michael Neumann 134eb0e26f Tuning pthread_key_t type
Both FreeBSD and DragonFly define pthread_key_t as int, while Linux
defines it as uint. As pthread_key_t is used as an opaque type and
storage size of both int and uint are the same, this is rather a
cosmetic change.

iOS uses ulong (as OS X) so difference is critical on 64bit platforms.
2015-01-06 20:12:19 +02:00
klutzy 68cb17097a std: prevent `CreateProcess()` race on Windows
Believe or not, `CreateProcess()` is racy if several threads create
child processes: [0], [1], [2].

This caused some tests show crash dialogs during
`make check-stage#-rpass`.

More explanation:

On Windows, `SetErrorMode()` controls display of error dialogs: it
accepts new error mode and returns old error mode.
The error mode is process-global and automatically inherited to child
process when created.

MSYS2 bash shell internally sets it to not show error dialogs, therefore
`make check-stage#-rpass` should not show them either.

However, [1] says that `CreateProcess()` internally invokes
`SetErrorMode()` twice: at first it sets mode `0x8001` and saves
original mode, and at second it restores original mode.
So if two threads simultaneously call `CreateProcess()`, the first
thread sets error mode to `0x8001` then the second thread recognizes
that current error mode is `0x8001`. Therefore, The second thread will
create process with wrong error mode.

This really occurs inside `compiletest`: it creates several processes on
each thread, so some `run-pass` tests are invoked with wrong error mode
therefore show crash dialog.

This commit adds `StaticMutex` for `CreateProcess()` call. This seems
to fix the "dialog annoyance" issue.

[0]: http://support.microsoft.com/kb/315939
[1]: https://code.google.com/p/nativeclient/issues/detail?id=2968
[2]: https://ghc.haskell.org/trac/ghc/ticket/2650
2015-01-07 03:07:49 +09:00
Aaron Turon 7de9a73ab5 Stabilize std::error
This commit is a first past stabilization of `std::error`:

* The module is stable.
* The `FromError` trait and impls are stable
* The `Error` trait itself is left unstable, pending current APIs and
  possible revisions during the alpha cycle.
2015-01-06 09:20:40 -08:00
Aaron Turon f67b81e8d4 Stabilize std::thread
This commit takes a first pass at stabilizing `std::thread`:

* It removes the `detach` method in favor of two constructors -- `spawn`
  for detached threads, `scoped` for "scoped" (i.e., must-join)
  threads. This addresses some of the surprise/frustrating debug
  sessions with the previous API, in which `spawn` produced a guard that
  on destruction joined the thread (unless `detach` was called).

  The reason to have the division in part is that `Send` will soon not
  imply `'static`, which means that `scoped` thread creation can take a
  closure over *shared stack data* of the parent thread. On the other
  hand, this means that the parent must not pop the relevant stack
  frames while the child thread is running. The `JoinGuard` is used to
  prevent this from happening by joining on drop (if you have not
  already explicitly `join`ed.) The APIs around `scoped` are
  future-proofed for the `Send` changes by taking an additional lifetime
  parameter. With the current definition of `Send`, this is forced to be
  `'static`, but when `Send` changes these APIs will gain their full
  flexibility immediately.

  Threads that are `spawn`ed, on the other hand, are detached from the
  start and do not yield an RAII guard.

  The hope is that, by making `scoped` an explicit opt-in with a very
  suggestive name, it will be drastically less likely to be caught by a
  surprising deadlock due to an implicit join at the end of a scope.

* The module itself is marked stable.

* Existing methods other than `spawn` and `scoped` are marked stable.

The migration path is:

```rust
Thread::spawn(f).detached()
```

becomes

```rust
Thread::spawn(f)
```

while

```rust
let res = Thread::spawn(f);
res.join()
```

becomes

```rust
let res = Thread::scoped(f);
res.join()
```

[breaking-change]
2015-01-06 09:04:48 -08:00
Corey Richardson e0b4287df6 Fix fallout 2015-01-06 12:04:41 -05:00
Valerii Hiora 72e08006da iOS: CString fallout 2015-01-06 15:21:04 +02:00
Huon Wilson 65922dd42d Apply stability attributes to std::num::Float. 2015-01-06 23:21:27 +11:00
Huon Wilson ae4762761c Merge core::num::Float and std::num::FloatMath.
`FloatMath` no longer exists and all functionality from both traits is
available under `Float`. Change from

    use std::num::{Float, FloatMath};

to

    use std::num::Float;

[breaking-change]
2015-01-06 23:21:27 +11:00
Huon Wilson cfb2e2acd7 num: remove deprecated functionality. 2015-01-06 23:21:01 +11:00
Alex Crichton 4b359e3aee More test fixes! 2015-01-05 22:58:37 -08:00
Peter Atashian 351e6b7255 Implement TTY::get_winsize for Windows
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-01-06 00:54:09 -05:00
Alex Crichton ee9921aaed Revert "Remove i suffix in docs"
This reverts commit f031671c6e.

Conflicts:
	src/libcollections/slice.rs
	src/libcore/iter.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/rwlock.rs
2015-01-05 19:08:37 -08:00
Alex Crichton 7975fd9cee rollup merge of #20482: kmcallister/macro-reform
Conflicts:
	src/libflate/lib.rs
	src/libstd/lib.rs
	src/libstd/macros.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/parse/parser.rs
	src/libsyntax/show_span.rs
	src/test/auxiliary/macro_crate_test.rs
	src/test/compile-fail/lint-stability.rs
	src/test/run-pass/intrinsics-math.rs
	src/test/run-pass/tcp-connect-timeouts.rs
2015-01-05 19:01:17 -08:00
Alex Crichton 384e218789 Merge remote-tracking branch 'nrc/sized-2' into rollup
Conflicts:
	src/liballoc/boxed.rs
	src/libcollections/btree/map.rs
	src/libcollections/slice.rs
	src/libcore/borrow.rs
	src/libcore/cmp.rs
	src/libcore/ops.rs
	src/libstd/c_str.rs
	src/libstd/collections/hash/map.rs
	src/libsyntax/parse/obsolete.rs
	src/test/compile-fail/unboxed-closure-sugar-default.rs
	src/test/compile-fail/unboxed-closure-sugar-equiv.rs
	src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs
	src/test/compile-fail/unboxed-closure-sugar-region.rs
	src/test/compile-fail/unsized3.rs
	src/test/run-pass/associated-types-conditional-dispatch.rs
2015-01-05 18:55:41 -08:00
Alex Crichton afbce050ca rollup merge of #20556: japaric/no-for-sized
Conflicts:
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcore/borrow.rs
	src/libcore/cmp.rs
	src/libcore/ops.rs
	src/libstd/c_str.rs
	src/test/compile-fail/issue-19009.rs
2015-01-05 18:47:45 -08:00
Alex Crichton de78419b8d rollup merge of #20581: apasel422/extend 2015-01-05 18:42:04 -08:00
Alex Crichton cda6acb2f1 rollup merge of #20566: zsiciarz/fix-stdext-docs 2015-01-05 18:41:59 -08:00
Alex Crichton 83c890b454 rollup merge of #20565: alexcrichton/missing-stability
Conflicts:
	src/libstd/sync/mpsc/mod.rs
2015-01-05 18:41:55 -08:00
Alex Crichton 2e883a5f53 rollup merge of #20560: aturon/stab-2-iter-ops-slice
Conflicts:
	src/libcollections/slice.rs
	src/libcore/iter.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/rwlock.rs
2015-01-05 18:41:20 -08:00
Alex Crichton 308c1baead rollup merge of #20538: EchoAce/issue-20529
Docs in ```tuple.rs``` edited.

Edit: for some reason commits from something else found their way into here.
2015-01-05 18:38:01 -08:00
Alex Crichton 6c2263c423 rollup merge of #20519: ville-h/rwlock-rename
Conflicts:
	src/libstd/sync/rwlock.rs
2015-01-05 18:37:58 -08:00
Alex Crichton 25d5a3a194 rollup merge of #20507: alexcrichton/issue-20444
This commit is an implementation of [RFC 494][rfc] which removes the entire
`std::c_vec` module and redesigns the `std::c_str` module as `std::ffi`.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0494-c_str-and-c_vec-stability.md

The interface of the new `CString` is outlined in the linked RFC, the primary
changes being:

* The `ToCStr` trait is gone, meaning the `with_c_str` and `to_c_str` methods
  are now gone. These two methods are replaced with a `CString::from_slice`
  method.
* The `CString` type is now just a wrapper around `Vec<u8>` with a static
  guarantee that there is a trailing nul byte with no internal nul bytes. This
  means that `CString` now implements `Deref<Target = [c_char]>`, which is where
  it gains most of its methods from. A few helper methods are added to acquire a
  slice of `u8` instead of `c_char`, as well as including a slice with the
  trailing nul byte if necessary.
* All usage of non-owned `CString` values is now done via two functions inside
  of `std::ffi`, called `c_str_to_bytes` and `c_str_to_bytes_with_nul`. These
  functions are now the one method used to convert a `*const c_char` to a Rust
  slice of `u8`.

Many more details, including newly deprecated methods, can be found linked in
the RFC. This is a:

[breaking-change]
Closes #20444
2015-01-05 18:37:22 -08:00
Alex Crichton 743d926d9e rollup merge of #20488: ltratt/nondeterministic_tempdir
The previous scheme made it possible for another user/attacker to cause the
temporary directory creation scheme to panic. All you needed to know was the pid
of the process you wanted to target ('other_pid') and the suffix it was using
(let's pretend it's 'sfx') and then code such as this would, in essence, DOS it:

    for i in range(0u, 1001) {
        let tp = &Path::new(format!("/tmp/rs-{}-{}-sfx", other_pid, i));
        match fs::mkdir(tp, io::USER_RWX) { _ => () }
    }

Since the scheme only 1000 times to create a temporary directory before dying,
the next time the attacked process called TempDir::new("sfx") after that would
typically cause a panic. Of course, you don't necessarily need an attacker to
cause such a DOS: creating 1000 temporary directories without closing any of the
previous would be enough to DOS yourself.

This patch broadly follows the OpenBSD implementation of mkstemp. It uses the
operating system's random number generator to produce random directory names
that are impractical to guess (and, just in case someone manages to do that, it
retries creating the directory for a long time before giving up; OpenBSD
retries INT_MAX times, although 1<<31 seems enough to thwart even the most
patient attacker).

As a small additional change while the file name is changing, this patch also
makes the argument that TempDir::new takes a prefix rather than a suffix.
This is because 1) it more closely matches what mkstemp and friends do 2)
if you're going to have a deterministic part of a filename, you really want it at
the beginning so that shell completion is useful.
2015-01-05 18:37:20 -08:00
Alex Crichton ca40fe0f5e rollup merge of #20483: nagisa/rng-copy
* Implement (derive) `Clone` for `ChaChaRng`, `Isaac*Rng`, `StdRng` and `ThreadRng`;
* Derive `XorShiftRng` `Clone` implementation instead of implementing it explicitly.

`OsRng` is the only Rng which does not implement `Clone` or `Copy` after this patch because of its dependence on `Reader`.

r? @huonw I guess?
2015-01-05 18:37:18 -08:00
Alex Crichton 059566b019 rollup merge of #20434: steveklabnik/five_eye
This takes advantage of integer fallback to stop recomending `i` so much.
2015-01-05 18:36:32 -08:00
Keegan McAllister 416137eb31 Modernize macro_rules! invocations
macro_rules! is like an item that defines a macro.  Other items don't have a
trailing semicolon, or use a paren-delimited body.

If there's an argument for matching the invocation syntax, e.g. parentheses for
an expr macro, then I think that applies more strongly to the *inner*
delimiters on the LHS, wrapping the individual argument patterns.
2015-01-05 18:21:14 -08:00
Keegan McAllister 0816255c80 Move #[macro_reexport] to extern crate 2015-01-05 18:21:13 -08:00
Keegan McAllister 60be2f52d2 Replace #[phase] with #[plugin] / #[macro_use] / #[no_link] 2015-01-05 18:21:13 -08:00
Nick Cameron e0684e8769 Fallout 2015-01-06 14:20:48 +13:00
Steve Klabnik f031671c6e Remove i suffix in docs 2015-01-05 17:35:16 -05:00
Aaron Turon c6f4a03d12 Stabilization of impls and fallout from stabilization 2015-01-05 14:26:04 -08:00
Jorge Aparicio 37f62ae1c0 std: remove remaining boxed closures 2015-01-05 17:22:12 -05:00
Jorge Aparicio a291a80fbe register snapshot 2015-01-05 17:22:11 -05:00
Aaron Turon cb765ce7e1 Stabilize collection modules
The earlier collections stabilization did not cover the modules
themselves. This commit marks as stable those modules whose types have
been stabilized.
2015-01-05 14:08:22 -08:00
FakeKane f7f5d0958b removing whitespace 2015-01-05 16:46:46 -05:00
FakeKane 8733b8b19c examples added for element access 2015-01-05 16:22:03 -05:00
Keegan McAllister 5bf385be6a Rename macro_escape to macro_use
In the future we want to support

    #[macro_use(foo, bar)]
    mod macros;

but it's not an essential part of macro reform.  Reserve the syntax for now.
2015-01-05 12:00:57 -08:00
Keegan McAllister fc58479323 Stop using macro_escape as an inner attribute
In preparation for the rename.
2015-01-05 12:00:57 -08:00
Keegan McAllister 73806ddd0f Use $crate and macro reexport to reduce duplicated code
Many of libstd's macros are now re-exported from libcore and libcollections.
Their libstd definitions have moved to a macros_stage0 module and can disappear
after the next snapshot.

Where the two crates had already diverged, I took the libstd versions as
they're generally newer and better-tested. See e.g. d3c831b, which was a fix to
libstd's assert_eq!() that didn't make it into libcore's.

Fixes #16806.
2015-01-05 12:00:56 -08:00
Jorge Aparicio c26f5801f5 remove unused `Sized` imports 2015-01-05 14:56:49 -05:00
Jorge Aparicio 774588fd9d sed -i -s 's/ for Sized?//g' **/*.rs 2015-01-05 14:56:49 -05:00
Andrew Paseltiner 61bb6ac9de remove unnecessary `Default` bound from `Hash{Map,Set}`'s `Extend` impl 2015-01-05 11:40:39 -05:00
Alex Crichton ec7a50d20d std: Redesign c_str and c_vec
This commit is an implementation of [RFC 494][rfc] which removes the entire
`std::c_vec` module and redesigns the `std::c_str` module as `std::ffi`.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0494-c_str-and-c_vec-stability.md

The interface of the new `CString` is outlined in the linked RFC, the primary
changes being:

* The `ToCStr` trait is gone, meaning the `with_c_str` and `to_c_str` methods
  are now gone. These two methods are replaced with a `CString::from_slice`
  method.
* The `CString` type is now just a wrapper around `Vec<u8>` with a static
  guarantee that there is a trailing nul byte with no internal nul bytes. This
  means that `CString` now implements `Deref<Target = [c_char]>`, which is where
  it gains most of its methods from. A few helper methods are added to acquire a
  slice of `u8` instead of `c_char`, as well as including a slice with the
  trailing nul byte if necessary.
* All usage of non-owned `CString` values is now done via two functions inside
  of `std::ffi`, called `c_str_to_bytes` and `c_str_to_bytes_with_nul`. These
  functions are now the one method used to convert a `*const c_char` to a Rust
  slice of `u8`.

Many more details, including newly deprecated methods, can be found linked in
the RFC. This is a:

[breaking-change]
Closes #20444
2015-01-05 08:00:13 -08:00
FakeKane 05c5b5f033 reverting other changes 2015-01-05 10:25:22 -05:00
Simonas Kazlauskas f677deeab3 Implement Clone for PRNGs 2015-01-05 13:10:27 +02:00
Laurence Tratt 2c44195895 Make temporary directory names non-deterministic.
The previous scheme made it possible for another user/attacker to cause the
temporary directory creation scheme to panic. All you needed to know was the pid
of the process you wanted to target ('other_pid') and the suffix it was using
(let's pretend it's 'sfx') and then code such as this would, in essence, DOS it:

    for i in range(0u, 1001) {
        let tp = &Path::new(format!("/tmp/rs-{}-{}-sfx", other_pid, i));
        match fs::mkdir(tp, io::USER_RWX) { _ => () }
    }

Since the scheme retried only 1000 times to create a temporary directory before
dying, the next time the attacked process called TempDir::new("sfx") after that
would typically cause a panic. Of course, you don't necessarily need an attacker
to cause such a DOS: creating 1000 temporary directories without closing any of
the previous would be enough to DOS yourself.

This patch broadly follows the OpenBSD implementation of mkstemp. It uses the
operating system's random number generator to produce random directory names
that are impractical to guess (and, just in case someone manages to do that, it
retries creating the directory for a long time before giving up; OpenBSD
retries INT_MAX times, although 1<<31 seems enough to thwart even the most
patient attacker).

As a small additional change, this patch also makes the argument that
TempDir::new takes a prefix rather than a suffix. This is because 1) it more
closely matches what mkstemp and friends do 2) if you're going to have a
deterministic part of a filename, you really want it at the beginning so that
shell completion is useful.
2015-01-05 10:19:19 +00:00
Zbigniew Siciarz 73019ac10e Fix misleading name in AsciiExt docs 2015-01-05 08:44:18 +01:00
Alex Crichton dc246ae018 std: Fix missing stability on prelude
The module itself is stable (the name)
2015-01-04 23:40:07 -08:00
Alex Crichton 177f8bc55c std: Fix missing stability in sync
* The `sync` module is stable
* The `sync::mpsc` module is stable
* The `Sender::send` method is stable.
* The `Once::doit` method is now removed.
* Deprecated atomic initializers are removed.
* Renamed atomic initializers are now stable.
2015-01-04 23:38:46 -08:00
bors 1f732ef53d auto merge of #20395 : huonw/rust/char-stab-2, r=aturon
cc #19260 

The casing transformations are left unstable (it is highly likely to be better to adopt the proper non-1-to-1 case mappings, per #20333) as are `is_xid_*`.

I've got a little todo list in the last commit of things I thought about/was told about that I haven't yet handled (I'd also like some feedback).
2015-01-05 06:45:39 +00:00
Huon Wilson 0302d37977 Merge `UnicodeChar` and `CharExt`.
This "reexports" all the functionality of `core::char::CharExt` as
methods on `unicode::u_char::UnicodeChar` (renamed to `CharExt`).

Imports may need to be updated (one now just imports
`unicode::CharExt`, or `std::char::CharExt` rather than two traits from
either), so this is a

[breaking-change]
2015-01-05 12:30:51 +11:00
Huon Wilson 19120209d8 Rename `core::char::Char` to `CharExt` to match prelude guidelines.
Imports may need to be updated so this is a

[breaking-change]
2015-01-05 12:30:30 +11:00
bors ad9e759382 auto merge of #20163 : bfops/rust/master, r=Gankro
TODOs:
  - ~~Entry is still `<'a, K, V>` instead of `<'a, O, V>`~~
  - ~~BTreeMap is still outstanding~~.
  - ~~Transform appropriate things into `.entry(...).get().or_else(|e| ...)`~~

Things that make me frowny face:
  - I'm not happy about the fact that this `clone`s the key even when it's already owned.
  - With small keys (e.g. `int`s), taking a reference seems wasteful.

r? @Gankro
cc: @cgaebel
2015-01-05 00:26:28 +00:00
bors 0fd2c84c6f Merge pull request #20510 from tshepang/patch-6
doc: remove incomplete sentence

Reviewed-by: steveklabnik, steveklabnik
2015-01-04 21:36:40 +00:00
bors 05abc65b99 Merge pull request #20464 from ranma42/improve-make-hash
Improve `make_hash` function

Reviewed-by: Gankro, Gankro
2015-01-04 21:36:36 +00:00
Ben Foppa 400c3a0ddc [breaking change] Update entry API as part of RFC 509. 2015-01-04 15:55:54 -05:00
ville-h fee1f2ade9 fix comment referencing RwLock 2015-01-04 13:26:25 +02:00
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