Auto merge of #23877 - richo:gardening, r=Manishearth
I also wanted to unignore https://github.com/rust-lang/rust/blob/master/src/libsyntax/ext/expand.rs#L1768-L1777 since the issue it references is closed, but the test fails, and it's internals aren't super clear to me.
BTW, I was just able to get the Bitrig Rust build to pass "make check" so I'll submit a PR once this lands to fix the tests and get the Bitrig buildbot to finally complete a build. That will hopefully end this nonsense of hand building and uploading snapshots. :+1:
Alex Crichton [Wed, 1 Apr 2015 20:56:20 +0000 (13:56 -0700)]
rollup merge of #23949: aturon/stab-timeout
This commit renames and stabilizes:
* `Condvar::wait_timeout_ms` (renamed from `wait_timeout`)
* `thread::park_timeout_ms` (renamed from `park_timeout`)
* `thread::sleep_ms` (renamed from `sleep`)
In each case, the timeout is taken as a `u32` number of milliseconds,
rather than a `Duration`.
These functions are likely to be deprecated once a stable form of
`Duration` is available, but there is little cost to having these named
variants around, and it's crucial functionality for 1.0.
* `Condvar::wait_timeout_ms` (renamed from `wait_timeout`)
* `thread::park_timeout_ms` (renamed from `park_timeout`)
* `thread::sleep_ms` (renamed from `sleep`)
In each case, the timeout is taken as a `u32` number of milliseconds,
rather than a `Duration`.
These functions are likely to be deprecated once a stable form of
`Duration` is available, but there is little cost to having these named
variants around, and it's crucial functionality for 1.0.
Alex Crichton [Wed, 1 Apr 2015 20:30:08 +0000 (13:30 -0700)]
rollup merge of #23951: alexcrichton/splitn
This commit is an implementation of [RFC 979][rfc] which changes the meaning of
the count parameter to the `splitn` function on strings and slices. The
parameter now means the number of items that are returned from the iterator, not
the number of splits that are made.
Alex Crichton [Wed, 1 Apr 2015 18:28:34 +0000 (11:28 -0700)]
std: Changing the meaning of the count to splitn
This commit is an implementation of [RFC 979][rfc] which changes the meaning of
the count parameter to the `splitn` function on strings and slices. The
parameter now means the number of items that are returned from the iterator, not
the number of splits that are made.
Alex Crichton [Wed, 1 Apr 2015 20:22:16 +0000 (13:22 -0700)]
rollup merge of #23947: aturon/revise-num
Recent numerics stabilization removed the inherent `min_value` and
`max_value` methods from integer types, assuming that the module-level
constants would suffice. However, that failed to account for the use
case in FFI code when dealing with integer type aliases.
This commit reintroduces the methods as `#[stable]`, since this is
essential functionality for 1.0.
It's unfortunate to freeze these as methods, but when we can provide
inherent associated constants these methods can be deprecated.
Alex Crichton [Wed, 1 Apr 2015 20:22:10 +0000 (13:22 -0700)]
rollup merge of #23867: nikomatsakis/issue-23086-take-3
This PR implements rust-lang/rfcs#1023. In the process it fixes #23086 and #23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence.
I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable).
Recent numerics stabilization removed the inherent `min_value` and
`max_value` methods from integer types, assuming that the module-level
constants would suffice. However, that failed to account for the use
case in FFI code when dealing with integer type aliases.
This commit reintroduces the methods as `#[stable]`, since this is
essential functionality for 1.0.
It's unfortunate to freeze these as methods, but when we can provide
inherent associated constants these methods can be deprecated.
Niko Matsakis [Wed, 1 Apr 2015 19:25:47 +0000 (15:25 -0400)]
Collect the definition of the `Error` trait into `libstd` for now. This
sidesteps a coherence difficulty where `liballoc` had to prove that
`&str: !Error`, which didn't involve any local types.
Rollup merge of #23925 - steveklabnik:gh22914, r=Gankro
Fixes #22914
Said issue was mostly fixed, as there wasn't any examples when it was initially posted. This is mostly just some re-wording of some things and some cleanup
Rollup merge of #23895 - nikomatsakis:fn-trait-inheritance-add-impls, r=pnkfelix
The primary purpose of this PR is to add blanket impls for the `Fn` traits of the following (simplified) form:
impl<F:Fn> Fn for &F
impl<F:FnMut> FnMut for &mut F
However, this wound up requiring two changes:
1. A slight hack so that `x()` where `x: &mut F` is translated to `FnMut::call_mut(&mut *x, ())` vs `FnMut::call_mut(&mut x, ())`. This is achieved by just autoderef'ing one time when calling something whose type is `&F` or `&mut F`.
2. Making the infinite recursion test in trait matching a bit more tailored. This involves adding a notion of "matching" types that looks to see if types are potentially unifiable (it's an approximation).
The PR also includes various small refactorings to the inference code that are aimed at moving the unification and other code into a library (I've got that particular change in a branch, these changes just lead the way there by removing unnecessary dependencies between the compiler and the more general unification code).
Note that per rust-lang/rfcs#1023, adding impls like these would be a breaking change in the future.
Rollup merge of #23867 - nikomatsakis:issue-23086-take-3, r=pnkfelix
This PR implements rust-lang/rfcs#1023. In the process it fixes #23086 and #23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence.
I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable).
Rollup merge of #23847 - bcoopers:read_clarification, r=sfackler
This introduces no functional changes except for reducing a few unnecessary operations and variables. Vec has the behavior that, if you request space past the capacity with reserve(), it will round up to the nearest power of 2. What that effectively means is that after the first call to reserve(16), we are doubling our capacity every time. So using the DEFAULT_BUF_SIZE and doubling cap_size() here is meaningless and has no effect on the call to reserve().
Note that with #23842 implemented this will hopefully have a clearer API and less of a need for commenting. If #23842 is not implemented then the most clear implementation would be to call reserve_exact(buf.capacity()) at every step (and making sure that buf.capacity() is not zero at the beginning of the function of course).
Edit- functional change now introduced. We will now zero 16 bytes of the vector first, then double to 32, then 64, etc. until we read 64kB. This stops us from zeroing the entire vector when we double it, some of which may be wasted work. Reallocation still follows the doubling strategy, but the responsibility has been moved to vec.extend(), which calls reserve() and push_back().
Rollup merge of #23844 - kvark:try_unique, r=alexcrichton
While trying to implement parallel ECS processing, I stumbled upon the need to mutate `Arc` contents. The only existed method that allowed that was `make_unique`, but it has issues:
- it may clone the data as if nothing happened, where the program may just need to crash
- it forces `Clone` bound, which I don't have
The new `try_unique` allows accessing the contents mutably without `Clone` bound and error out if the pointer is not unique.
Rollup merge of #23066 - michaelwoerister:unreachable-if, r=pnkfelix
This PR solves #21559 by making sure that unreachable if-expressions are not further translated.
Could someone who knows their way around `trans` take a look at the changes in `controlflow.rs`? I'm not sure if any other code relies on any side-effects of translating unreachable things.
Niko Matsakis [Wed, 1 Apr 2015 15:12:30 +0000 (11:12 -0400)]
Remove `Thunk` struct and `Invoke` trait; change `Thunk` to be an alias
for `Box<FnBox()>`. I found the alias was still handy because it is
shorter than the fully written type.
This is a [breaking-change]: convert code using `Invoke` to use `FnBox`,
which is usually pretty straight-forward. Code using thunk mostly works
if you change `Thunk::new => Box::new` and `foo.invoke(arg)` to
`foo(arg)`.
Niko Matsakis [Mon, 30 Mar 2015 21:51:26 +0000 (17:51 -0400)]
Fallout in libsyntax/librustc: use newtype'd options for linked lists,
since `Option` is not fundamental and hence the old impls run afoul of
the orphan rules.
Niko Matsakis [Mon, 30 Mar 2015 21:52:00 +0000 (17:52 -0400)]
Add `#[fundamental]` annotations into libcore so that `Sized` and the
`Fn` traits are considered fundamental, along with `Box` (though that is
mostly for show; the real type is `~T` in the compiler).
Niko Matsakis [Mon, 30 Mar 2015 21:46:34 +0000 (17:46 -0400)]
Implement the changes to coherence such that we consider a type to be
local only if matches `FUNDAMENTAL(LocalType)`, where `FUNDAMENTAL`
includes `&T` and types marked as fundamental (which includes `Box`).
Also apply these tests to negative reasoning.
Niko Matsakis [Fri, 6 Mar 2015 02:31:42 +0000 (21:31 -0500)]
Remove the `Option<>` since when computing LUB since I believe that the
case where `None` was returned should never happen in practice; it
amounts to comparing regions from two unrelated hierarchies. (I was also
not able to make it happen.)
Niko Matsakis [Thu, 5 Mar 2015 11:24:22 +0000 (06:24 -0500)]
Implement the new region hierarchy rules, in which regions from distinct
hierarchies are judged based on the lexical relationship of their
respective fn bodies.
Niko Matsakis [Wed, 4 Mar 2015 15:52:39 +0000 (10:52 -0500)]
Add a meta-hierarchy of trees -- in future, each fn body will inhabit
its own disjoint region tree, and the new table encodes the lexical
relationships between those trees.
One tricky detail here: There is some duplication of labor between `rustc::middle::const_eval` and `rustc_trans::trans::consts`. It might be good to explore ways to try to factor out the common structure to the two passes (by abstracting over the particular value-representation used in the compile-time interpreter).