Commit Graph

204 Commits

Author SHA1 Message Date
Jorge Aparicio fd702702ee `for x in xs.into_iter()` -> `for x in xs`
Also `for x in option.into_iter()` -> `if let Some(x) = option`
2015-02-02 13:40:18 -05:00
Alex Crichton 188d7c0bc3 rollup merge of #21631: tbu-/isize_police
Conflicts:
	src/libcoretest/iter.rs
2015-01-30 13:27:02 -08:00
Alex Crichton 6227357513 std: Stabilize the std::fmt module
This commit performs a final stabilization pass over the std::fmt module,
marking all necessary APIs as stable. One of the more interesting aspects of
this module is that it exposes a good deal of its runtime representation to the
outside world in order for `format_args!` to be able to construct the format
strings. Instead of hacking the compiler to assume that these items are stable,
this commit instead lays out a story for the stabilization and evolution of
these APIs.

There are three primary details used by the `format_args!` macro:

1. `Arguments` - an opaque package of a "compiled format string". This structure
   is passed around and the `write` function is the source of truth for
   transforming a compiled format string into a string at runtime. This must be
   able to be constructed in stable code.

2. `Argument` - an opaque structure representing an argument to a format string.
   This is *almost* a trait object as it's just a pointer/function pair, but due
   to the function originating from one of many traits, it's not actually a
   trait object. Like `Arguments`, this must be constructed from stable code.

3. `fmt::rt` - this module contains the runtime type definitions primarily for
   the `rt::Argument` structure. Whenever an argument is formatted with
   nonstandard flags, a corresponding `rt::Argument` is generated describing how
   the argument is being formatted. This can be used to construct an
   `Arguments`.

The primary interface to `std::fmt` is the `Arguments` structure, and as such
this type name is stabilize as-is today. It is expected for libraries to pass
around an `Arguments` structure to represent a pending formatted computation.

The remaining portions are largely "cruft" which would rather not be stabilized,
but due to the stability checks they must be. As a result, almost all pieces
have been renamed to represent that they are "version 1" of the formatting
representation. The theory is that at a later date if we change the
representation of these types we can add new definitions called "version 2" and
corresponding constructors for `Arguments`.

One of the other remaining large questions about the fmt module were how the
pending I/O reform would affect the signatures of methods in the module. Due to
[RFC 526][rfc], however, the writers of fmt are now incompatible with the
writers of io, so this question has largely been solved. As a result the
interfaces are largely stabilized as-is today.

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

Specifically, the following changes were made:

* The contents of `fmt::rt` were all moved under `fmt::rt::v1`
* `fmt::rt` is stable
* `fmt::rt::v1` is stable
* `Error` is stable
* `Writer` is stable
* `Writer::write_str` is stable
* `Writer::write_fmt` is stable
* `Formatter` is stable
* `Argument` has been renamed to `ArgumentV1` and is stable
* `ArgumentV1::new` is stable
* `ArgumentV1::from_uint` is stable
* `Arguments::new_v1` is stable (renamed from `new`)
* `Arguments::new_v1_formatted` is stable (renamed from `with_placeholders`)
* All formatting traits are now stable, as well as the `fmt` method.
* `fmt::write` is stable
* `fmt::format` is stable
* `Formatter::pad_integral` is stable
* `Formatter::pad` is stable
* `Formatter::write_str` is stable
* `Formatter::write_fmt` is stable
* Some assorted top level items which were only used by `format_args!` were
  removed in favor of static functions on `ArgumentV1` as well.
* The formatting-flag-accessing methods remain unstable

Within the contents of the `fmt::rt::v1` module, the following actions were
taken:

* Reexports of all enum variants were removed
* All prefixes on enum variants were removed
* A few miscellaneous enum variants were renamed
* Otherwise all structs, fields, and variants were marked stable.

In addition to these actions in the `std::fmt` module, many implementations of
`Show` and `String` were stabilized as well.

In some other modules:

* `ToString` is now stable
* `ToString::to_string` is now stable
* `Vec` no longer implements `fmt::Writer` (this has moved to `String`)

This is a breaking change due to all of the changes to the `fmt::rt` module, but
this likely will not have much impact on existing programs.

Closes #20661
[breaking-change]
2015-01-30 09:21:56 -08:00
Tobias Bucher 7f64fe4e27 Remove all `i` suffixes 2015-01-30 04:38:54 +01:00
Jorge Aparicio 788181d405 s/Show/Debug/g 2015-01-29 07:49:02 -05:00
Jorge Aparicio efc97a51ff convert remaining `range(a, b)` to `a..b` 2015-01-29 07:49:01 -05:00
Jorge Aparicio 7d661af9c8 `for x in range(a, b)` -> `for x in a..b`
sed -i 's/in range(\([^,]*\), *\([^()]*\))/in \1\.\.\2/g' **/*.rs
2015-01-29 07:47:37 -05:00
Jorge Aparicio c300d681bd `range(a, b).foo()` -> `(a..b).foo()`
sed -i 's/ range(\([^,]*\), *\([^()]*\))\./ (\1\.\.\2)\./g' **/*.rs
2015-01-29 07:46:44 -05:00
Brian Anderson 7122305053 Merge remote-tracking branch 'rust-lang/master'
Conflicts:
	src/libcore/cell.rs
	src/librustc_driver/test.rs
	src/libstd/old_io/net/tcp.rs
	src/libstd/old_io/process.rs
2015-01-27 15:05:04 -08:00
Alex Crichton 3a07f859b8 Fallout of io => old_io 2015-01-26 16:01:16 -08:00
Brian Anderson d179ba3b8e Merge remote-tracking branch 'rust-lang/master'
Conflicts:
	src/libcore/cmp.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/num/f32.rs
	src/libcore/num/f64.rs
	src/libcore/result.rs
	src/libcore/str/mod.rs
	src/librustc/lint/builtin.rs
	src/librustc/lint/context.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/poison.rs
2015-01-25 22:14:06 -08:00
Brian Anderson 63fcbcf3ce Merge remote-tracking branch 'rust-lang/master'
Conflicts:
	mk/tests.mk
	src/liballoc/arc.rs
	src/liballoc/boxed.rs
	src/liballoc/rc.rs
	src/libcollections/bit.rs
	src/libcollections/btree/map.rs
	src/libcollections/btree/set.rs
	src/libcollections/dlist.rs
	src/libcollections/ring_buf.rs
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/libcollections/vec_map.rs
	src/libcore/any.rs
	src/libcore/array.rs
	src/libcore/borrow.rs
	src/libcore/error.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/ops.rs
	src/libcore/result.rs
	src/libcore/slice.rs
	src/libcore/str/mod.rs
	src/libregex/lib.rs
	src/libregex/re.rs
	src/librustc/lint/builtin.rs
	src/libstd/collections/hash/map.rs
	src/libstd/collections/hash/set.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/poison.rs
	src/libstd/sync/rwlock.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/test.rs
2015-01-25 01:20:55 -08:00
Brian Anderson b44ee371b8 grandfathered -> rust1 2015-01-23 21:48:20 -08:00
Brian Anderson 9758c488a9 Deprecated attributes don't take 'feature' names and are paired with stable/unstable
Conflicts:
	src/libcore/atomic.rs
	src/libcore/finally.rs
	src/test/auxiliary/inherited_stability.rs
	src/test/auxiliary/lint_stability.rs
2015-01-23 15:50:03 -08:00
Alex Crichton 08246520c0 std: Relax Result::unwrap() to Debug
This commit relaxes the bound on `Result::unwrap` and `Result::unwrap_err` from
the `Display` trait to the `Debug` trait for generating an error message about
the unwrapping operation.

This commit is a breaking change and any breakage should be mitigated by
ensuring that `Debug` is implemented on the relevant type.

[breaking-change]
2015-01-23 14:11:34 -08:00
Brian Anderson cd6d9eab5d Set unstable feature names appropriately
* `core` - for the core crate
* `hash` - hashing
* `io` - io
* `path` - path
* `alloc` - alloc crate
* `rand` - rand crate
* `collections` - collections crate
* `std_misc` - other parts of std
* `test` - test crate
* `rustc_private` - everything else
2015-01-23 13:28:40 -08:00
Steve Klabnik 22ed381ada Rollup merge of #21477 - steveklabnik:gh21440, r=alexcrichton
Fixes #21440"
2015-01-22 18:09:59 -05:00
Brian Anderson 41278c5441 Remove 'since' from unstable attributes 2015-01-21 19:25:55 -08:00
Brian Anderson 94ca8a3610 Add 'feature' and 'since' to stability attributes 2015-01-21 16:16:18 -08:00
Steve Klabnik bbbdd1086c Improve RwLock::new's docs
Fixes #21440"
2015-01-21 14:54:52 -05:00
Alex Crichton 4ffde0814f Test fixes and rebase conflicts 2015-01-21 10:32:56 -08:00
Alex Crichton 87c3ee861e rollup merge of #21457: alexcrichton/issue-21436
Conflicts:
	src/liballoc/boxed.rs
	src/librustc/middle/traits/error_reporting.rs
	src/libstd/sync/mpsc/mod.rs
2015-01-21 09:20:35 -08:00
Alex Crichton 907db6c834 rollup merge of #21444: petrochenkov/null
Conflicts:
	src/libstd/sync/mpsc/select.rs
2015-01-21 09:18:07 -08:00
Alex Crichton 27838075e0 rollup merge of #21438: taralx/kill-racycell
Conflicts:
	src/libstd/sync/mpsc/mod.rs
2015-01-21 09:17:40 -08:00
Alex Crichton 04a2255739 rollup merge of #21437: FlaPer87/snapshot
r? @alexcrichton
2015-01-21 09:16:40 -08:00
Alex Crichton 3cb9fa26ef std: Rename Show/String to Debug/Display
This commit is an implementation of [RFC 565][rfc] which is a stabilization of
the `std::fmt` module and the implementations of various formatting traits.
Specifically, the following changes were performed:

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md

* The `Show` trait is now deprecated, it was renamed to `Debug`
* The `String` trait is now deprecated, it was renamed to `Display`
* Many `Debug` and `Display` implementations were audited in accordance with the
  RFC and audited implementations now have the `#[stable]` attribute
  * Integers and floats no longer print a suffix
  * Smart pointers no longer print details that they are a smart pointer
  * Paths with `Debug` are now quoted and escape characters
* The `unwrap` methods on `Result` now require `Display` instead of `Debug`
* The `Error` trait no longer has a `detail` method and now requires that
  `Display` must be implemented. With the loss of `String`, this has moved into
  libcore.
* `impl<E: Error> FromError<E> for Box<Error>` now exists
* `derive(Show)` has been renamed to `derive(Debug)`. This is not currently
  warned about due to warnings being emitted on stage1+

While backwards compatibility is attempted to be maintained with a blanket
implementation of `Display` for the old `String` trait (and the same for
`Show`/`Debug`) this is still a breaking change due to primitives no longer
implementing `String` as well as modifications such as `unwrap` and the `Error`
trait. Most code is fairly straightforward to update with a rename or tweaks of
method calls.

[breaking-change]
Closes #21436
2015-01-20 22:36:13 -08:00
bors 51e28dd0c8 Auto merge of #21395 - sfackler:fix-cvar-test, r=alexcrichton
r? @alexcrichton
2015-01-21 05:55:02 +00:00
Flavio Percoco cd631c6914 Register snapshot for 9006c3c 2015-01-20 22:15:44 +01:00
JP Sugarbroad b6380f5c67 Kill RacyCell in favor of marking SyncSender explicitly Send. 2015-01-20 12:34:18 -08:00
Steven Fackler 2854f0c75e Fix flaky condvar test 2015-01-19 09:11:06 -08:00
we 2c2480df5d Replace `0 as *const/mut T` with `ptr::null/null_mut()` 2015-01-19 08:27:09 +03:00
Michael Sproul ffdf1118d5 Implement the error trait for errors in std::sync. 2015-01-17 14:35:16 -08:00
Steve Klabnik 078bd498b9 Evaluate # fn in docs
I searched for times when we were hiding functions with # in the documentation,
and fixed them to not use it unless neccesary.

I also made random improvements whenever I changed something. For example,
I changed Example to Examples, for consistency.

Fixes #13423
2015-01-17 10:49:49 -05:00
bors 378fb5846d auto merge of #21132 : sfackler/rust/wait_timeout, r=alexcrichton
**The implementation is a direct adaptation of libcxx's condition_variable implementation.**

I also added a wait_timeout_with method, which matches the second overload in C++'s condition_variable. The implementation right now is kind of dumb but it works. There is an outstanding issue with it: as is it doesn't support the use case where a user doesn't care about poisoning and wants to continue through poison.

r? @alexcrichton @aturon
2015-01-17 03:51:34 +00:00
Steven Fackler 08f6380a9f Rewrite Condvar::wait_timeout and make it public
**The implementation is a direct adaptation of libcxx's
condition_variable implementation.**

pthread_cond_timedwait uses the non-monotonic system clock. It's
possible to change the clock to a monotonic via pthread_cond_attr, but
this is incompatible with static initialization. To deal with this, we
calculate the timeout using the system clock, and maintain a separate
record of the start and end times with a monotonic clock to be used for
calculation of the return value.
2015-01-16 09:17:37 -08:00
bors ee2bfae011 auto merge of #20972 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis
This PR adds rules for negative implementations. It follows pretty much what the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md) says with 1 main difference:

Instead of positive implementations override negative implementations, this have been implemented in a way that a negative implementation of `Trait` for `T` will overlap with a positive implementation, causing a coherence error.

@nikomatsakis r?

cc #13231

[breaking-change]
2015-01-16 13:10:59 +00:00
Flavio Percoco c6ab9a6370 Don't use NoSend/NoSync in libstd 2015-01-16 08:18:56 +01:00
Fenhl 5f34815a22 Fix sync::condvar::Condvar::notify_one docs 2015-01-15 22:43:12 +00:00
Steven Fackler 8b6cda3ce6 Rename AtomicInt and AtomicUint
Change any use of AtomicInt to AtomicIsize and AtomicUint to AtomicUsize

Closes #20893

[breaking-change]
2015-01-11 11:47:44 -08:00
Brian Anderson 1f70acbf4c Improvements to feature staging
This gets rid of the 'experimental' level, removes the non-staged_api
case (i.e. stability levels for out-of-tree crates), and lets the
staged_api attributes use 'unstable' and 'deprecated' lints.

This makes the transition period to the full feature staging design
a bit nicer.
2015-01-08 03:07:23 -08:00
Jorge Aparicio 7d72719efc fix the `&mut _` patterns 2015-01-07 19:26:36 -05:00
Alex Crichton a64000820f More test fixes 2015-01-06 21:26:48 -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 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
Nick Cameron 9f07d055f7 markers -> marker 2015-01-07 12:10:31 +13:00
Aaron Turon caca9b2e71 Fallout from stabilization 2015-01-06 14:57:52 -08: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 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 83c890b454 rollup merge of #20565: alexcrichton/missing-stability
Conflicts:
	src/libstd/sync/mpsc/mod.rs
2015-01-05 18:41:55 -08:00