Commit Graph

5558 Commits

Author SHA1 Message Date
Alex Crichton 03ec8e5cc9 std: Rebase better errors on master 2014-06-13 13:53:34 -07:00
Yehuda Katz 298412a6e8 Improve error messages for io::fs 2014-06-13 13:53:34 -07:00
bors 0422934e24 auto merge of #14831 : alexcrichton/rust/format-intl, r=brson
* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
2014-06-13 14:42:03 +00:00
bors 7c7f4b0e0b auto merge of #14816 : theptrk/rust/unclear-comment, r=huonw
The old comment left it unclear if this is creating a random value or doing a check as to whether or not the generator is available or some other operation.

See: http://stackoverflow.com/questions/24153311/when-is-rng-gen-not-true
2014-06-13 00:07:05 +00:00
bors f03863ae7d auto merge of #14713 : darnuria/rust/Improve_std_os_documentation_#2, r=alexcrichton
Improving documentation, consistency, removes evils empty lines etc...
2014-06-11 19:06:58 -07:00
Axel Viala 6dc06249d7 Improve docs and refactore std::os. 2014-06-12 02:17:52 +02:00
Alex Crichton cac7a2053a std: Remove i18n/l10n from format!
* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
2014-06-11 16:04:24 -07:00
Alex Crichton 3316b1eb7c rustc: Remove ~[T] from the language
The following features have been removed

* box [a, b, c]
* ~[a, b, c]
* box [a, ..N]
* ~[a, ..N]
* ~[T] (as a type)
* deprecated_owned_vector lint

All users of ~[T] should move to using Vec<T> instead.
2014-06-11 15:02:17 -07:00
bors f9260d41d6 auto merge of #14746 : alexcrichton/rust/libsync, r=brson
This commit is the final step in the libstd facade, #13851. The purpose of this
commit is to move libsync underneath the standard library, behind the facade.
This will allow core primitives like channels, queues, and atomics to all live
in the same location.

There were a few notable changes and a few breaking changes as part of this
movement:

* The `Vec` and `String` types are reexported at the top level of libcollections
* The `unreachable!()` macro was copied to libcore
* The `std::rt::thread` module was moved to librustrt, but it is still
  reexported at the same location.
* The `std::comm` module was moved to libsync
* The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`.
  It is now a private module with types/functions being reexported under
  `sync::comm`. This is a breaking change for any existing users of duplex
  streams.
* All concurrent queues/deques were moved directly under libsync. They are also
  all marked with #![experimental] for now if they are public.
* The `task_pool` and `future` modules no longer live in libsync, but rather
  live under `std::sync`. They will forever live at this location, but they may
  move to libsync if the `std::task` module moves as well.

[breaking-change]
2014-06-11 11:47:04 -07:00
bors f0f9095f1d auto merge of #14250 : alexcrichton/rust/gc, r=brson
This commit removes `@T` from the compiler by moving the AST to using `Gc<T>`. This also starts treating `Gc<T>` as `@T` in the same way that `Box<T>` is the same as `~T` in the compiler.

After this hits a snapshot, the `@T` syntax should be able to be removed completely.
2014-06-11 10:02:04 -07:00
Alex Crichton b1c9ce9c6f sync: Move underneath libstd
This commit is the final step in the libstd facade, #13851. The purpose of this
commit is to move libsync underneath the standard library, behind the facade.
This will allow core primitives like channels, queues, and atomics to all live
in the same location.

There were a few notable changes and a few breaking changes as part of this
movement:

* The `Vec` and `String` types are reexported at the top level of libcollections
* The `unreachable!()` macro was copied to libcore
* The `std::rt::thread` module was moved to librustrt, but it is still
  reexported at the same location.
* The `std::comm` module was moved to libsync
* The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`.
  It is now a private module with types/functions being reexported under
  `sync::comm`. This is a breaking change for any existing users of duplex
  streams.
* All concurrent queues/deques were moved directly under libsync. They are also
  all marked with #![experimental] for now if they are public.
* The `task_pool` and `future` modules no longer live in libsync, but rather
  live under `std::sync`. They will forever live at this location, but they may
  move to libsync if the `std::task` module moves as well.

[breaking-change]
2014-06-11 10:00:43 -07:00
Alex Crichton 54c2a1e1ce rustc: Move the AST from @T to Gc<T> 2014-06-11 09:51:37 -07:00
Alex Crichton 531ed3d599 rustc: Update how Gc<T> is recognized
This commit uses the same trick as ~/Box to map Gc<T> to @T internally inside
the compiler. This moves a number of implementations of traits to the `gc`
module in the standard library.

This removes functions such as `Gc::new`, `Gc::borrow`, and `Gc::ptr_eq` in
favor of the more modern equivalents, `box(GC)`, `Deref`, and pointer equality.

The Gc pointer itself should be much more useful now, and subsequent commits
will move the compiler away from @T towards Gc<T>

[breaking-change]
2014-06-11 09:11:40 -07:00
bors c54ce27b39 auto merge of #14789 : aochagavia/rust/prelude, r=alexcrichton 2014-06-11 07:42:07 -07:00
theptrk f3020c3f1f Fix unclear wording of comment 2014-06-10 20:29:09 -07:00
bors b1302f9c4f auto merge of #14764 : jbcrail/rust/fix-more-comments, r=alexcrichton 2014-06-10 15:17:01 -07:00
bors 9bb8f88d3a auto merge of #14696 : jakub-/rust/dead-struct-fields, r=alexcrichton
This uncovered some dead code, most notably in middle/liveness.rs, which I think suggests there must be something fishy with that part of the code.

The #[allow(dead_code)] annotations on some of the fields I am not super happy about but as I understand, marker type may disappear at some point.
2014-06-10 09:49:29 -07:00
Joseph Crail c2c9946372 Fix more misspelled comments and strings. 2014-06-10 11:24:17 -04:00
Adolfo Ochagavía 02866e6fe2 Pub use CheckedDiv in the prelude 2014-06-10 10:01:49 +02:00
Huon Wilson 14668f2791 std: adjust the TCP io doc example to work reliably.
Fixes #11576 by making the code never run (and hence never
pass when the test was marked `should_fail`).
2014-06-09 17:46:53 -07:00
Brian Anderson 1635ef2a19 std: Move dynamic_lib from std::unstable to std
This leaves a deprecated reexport in place temporarily.

Closes #1457.
2014-06-09 17:46:53 -07:00
Alex Crichton d42cc130f9 std: Remove the as_utf16_p functions
These functions are all much better expressed via RAII using the to_utf16()
method on strings. This refactoring also takes this opportunity to properly
handle when filenames aren't valid unicode when passed through to the windows
I/O layer by properly returning I/O errors.

All previous users of the `as_utf16_p` or `as_utf16_mut_p` functions will need
to convert their code to using `foo.to_utf16().append_one(0)` to get a
null-terminated utf16 string.

[breaking-change]
2014-06-09 17:46:27 -07:00
bors 0ea7aa30cc auto merge of #14554 : kmcallister/rust/plugin_registrar, r=cmr
This implements the design in rust-lang/rfcs#86.  It shouldn't be merged until that RFC is accepted, but it would be great if somebody has time to review the code before then.
2014-06-09 15:52:07 -07:00
Keegan McAllister ffb2f12ed8 Use phase(plugin) in bootstrap crates
Do this to avoid warnings on post-stage0 builds.
2014-06-09 14:29:30 -07:00
Alex Crichton a7872b3c1e std: Read HOME instead of USER
Apparently one of the linux bots doesn't have the USER variable defined, and
this fix will likely land more quickly than a fix to the bots.
2014-06-09 12:44:45 -07:00
bors e55f64f997 auto merge of #14709 : alexcrichton/rust/collections, r=brson
This is mostly just a cosmetic change, continuing the work from #14333.
2014-06-09 01:11:58 -07:00
Alex Crichton da0703973a core: Move the collections traits to libcollections
This commit moves Mutable, Map, MutableMap, Set, and MutableSet from
`core::collections` to the `collections` crate at the top-level. Additionally,
this removes the `deque` module and moves the `Deque` trait to only being
available at the top-level of the collections crate.

All functionality continues to be reexported through `std::collections`.

[breaking-change]
2014-06-09 00:38:46 -07:00
Brian Anderson 50942c7695 core: Rename `container` mod to `collections`. Closes #12543
Also renames the `Container` trait to `Collection`.

[breaking-change]
2014-06-08 21:29:57 -07:00
bors 61d65cd56e auto merge of #14765 : rapha/rust/master, r=alexcrichton 2014-06-08 21:26:59 -07:00
Raphael Speyer 1638c4b749 Converted PortReader and ChanWriter to use Vec. 2014-06-09 14:18:11 +10:00
Joseph Crail 45e56eccbe Fix spelling errors in comments. 2014-06-08 13:39:42 -04:00
Jakub Wieczorek f7d86b2f4a Remove the dead code identified by the new lint 2014-06-08 13:36:28 +02:00
Huon Wilson e8d180df46 std::io: expand the oneshot/periodic docs.
Examples!

Fixes #14714.
2014-06-08 18:32:15 +10:00
Alex Crichton 75014f7b17 libs: Fix miscellaneous fallout of librustrt 2014-06-06 23:00:01 -07:00
Alex Crichton da2293c6f6 std: Deal with fallout of rtio changes 2014-06-06 22:19:57 -07:00
Alex Crichton 5ec36c358f std: Extract librustrt out of libstd
As part of the libstd facade efforts, this commit extracts the runtime interface
out of the standard library into a standalone crate, librustrt. This crate will
provide the following services:

* Definition of the rtio interface
* Definition of the Runtime interface
* Implementation of the Task structure
* Implementation of task-local-data
* Implementation of task failure via unwinding via libunwind
* Implementation of runtime initialization and shutdown
* Implementation of thread-local-storage for the local rust Task

Notably, this crate avoids the following services:

* Thread creation and destruction. The crate does not require the knowledge of
  an OS threading system, and as a result it seemed best to leave out the
  `rt::thread` module from librustrt. The librustrt module does depend on
  mutexes, however.
* Implementation of backtraces. There is no inherent requirement for the runtime
  to be able to generate backtraces. As will be discussed later, this
  functionality continues to live in libstd rather than librustrt.

As usual, a number of architectural changes were required to make this crate
possible. Users of "stable" functionality will not be impacted by this change,
but users of the `std::rt` module will likely note the changes. A list of
architectural changes made is:

* The stdout/stderr handles no longer live directly inside of the `Task`
  structure. This is a consequence of librustrt not knowing about `std::io`.
  These two handles are now stored inside of task-local-data.

  The handles were originally stored inside of the `Task` for perf reasons, and
  TLD is not currently as fast as it could be. For comparison, 100k prints goes
  from 59ms to 68ms (a 15% slowdown). This appeared to me to be an acceptable
  perf loss for the successful extraction of a librustrt crate.

* The `rtio` module was forced to duplicate more functionality of `std::io`. As
  the module no longer depends on `std::io`, `rtio` now defines structures such
  as socket addresses, addrinfo fiddly bits, etc. The primary change made was
  that `rtio` now defines its own `IoError` type. This type is distinct from
  `std::io::IoError` in that it does not have an enum for what error occurred,
  but rather a platform-specific error code.

  The native and green libraries will be updated in later commits for this
  change, and the bulk of this effort was put behind updating the two libraries
  for this change (with `rtio`).

* Printing a message on task failure (along with the backtrace) continues to
  live in libstd, not in librustrt. This is a consequence of the above decision
  to move the stdout/stderr handles to TLD rather than inside the `Task` itself.
  The unwinding API now supports registration of global callback functions which
  will be invoked when a task fails, allowing for libstd to register a function
  to print a message and a backtrace.

  The API for registering a callback is experimental and unsafe, as the
  ramifications of running code on unwinding is pretty hairy.

* The `std::unstable::mutex` module has moved to `std::rt::mutex`.

* The `std::unstable::sync` module has been moved to `std::rt::exclusive` and
  the type has been rewritten to not internally have an Arc and to have an RAII
  guard structure when locking. Old code should stop using `Exclusive` in favor
  of the primitives in `libsync`, but if necessary, old code should port to
  `Arc<Exclusive<T>>`.

* The local heap has been stripped down to have fewer debugging options. None of
  these were tested, and none of these have been used in a very long time.

[breaking-change]
2014-06-06 22:19:41 -07:00
Alex Crichton a3f9aa9ef8 rtio: Remove usage of `Path`
The rtio interface is a thin low-level interface over the I/O subsystems, and
the `Path` type is a little too high-level for this interface.
2014-06-06 22:19:41 -07:00
Alex Crichton b830b4b86b rtio: Remove unused stuct 2014-06-06 22:19:41 -07:00
Alex Crichton 8bf6da0836 Test fixes from the rollup 2014-06-06 20:37:26 -07:00
Alex Crichton e5bbbca33e rustdoc: Submit examples to play.rust-lang.org
This grows a new option inside of rustdoc to add the ability to submit examples
to an external website. If the `--markdown-playground-url` command line option
or crate doc attribute `html_playground_url` is present, then examples will have
a button on hover to submit the code to the playground specified.

This commit enables submission of example code to play.rust-lang.org. The code
submitted is that which is tested by rustdoc, not necessarily the exact code
shown in the example.

Closes #14654
2014-06-06 20:00:16 -07:00
Axel Viala 5915763106 Removing unused wrapper to libc::close. 2014-06-06 19:52:25 -07:00
Alex Crichton cb12e7ab74 mk: Run doc tests with --cfg dox
There were a few examples in the macros::builtin module that weren't being run
because they were being #[cfg]'d out.

Closes #14697
2014-06-06 19:51:52 -07:00
Steven Fackler b662aa5ec0 Implement Eq for HashSet and HashMap
Also fix documentation references to PartialEq.
2014-06-06 19:51:37 -07:00
Aaron Turon 1bde6e3fcb Rename Iterator::len to count
This commit carries out the request from issue #14678:

> The method `Iterator::len()` is surprising, as all the other uses of
> `len()` do not consume the value. `len()` would make more sense to be
> called `count()`, but that would collide with the current
> `Iterator::count(|T| -> bool) -> unit` method. That method, however, is
> a bit redundant, and can be easily replaced with
> `iter.filter(|x| x < 5).count()`.
> After this change, we could then define the `len()` method
> on `iter::ExactSize`.

Closes #14678.

[breaking-change]
2014-06-06 19:51:31 -07:00
fort 1bc29924dc Remove reference to ~str in documentation 2014-06-06 19:51:26 -07:00
bors 124e997f36 auto merge of #14676 : brson/rust/double-rainbow, r=alexcrichton 2014-06-06 08:07:07 -07:00
bors 5ec49c7924 auto merge of #14641 : darnuria/rust/add_documentation_to_std_os, r=alexcrichton
Just opening a pull request for adding code examples and documentation to std::os.

More to come soon.
2014-06-05 16:41:53 -07:00
Alex Crichton 760b93adc0 Fallout from the libcollections movement 2014-06-05 13:55:11 -07:00
Alex Crichton 6a585375a0 std: Recreate a `collections` module
As with the previous commit with `librand`, this commit shuffles around some
`collections` code. The new state of the world is similar to that of librand:

* The libcollections crate now only depends on libcore and liballoc.
* The standard library has a new module, `std::collections`. All functionality
  of libcollections is reexported through this module.

I would like to stress that this change is purely cosmetic. There are very few
alterations to these primitives.

There are a number of notable points about the new organization:

* std::{str, slice, string, vec} all moved to libcollections. There is no reason
  that these primitives shouldn't be necessarily usable in a freestanding
  context that has allocation. These are all reexported in their usual places in
  the standard library.

* The `hashmap`, and transitively the `lru_cache`, modules no longer reside in
  `libcollections`, but rather in libstd. The reason for this is because the
  `HashMap::new` contructor requires access to the OSRng for initially seeding
  the hash map. Beyond this requirement, there is no reason that the hashmap
  could not move to libcollections.

  I do, however, have a plan to move the hash map to the collections module. The
  `HashMap::new` function could be altered to require that the `H` hasher
  parameter ascribe to the `Default` trait, allowing the entire `hashmap` module
  to live in libcollections. The key idea would be that the default hasher would
  be different in libstd. Something along the lines of:

      // src/libstd/collections/mod.rs

      pub type HashMap<K, V, H = RandomizedSipHasher> =
            core_collections::HashMap<K, V, H>;

  This is not possible today because you cannot invoke static methods through
  type aliases. If we modified the compiler, however, to allow invocation of
  static methods through type aliases, then this type definition would
  essentially be switching the default hasher from `SipHasher` in libcollections
  to a libstd-defined `RandomizedSipHasher` type. This type's `Default`
  implementation would randomly seed the `SipHasher` instance, and otherwise
  perform the same as `SipHasher`.

  This future state doesn't seem incredibly far off, but until that time comes,
  the hashmap module will live in libstd to not compromise on functionality.

* In preparation for the hashmap moving to libcollections, the `hash` module has
  moved from libstd to libcollections. A previously snapshotted commit enables a
  distinct `Writer` trait to live in the `hash` module which `Hash`
  implementations are now parameterized over.

  Due to using a custom trait, the `SipHasher` implementation has lost its
  specialized methods for writing integers. These can be re-added
  backwards-compatibly in the future via default methods if necessary, but the
  FNV hashing should satisfy much of the need for speedier hashing.

A list of breaking changes:

* HashMap::{get, get_mut} no longer fails with the key formatted into the error
  message with `{:?}`, instead, a generic message is printed. With backtraces,
  it should still be not-too-hard to track down errors.

* The HashMap, HashSet, and LruCache types are now available through
  std::collections instead of the collections crate.

* Manual implementations of hash should be parameterized over `hash::Writer`
  instead of just `Writer`.

[breaking-change]
2014-06-05 13:55:10 -07:00
Brian Anderson b45553f075 How about a less cringe-worthy double-failure message? 2014-06-05 10:21:35 -07:00