]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #14708 : gereeter/rust/faster-sem, r=alexcrichton
bors [Sat, 7 Jun 2014 07:51:36 +0000 (00:51 -0700)]
auto merge of #14708 : gereeter/rust/faster-sem, r=alexcrichton

Currently, `Sem`, which is used as a building block for all the blocking primitives, uses a very ugly hack to implement `Share` and be able to mutate the stored `WaitQueue` by hiding it all behind a `transmute`d `*()`. This PR replaces all that ugly machinery with `Unsafe`. Beyond being cleaner and not requiring `transmute`, this removes an allocation in the creation and removes an indirection for access.

10 years agoauto merge of #14638 : alexcrichton/rust/librustrt, r=brson
bors [Sat, 7 Jun 2014 06:06:35 +0000 (23:06 -0700)]
auto merge of #14638 : alexcrichton/rust/librustrt, r=brson

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.

10 years agolibs: Fix miscellaneous fallout of librustrt
Alex Crichton [Wed, 4 Jun 2014 07:01:40 +0000 (00:01 -0700)]
libs: Fix miscellaneous fallout of librustrt

10 years agotest: Fix fallout of previous changes
Alex Crichton [Wed, 4 Jun 2014 07:01:08 +0000 (00:01 -0700)]
test: Fix fallout of previous changes

10 years agorustuv: Deal with the rtio changes
Alex Crichton [Wed, 4 Jun 2014 07:00:59 +0000 (00:00 -0700)]
rustuv: Deal with the rtio changes

10 years agonative: Deal with the rtio changes
Alex Crichton [Wed, 4 Jun 2014 07:00:49 +0000 (00:00 -0700)]
native: Deal with the rtio changes

10 years agostd: Deal with fallout of rtio changes
Alex Crichton [Wed, 4 Jun 2014 03:09:39 +0000 (20:09 -0700)]
std: Deal with fallout of rtio changes

10 years agostd: Extract librustrt out of libstd
Alex Crichton [Wed, 4 Jun 2014 02:11:49 +0000 (19:11 -0700)]
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]

10 years agortio: Remove usage of `Path`
Alex Crichton [Tue, 3 Jun 2014 05:11:19 +0000 (22:11 -0700)]
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.

10 years agortio: Remove unused stuct
Alex Crichton [Tue, 3 Jun 2014 05:10:38 +0000 (22:10 -0700)]
rtio: Remove unused stuct

10 years agoauto merge of #14712 : alexcrichton/rust/rollup, r=alexcrichton
bors [Sat, 7 Jun 2014 03:42:01 +0000 (20:42 -0700)]
auto merge of #14712 : alexcrichton/rust/rollup, r=alexcrichton

Closes #14675 (rustc: Encode argument names for traits)
Closes #14681 (rustc: Avoid UB with signed division/remainder)
Closes #14682 (librustc: Update AutoObject adjustment in writeback.)
Closes #14683 (Avoid 16-byte filenames in rlibs)
Closes #14687 (rustdoc: Inline static documentation across crates)
Closes #14689 (Remove reference to ~str in documentation)
Closes #14692 (Rename Iterator::len to count)
Closes #14693 (Implement Eq for HashSet and HashMap)
Closes #14699 (url: encode small bytes correctly.)
Closes #14700 (rustdoc: Submit examples to play.rust-lang.org)
Closes #14701 (mk: Run doc tests with --cfg dox)
Closes #14710 (rustc: Preserve reachable extern fns with LTO)
Closes #14711 (Removing unused wrapper to libc::close.)

10 years agoTest fixes from the rollup
Alex Crichton [Sat, 7 Jun 2014 03:17:19 +0000 (20:17 -0700)]
Test fixes from the rollup

10 years agorustdoc: Submit examples to play.rust-lang.org
Alex Crichton [Fri, 6 Jun 2014 16:12:18 +0000 (09:12 -0700)]
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

10 years agodoc: Turn off special features for rustdoc tests
Alex Crichton [Fri, 6 Jun 2014 06:01:01 +0000 (23:01 -0700)]
doc: Turn off special features for rustdoc tests

These were only used for the markdown tests, and there's no reason they should
be distinct from the other tests.

10 years agoRemoving unused wrapper to libc::close.
Axel Viala [Fri, 6 Jun 2014 22:43:45 +0000 (00:43 +0200)]
Removing unused wrapper to libc::close.

10 years agorustc: Preserve reachable extern fns with LTO
Alex Crichton [Sat, 7 Jun 2014 00:48:46 +0000 (17:48 -0700)]
rustc: Preserve reachable extern fns with LTO

All rust functions are internal implementation details with respect to the ABI
exposed by crates, but extern fns are public components of the ABI and shouldn't
be stripped. This commit serializes reachable extern fns to metadata, so when
LTO is performed all of their symbols are not stripped.

Closes #14500

10 years agomk: Run doc tests with --cfg dox
Alex Crichton [Fri, 6 Jun 2014 16:22:19 +0000 (09:22 -0700)]
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

10 years agourl: encode small bytes correctly.
Huon Wilson [Fri, 6 Jun 2014 14:49:19 +0000 (00:49 +1000)]
url: encode small bytes correctly.

Previously, bytes less than 16 would be encoded as %X, rather than %XX,
since the output width was left to be automatic.

10 years agoImplement Eq for HashSet and HashMap
Steven Fackler [Fri, 6 Jun 2014 06:22:01 +0000 (23:22 -0700)]
Implement Eq for HashSet and HashMap

Also fix documentation references to PartialEq.

10 years agoRename Iterator::len to count
Aaron Turon [Fri, 6 Jun 2014 06:18:51 +0000 (23:18 -0700)]
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]

10 years agoRemove reference to ~str in documentation
fort [Fri, 6 Jun 2014 01:13:30 +0000 (18:13 -0700)]
Remove reference to ~str in documentation

10 years agorustdoc: Inline static documentation across crates
Alex Crichton [Fri, 6 Jun 2014 00:20:59 +0000 (17:20 -0700)]
rustdoc: Inline static documentation across crates

10 years agorustc: Avoid 16-byte filenames in rlibs
Alex Crichton [Thu, 5 Jun 2014 22:31:45 +0000 (15:31 -0700)]
rustc: Avoid 16-byte filenames in rlibs

In addition to avoiding 16-byte filenames with bytecode files, this commit also
avoids 16-byte filenames with object files pulled in from native libraries.

10 years agoAdd workaround for archive reading bug in LLDB.
Michael Woerister [Thu, 5 Jun 2014 08:24:34 +0000 (10:24 +0200)]
Add workaround for archive reading bug in LLDB.

LLDB contains a bug that makes it crash if an archive it reads
contains a file the name of which is exactly 16 bytes long. This
bug recently has made it impossible to debug Rust applications with
LLDB because some standard libraries triggered it indirectly:
For rlibs, rustc includes the LLVM bytecode in the archive, giving
it the extension ".bc.deflate". For liballoc (for example) this
results in the 16 character filename "alloc.bc.deflate", which is
bad.

This commit replaces the ".bc.deflate" suffix with
".bytecode.deflate" which itself is already longer than 16 bytes,
thus making sure that the bug won't be run into anymore.

The bug could still be run into with 14 character filenames because
then the .o files will trigger it. However, this is much more rare
and working around it would introduce more complexity than necessary
at the moment. It can always be done later on, if the need arises.

Fixes #14356.

10 years agolibrustc: Update AutoObject adjustment in writeback.
Luqman Aden [Thu, 5 Jun 2014 22:06:33 +0000 (18:06 -0400)]
librustc: Update AutoObject adjustment in writeback.

10 years agorustc: Avoid UB with signed division/remainder
Alex Crichton [Thu, 5 Jun 2014 19:23:34 +0000 (12:23 -0700)]
rustc: Avoid UB with signed division/remainder

Division and remainder by 0 are undefined behavior, and are detected at runtime.
This commit adds support for ensuring that MIN / -1 is also checked for at
runtime, as this would cause signed overflow, or undefined behvaior.

Closes #8460

10 years agorustc: Encode argument names for traits
Alex Crichton [Thu, 5 Jun 2014 17:07:19 +0000 (10:07 -0700)]
rustc: Encode argument names for traits

This ensures that rustdoc can properly document inlined traits across crates.

Closes #14670

10 years agoauto merge of #14702 : nikomatsakis/rust/issue-5527-namespace-substs-b, r=pnkfelix
bors [Sat, 7 Jun 2014 00:02:00 +0000 (17:02 -0700)]
auto merge of #14702 : nikomatsakis/rust/issue-5527-namespace-substs-b, r=pnkfelix

Separate out initial refactorings for PR #14604

10 years agoFix resolve to not permit refs to type vars from outer fns
Niko Matsakis [Sat, 31 May 2014 05:54:04 +0000 (01:54 -0400)]
Fix resolve to not permit refs to type vars from outer fns
(Fixes #14603)

10 years agoAdd missing test case for contravariant trait matching
Niko Matsakis [Sat, 31 May 2014 22:48:20 +0000 (18:48 -0400)]
Add missing test case for contravariant trait matching

10 years agoStop passing around Option<&substs> in trans and just pass &substs, making the code...
Niko Matsakis [Thu, 15 May 2014 00:53:48 +0000 (20:53 -0400)]
Stop passing around Option<&substs> in trans and just pass &substs, making the code more regular

10 years agoMove Def out of syntax crate, where it does not belong
Niko Matsakis [Wed, 14 May 2014 19:31:30 +0000 (15:31 -0400)]
Move Def out of syntax crate, where it does not belong

10 years agoSimplify MonoId not to include parameters which, given coherence, are purely derived
Niko Matsakis [Tue, 13 May 2014 15:49:06 +0000 (11:49 -0400)]
Simplify MonoId not to include parameters which, given coherence, are purely derived

10 years agoMove subst data structures into subst.rs, fix capitalization
Niko Matsakis [Tue, 13 May 2014 15:35:42 +0000 (11:35 -0400)]
Move subst data structures into subst.rs, fix capitalization

10 years agoauto merge of #14680 : Kimundi/rust/master, r=brson
bors [Fri, 6 Jun 2014 22:21:59 +0000 (15:21 -0700)]
auto merge of #14680 : Kimundi/rust/master, r=brson

Also updated/corrected a few other details in the tuple and struct sections.

10 years agoMake sync::raw::Sem use Unsafe to manage mutability instead of transmuting an unsafe...
Jonathan S [Fri, 6 Jun 2014 20:24:14 +0000 (15:24 -0500)]
Make sync::raw::Sem use Unsafe to manage mutability instead of transmuting an unsafe pointer

10 years agoauto merge of #14318 : zwarich/rust/check-loans-refactor, r=nikomatsakis
bors [Fri, 6 Jun 2014 19:17:10 +0000 (12:17 -0700)]
auto merge of #14318 : zwarich/rust/check-loans-refactor, r=nikomatsakis

I tried to split up the less mechanical changes into separate commits so they are easier to review. One thing I'm not quite sure of is whether `MoveReason` should just be replaced with `move_data::MoveKind`.

10 years agoAdd a test for borrowck errors with multiple closure captures.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:33 +0000 (11:59 -0700)]
Add a test for borrowck errors with multiple closure captures.

When converting check_loans to use ExprUseVisitor I encountered a few
issues where the wrong number of errors were being emitted for multiple
closure captures, but there is no existing test for this.

10 years agoAdd new tests for borrowck field-sensitivity.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:33 +0000 (11:59 -0700)]
Add new tests for borrowck field-sensitivity.

10 years agoChange check_loans to use ExprUseVisitor.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:33 +0000 (11:59 -0700)]
Change check_loans to use ExprUseVisitor.

10 years agoAdd a kind_of_move_of_path method to FlowedMoveData.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:33 +0000 (11:59 -0700)]
Add a kind_of_move_of_path method to FlowedMoveData.

10 years agoUse the MoveReason to determine a more precise MoveKind in gather_moves.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:33 +0000 (11:59 -0700)]
Use the MoveReason to determine a more precise MoveKind in gather_moves.

10 years agoAdd a move reason to the Move ConsumeMode.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:33 +0000 (11:59 -0700)]
Add a move reason to the Move ConsumeMode.

Currently it is not possible to distinguish moves caused by captures
in the ExprUseVisitor interface. Since check_Loans needs to make that
distinction for generating good diagnostics, this is necessary for
check_loans to switch to ExprUseVisitor.

10 years agoAdd an Init mode to MutateMode.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:32 +0000 (11:59 -0700)]
Add an Init mode to MutateMode.

This isn't necessary right now, but check_loans needs to be able to
distinguish between initialization and writes in the ExprUseVisitor
mutate callback.

10 years agoFix mem_categorization to treat an AutoObject adjustment as an rvalue.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:32 +0000 (11:59 -0700)]
Fix mem_categorization to treat an AutoObject adjustment as an rvalue.

Currently mem_categorization categorizes an AutoObject adjustment the
same as the original expression. This can cause two moves to be
generated for the same underlying expression. Currently this isn't a
problem in practice, since check_loans doesn't rely on ExprUseVisitor.

10 years agoClean up check_loans.
Cameron Zwarich [Fri, 6 Jun 2014 18:59:32 +0000 (11:59 -0700)]
Clean up check_loans.

Refactor a number of functions in check_loans to take node IDs and spans
rather than taking expressions directly. Also rename some variables to
make them less ambiguous.

This is the first step towards using ExprUseVisitor in check_loans, as
now some of the interfaces more closely match those used in
ExprUseVisitor.

10 years agoauto merge of #14677 : alexcrichton/rust/issue-2665, r=brson
bors [Fri, 6 Jun 2014 17:36:55 +0000 (10:36 -0700)]
auto merge of #14677 : alexcrichton/rust/issue-2665, r=brson

There's no need to distribute these ABI helpers for tests with the standard rust
distribution they're only needed for our tests.

Closes #2665

10 years agoauto merge of #14676 : brson/rust/double-rainbow, r=alexcrichton
bors [Fri, 6 Jun 2014 15:07:07 +0000 (08:07 -0700)]
auto merge of #14676 : brson/rust/double-rainbow, r=alexcrichton

10 years agoauto merge of #14673 : sylvestre/rust/master, r=alexcrichton
bors [Fri, 6 Jun 2014 13:27:00 +0000 (06:27 -0700)]
auto merge of #14673 : sylvestre/rust/master, r=alexcrichton

 Remove a warning (./configure: 1140: [: unexpected operator) when built with --disable-manage-submodules

10 years agoauto merge of #14671 : aochagavia/rust/patch-1, r=alexcrichton
bors [Fri, 6 Jun 2014 11:41:53 +0000 (04:41 -0700)]
auto merge of #14671 : aochagavia/rust/patch-1, r=alexcrichton

10 years agoauto merge of #14668 : aochagavia/rust/pr3, r=alexcrichton
bors [Fri, 6 Jun 2014 10:01:57 +0000 (03:01 -0700)]
auto merge of #14668 : aochagavia/rust/pr3, r=alexcrichton

Closes https://github.com/mozilla/rust/issues/14577
Closes https://github.com/mozilla/rust/issues/14639

10 years agoauto merge of #14667 : aochagavia/rust/pr2, r=huonw
bors [Fri, 6 Jun 2014 08:21:54 +0000 (01:21 -0700)]
auto merge of #14667 : aochagavia/rust/pr2, r=huonw

10 years agoChange to_str().to_string() to just to_str()
Adolfo Ochagavía [Thu, 5 Jun 2014 07:15:19 +0000 (09:15 +0200)]
Change to_str().to_string() to just to_str()

10 years agoDocument BigInt's new and from_slice methods
Adolfo Ochagavía [Thu, 5 Jun 2014 07:40:43 +0000 (09:40 +0200)]
Document BigInt's new and from_slice methods

Fixes https://github.com/mozilla/rust/issues/14639

10 years agoFix documentation for `slice()`
Adolfo Ochagavía [Thu, 5 Jun 2014 07:33:49 +0000 (09:33 +0200)]
Fix documentation for `slice()`

Fixes https://github.com/mozilla/rust/issues/14577

10 years agoauto merge of #14669 : TeXitoi/rust/relicense-shootout-meteor, r=brson
bors [Fri, 6 Jun 2014 06:36:56 +0000 (23:36 -0700)]
auto merge of #14669 : TeXitoi/rust/relicense-shootout-meteor, r=brson

part of #14248, fix #14420

Removed @richo's contribution (outdated comment)

Quoting @brson: let's move forward with this one. The only
statement I'm missing is @richo's and it sounds like his was a
minor patch.

10 years agoauto merge of #14664 : reem/rust/lifetimes-guide-grammar, r=brson
bors [Fri, 6 Jun 2014 03:16:53 +0000 (20:16 -0700)]
auto merge of #14664 : reem/rust/lifetimes-guide-grammar, r=brson

Removed strange fragment-like thing in the intro.

10 years agoauto merge of #14653 : alexcrichton/rust/travis-opt, r=cmr
bors [Fri, 6 Jun 2014 01:36:56 +0000 (18:36 -0700)]
auto merge of #14653 : alexcrichton/rust/travis-opt, r=cmr

The most frequent failure for our travis builds is running into the timeout
limits when building the compiler itself. Building librustc takes a very long
amount of time, often hitting the 10 minutes with no output threshold that
travis imposes on us.

This commit switches the relevant `make` step to being wrapped in the
`travis_wait` command [1]. This command will print something once a minute so as
to not time out a build.

This will hopefully enable us to have fewer flaky builds on travis!

[1]: http://docs.travis-ci.com/user/build-timeouts/

10 years agomk: Move rust_test_helpers out of libstd
Alex Crichton [Thu, 5 Jun 2014 18:08:43 +0000 (11:08 -0700)]
mk: Move rust_test_helpers out of libstd

There's no need to distribute these ABI helpers for tests with the standard rust
distribution they're only needed for our tests.

Closes #2665

10 years agoauto merge of #14641 : darnuria/rust/add_documentation_to_std_os, r=alexcrichton
bors [Thu, 5 Jun 2014 23:41:53 +0000 (16:41 -0700)]
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.

10 years agoauto merge of #14538 : alexcrichton/rust/libcollections, r=brson
bors [Thu, 5 Jun 2014 22:01:54 +0000 (15:01 -0700)]
auto merge of #14538 : alexcrichton/rust/libcollections, r=brson

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]

10 years agoFallout from the libcollections movement
Alex Crichton [Fri, 30 May 2014 02:03:06 +0000 (19:03 -0700)]
Fallout from the libcollections movement

10 years agostd: Recreate a `collections` module
Alex Crichton [Fri, 30 May 2014 01:50:12 +0000 (18:50 -0700)]
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]

10 years agoauto merge of #14647 : BurntSushi/rust/fix-14185, r=alexcrichton
bors [Thu, 5 Jun 2014 20:26:53 +0000 (13:26 -0700)]
auto merge of #14647 : BurntSushi/rust/fix-14185, r=alexcrichton

This fix suppresses dead_code warnings from code generated by regex! when
the result of regex! is unused. Correct behavior should be a single
unused variable warning.

Regression tests are included for both `let` and `static` bound regex!
values.

see #14185

10 years agoPurged "record" from the manual.
Marvin Löbel [Thu, 5 Jun 2014 19:31:57 +0000 (21:31 +0200)]
Purged "record" from the manual.

Also updated/corrected a few other details in the tuple and struct sections.

10 years agoauto merge of #14526 : pczarn/rust/hashmap-opt, r=alexcrichton
bors [Thu, 5 Jun 2014 18:06:53 +0000 (11:06 -0700)]
auto merge of #14526 : pczarn/rust/hashmap-opt, r=alexcrichton

An interface that gives a better control over the load factor and the minimum capacity for HashMap.
The size of `HashMap<K, V>` is now 64 bytes by default on a 64-bit platform (or at least 40 bytes, that is 3 words less, with FNV and without minimum capacity)

Unanswered questions about `ResizePolicy`

* should it control the `INITIAL_CAPACITY`?
* should it fully control the resizing behavior? Even though the capacity always changes by a factor of 2.
* is caching `grow_at` desirable?

special thanks to @eddyb and @pnkfelix

10 years agoHow about a less cringe-worthy double-failure message?
Brian Anderson [Thu, 5 Jun 2014 17:21:35 +0000 (10:21 -0700)]
How about a less cringe-worthy double-failure message?

10 years agoImprove documentation on std::os::env.
Axel Viala [Thu, 5 Jun 2014 15:36:15 +0000 (17:36 +0200)]
Improve documentation on std::os::env.

10 years agoauto merge of #14644 : alexcrichton/rust/more-no-runtime-use-cases, r=brson
bors [Thu, 5 Jun 2014 15:26:51 +0000 (08:26 -0700)]
auto merge of #14644 : alexcrichton/rust/more-no-runtime-use-cases, r=brson

A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.

10 years agoauto merge of #14643 : jakub-/rust/infinite-loop-unreachable, r=alexcrichton
bors [Thu, 5 Jun 2014 13:46:54 +0000 (06:46 -0700)]
auto merge of #14643 : jakub-/rust/infinite-loop-unreachable, r=alexcrichton

10 years agoRemove a warning (./configure: 1140: [: unexpected operator) when built with --disab...
Sylvestre Ledru [Thu, 5 Jun 2014 13:17:59 +0000 (15:17 +0200)]
Remove a warning  (./configure: 1140: [: unexpected operator) when built with --disable-manage-submodules

10 years agoauto merge of #14642 : aochagavia/rust/pr, r=alexcrichton
bors [Thu, 5 Jun 2014 12:11:54 +0000 (05:11 -0700)]
auto merge of #14642 : aochagavia/rust/pr, r=alexcrichton

The contents of a `RingBuf` are shown in the same way as the contents of a `Vector`. See the tests for examples.

10 years agoauto merge of #14640 : tomjakubowski/rust/fix-14636, r=huonw
bors [Thu, 5 Jun 2014 10:36:52 +0000 (03:36 -0700)]
auto merge of #14640 : tomjakubowski/rust/fix-14636, r=huonw

Previously, documentation for an inlined trait (i.e. a trait imported
and reexported from another crate) didn't display the trait's supertraits.

Closes #14636

10 years agoAdding examples and possible failures for getcwd.
Axel Viala [Wed, 4 Jun 2014 14:33:25 +0000 (16:33 +0200)]
Adding examples and possible failures for getcwd.

For both window and unix platforms.

10 years agoUpdate AUTHORS.txt
Adolfo Ochagavía [Thu, 5 Jun 2014 08:43:47 +0000 (10:43 +0200)]
Update AUTHORS.txt

10 years agorustdoc: Include supertraits on inlined traits
Tom Jakubowski [Wed, 4 Jun 2014 10:51:41 +0000 (03:51 -0700)]
rustdoc: Include supertraits on inlined traits

Previously, documentation for an inlined trait (i.e. a trait imported
and reexported from another crate) didn't display the trait's
supertraits.

Closes #14636

10 years agorelicense shootout-meteor.rs
Guillaume Pinot [Thu, 5 Jun 2014 07:55:49 +0000 (09:55 +0200)]
relicense shootout-meteor.rs

part of #14248, fix #14420

Removed @richo's contribution (outdated comment)

Quoting @brson: let's move forward with this one. The only
statement I'm missing is @richo's and it sounds like his was a
minor patch.

10 years agoauto merge of #14568 : erickt/rust/slice-update, r=alexcrichton
bors [Thu, 5 Jun 2014 07:51:48 +0000 (00:51 -0700)]
auto merge of #14568 : erickt/rust/slice-update, r=alexcrichton

This PR adds two features to make it possible to transform an `Iterator<u8>` into a `Reader`. The first patch adds a method to mutable slices that allows it to be updated with an `Iterator<T>` without paying for the bounds cost. The second adds a Iterator adaptor, `IterReader`, to provide that `Reader` interface.

I had two questions. First, are these named the right things? Second, should `IterReader` instead wrap an `Iterator<Result<u8, E>>`? This would allow you to `IterReader::new(rdr.bytes())`, which could be useful if you want to apply some iterator transformations on a reader while still exporting the Reader interface, but I'd expect there'd be a lot of overhead annotating each byte with an error result.

10 years agoFixed weird grammar in lifetimes guide.
Jonathan Reem [Thu, 5 Jun 2014 05:27:21 +0000 (22:27 -0700)]
Fixed weird grammar in lifetimes guide.

10 years agoauto merge of #14592 : alexcrichton/rust/rustdoc-links, r=huonw
bors [Thu, 5 Jun 2014 05:21:43 +0000 (22:21 -0700)]
auto merge of #14592 : alexcrichton/rust/rustdoc-links, r=huonw

These are a few assorted fixes for some issues I found this morning (details in the commits).

10 years agoauto merge of #14610 : alexcrichton/rust/issue-14008, r=brson
bors [Thu, 5 Jun 2014 03:41:44 +0000 (20:41 -0700)]
auto merge of #14610 : alexcrichton/rust/issue-14008, r=brson

This commit removes the <M: Any + Send> type parameter from Option::expect in
favor of just taking a hard-coded `&str` argument. This allows this function to
move into libcore.

Previous code using strings with `expect` will continue to work, but code using
this implicitly to transmit task failure will need to unwrap manually with a
`match` statement.

[breaking-change]
Closes #14008

10 years agoauto merge of #14529 : brson/rust/ptr, r=brson
bors [Thu, 5 Jun 2014 01:56:48 +0000 (18:56 -0700)]
auto merge of #14529 : brson/rust/ptr, r=brson

This time we're not promoting anything directly to 'stable', but instead promoting functions we're happy with to 'unstable'. They'll become stable in another pass later.

* null and mut_null are unstable. Their names may change if the unsafe
  pointer types change.
* copy_memory and copy_overlapping_memory are unstable. We think they
  aren't going to change.
* set_memory and zero_memory are experimental. Both the names and
  the semantics are under question.
* swap and replace are unstable and probably won't change.
* read is unstable, probably won't change
* read_and_zero is experimental. It's necessity is in doubt.
* mem::overwrite is now called ptr::write to match read and is
  unstable. mem::overwrite is now deprecated
* array_each, array_each_with_len, buf_len, and position are
  all deprecated because they use old style iteration and their
  utility is generally under question.

Note that `mem::overwrite`, which was just declared stable last week, is deprecated now in favor of `ptr::write`. Woo!

10 years agocore: Apply stability attributes to ptr mod
Brian Anderson [Fri, 30 May 2014 00:40:18 +0000 (17:40 -0700)]
core: Apply stability attributes to ptr mod

* null and mut_null are unstable. Their names may change if the unsafe
  pointer types change.
* copy_memory and copy_overlapping_memory are unstable. We think they
  aren't going to change.
* set_memory and zero_memory are experimental. Both the names and
  the semantics are under question.
* swap and replace are unstable and probably won't change.
* read is unstable, probably won't change
* read_and_zero is experimental. It's necessity is in doubt.
* mem::overwrite is now called ptr::write to match read and is
  unstable. mem::overwrite is now deprecated
* array_each, array_each_with_len, buf_len, and position are
  all deprecated because they use old style iteration and their
  utility is generally under question.

10 years agotravis: Prevent timeouts with travis_wait
Alex Crichton [Wed, 4 Jun 2014 19:00:42 +0000 (12:00 -0700)]
travis: Prevent timeouts with travis_wait

The most frequent failure for our travis builds is running into the timeout
limits when building the compiler itself. Building librustc takes a very long
amount of time, often hitting the 10 minutes with no output threshold that
travis imposes on us.

This commit switches the relevant `make` step to being wrapped in the
`travis_wait` command [1]. This command will print something once a minute so as
to not time out a build.

This will hopefully enable us to have fewer flaky builds on travis!

[1]: http://docs.travis-ci.com/user/build-timeouts/

10 years agoauto merge of #14633 : huonw/rust/nodylibc, r=alexcrichton
bors [Wed, 4 Jun 2014 22:26:50 +0000 (15:26 -0700)]
auto merge of #14633 : huonw/rust/nodylibc, r=alexcrichton

libc: only provide an rlib.

There's absolutely no reason for `libc` to be offered as a dynamic
library.

10 years agoFixes #14185.
Andrew Gallant [Wed, 4 Jun 2014 20:59:27 +0000 (16:59 -0400)]
Fixes #14185.

This fix suppresses dead_code warnings from code generated by regex! when
the result of regex! is unused. Correct behavior should be a single
unused variable warning.

Regression tests are included for both `let` and `static` bound regex!
values.

10 years agoauto merge of #14630 : cmr/rust/rewrite-lexer, r=alexcrichton
bors [Wed, 4 Jun 2014 20:06:47 +0000 (13:06 -0700)]
auto merge of #14630 : cmr/rust/rewrite-lexer, r=alexcrichton

These are a pain to rebase, so I'm separating this from the rest of my work.
Nothing controversial here, just some simple refactoring and removal of an
unused entry in the token table. Brings the lexer into 2012 with methods!

10 years agosyntax: use doc comments in the interner
Corey Richardson [Thu, 22 May 2014 00:20:52 +0000 (17:20 -0700)]
syntax: use doc comments in the interner

10 years agosyntax: methodify the lexer
Corey Richardson [Wed, 21 May 2014 23:57:31 +0000 (16:57 -0700)]
syntax: methodify the lexer

10 years agostd: Improve non-task-based usage
Alex Crichton [Wed, 4 Jun 2014 17:54:35 +0000 (10:54 -0700)]
std: Improve non-task-based usage

A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

* Invoking get() on a TLD key will return None if no task is available

* Invoking replace() on a TLD key will fail if no task is available.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.

10 years agoauto merge of #14623 : exscape/rust-fork/master, r=alexcrichton
bors [Wed, 4 Jun 2014 18:06:49 +0000 (11:06 -0700)]
auto merge of #14623 : exscape/rust-fork/master, r=alexcrichton

Unlike ImmutableClonableVector::permutations() which returns an iterator,
cloning the entire array each iteration, these methods mutate the vector in-place.
For that reason, these methods are much faster; between 35-55 times faster,
depending on the benchmark. They also generate permutations in lexicographical order.

10 years agocollections: optimize `HashMap`. Add `DefaultResizePolicy`.
Piotr Czarnecki [Mon, 2 Jun 2014 08:26:02 +0000 (10:26 +0200)]
collections: optimize `HashMap`. Add `DefaultResizePolicy`.

Refactored the load factor and the minimum capacity out of HashMap.
The size of HashMap<K, V> is now 64 bytes by default on a 64-bit platform
(or 48 bytes, that is 2 words less, with FNV)
Added a documentation in a few places to clarify the behavior.

10 years agoFix an ICE when a function argument is of the bottom type
Jakub Wieczorek [Wed, 4 Jun 2014 16:25:30 +0000 (18:25 +0200)]
Fix an ICE when a function argument is of the bottom type

Fixes #13352

10 years agoMark the exit of infinite loops as unreachable
Jakub Wieczorek [Wed, 4 Jun 2014 16:24:58 +0000 (18:24 +0200)]
Mark the exit of infinite loops as unreachable

10 years agoauto merge of #14616 : forticulous/rust/rc-show, r=alexcrichton
bors [Wed, 4 Jun 2014 15:11:51 +0000 (08:11 -0700)]
auto merge of #14616 : forticulous/rust/rc-show, r=alexcrichton

Show impl for Rc

10 years agoImplement Show for RingBuf
Adolfo Ochagavía [Wed, 4 Jun 2014 14:15:04 +0000 (16:15 +0200)]
Implement Show for RingBuf

10 years agoAdd code example to std::os::getenv for unix.
Axel Viala [Wed, 4 Jun 2014 12:45:56 +0000 (14:45 +0200)]
Add code example to std::os::getenv for unix.

10 years agolibc: only provide an rlib.
Huon Wilson [Tue, 3 Jun 2014 23:12:11 +0000 (09:12 +1000)]
libc: only provide an rlib.

There's absolutely no reason for `libc` to be offered as a dynamic
library.

10 years agoauto merge of #14635 : BurntSushi/rust/regex-doco-touchups, r=alexcrichton
bors [Wed, 4 Jun 2014 06:51:41 +0000 (23:51 -0700)]
auto merge of #14635 : BurntSushi/rust/regex-doco-touchups, r=alexcrichton

10 years agoauto merge of #14634 : BurntSushi/rust/fix-13843, r=alexcrichton
bors [Wed, 4 Jun 2014 05:01:43 +0000 (22:01 -0700)]
auto merge of #14634 : BurntSushi/rust/fix-13843, r=alexcrichton

An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.

I'd just assume that an empty regex is an invalid regex and that an error should be returned (I can't think of any reason to use an empty regex?), but it's probably better to be consistent with other regex libraries.