Commit Graph

36559 Commits

Author SHA1 Message Date
Niko Matsakis
2375a79152 Implement impl reachability rules. This is a [breaking-change]. Type
parameters on impls must now also appear in the trait ref, self type,
or some associated type declared on the impl. This ensures that they
are constrianed in some way and that the semantics of the trait system
are well-defined (always a good thing).

There are three major ways to fix this error:

1. Convert the trait to use associated types; most often the type
   parameters are not constrained because they are in fact outputs of
   the impl.

2. Move the type parameters to methods.

3. Add an additional type parameter to the self type or trait so that
   the unused parameter can appear there.

In some cases, it is not possible to fix the impl because the trait
definition needs to be changed first (and that may be out of your
control). In that case, for the time being, you can opt out of these
rules by using `#[old_impl_check]` on the impl and adding a
`#![feature(old_impl_check)]` to your crate declaration.
2015-01-06 17:17:48 -05:00
Niko Matsakis
3ed7f067dc Fix fallout in libs. For the most part I just tagged impls as #[old_impl_check]. 2015-01-06 17:17:48 -05:00
Jonathan Reem
2404232369 Remove the unneeded Sized bound on TypeId creation
This bound is probably unintentional and is unnecessarily
constricting.
2015-01-06 22:59:07 +01:00
Nick Cameron
791f545685 Pretty print empty structs properly 2015-01-07 10:49:00 +13:00
Nick Cameron
480374a696 Only use built-in indexing for uint indexes 2015-01-07 10:49:00 +13:00
Nick Cameron
77ed497456 Tests 2015-01-07 10:49:00 +13:00
Nick Cameron
e970db37a9 Remove old slicing hacks and make new slicing work 2015-01-07 10:49:00 +13:00
Corey Richardson
5a4ca31918 test fallout from isize/usize 2015-01-06 16:48:33 -05:00
Nick Cameron
f7ff37e4c5 Replace full slice notation with index calls 2015-01-07 10:46:33 +13:00
Nick Cameron
918255ef8c Impls using the new scheme for slicing 2015-01-07 10:24:19 +13:00
Nick Cameron
91ba66fa99 Review changes 2015-01-07 09:46:16 +13:00
Nick Cameron
ba2a77b450 stabilisation 2015-01-07 09:46:16 +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
Corey Richardson
abcbe27695 syntax/rustc: implement isize/usize 2015-01-06 15:15:07 -05:00
Alex Crichton
169fbed251 std: Revert stability of Entry-based APIs
There's been some debate over the precise form that these APIs should take, and
they've undergone some changes recently, so these APIs are going to be left
unstable for now to be fleshed out during the next release cycle.
2015-01-06 11:59:26 -08:00
Dylan Ede
25eada1574 [breaking change] Revert Entry behaviour to take keys by value. 2015-01-06 11:59:26 -08:00
bors
ea6f65c5f1 auto merge of #20633 : vhbit/rust/ios-cstring, r=brson 2015-01-06 19:47:08 +00:00
Niko Matsakis
2486d93e5b Fix ICE that @steveklabnik encountered in rust-ice. The problems turned out to be that were being very loose with bound regions in trans (we were basically just ignoring and flattening binders). Since binders are significant to subtyping and hence to trait selection, this can cause a lot of problems. So this patch makes us treat them more strictly -- for example, we propagate binders, and avoid skipping past the Binder by writing foo.0.
Fixes #20644.
2015-01-06 13:42:42 -05:00
Michael Neumann
134eb0e26f Tuning pthread_key_t type
Both FreeBSD and DragonFly define pthread_key_t as int, while Linux
defines it as uint. As pthread_key_t is used as an opaque type and
storage size of both int and uint are the same, this is rather a
cosmetic change.

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

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

More explanation:

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

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

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

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

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

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

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

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

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

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

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

* The module itself is marked stable.

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

The migration path is:

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

becomes

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

while

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

becomes

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

[breaking-change]
2015-01-06 09:04:48 -08:00
Corey Richardson
e0b4287df6 Fix fallout 2015-01-06 12:04:41 -05:00
Corey Richardson
6680c9c5c7 syntax: implement 'macro input future proofing'
See RFC 550 (https://github.com/rust-lang/rfcs/pull/550) for the motivation
and details.

If this breaks your code, add one of the listed tokens after the relevant
non-terminal in your matcher.

[breaking-change]
2015-01-06 12:03:12 -05:00
bors
6539cb417f auto merge of #20618 : alexcrichton/rust/less-warn, r=brson
This warning has been around in the compiler for quite some time now, but the
real place for a warning like this, if it should exist, is in Cargo, not in the
compiler itself. It's a first-class feature of Cargo that multiple versions of a
crate can be compiled into the same executable, and we shouldn't be warning
about our first-class features.
2015-01-06 16:42:43 +00:00
Jorge Aparicio
ec133fed40 cleanup: use short AT notation (Ty::Item instead of <Ty as Trait>::Item) 2015-01-06 11:23:18 -05:00
Alex Crichton
9d0b3c9fc9 rustc: Turn off multiple versions of crate warning
This warning has been around in the compiler for quite some time now, but the
real place for a warning like this, if it should exist, is in Cargo, not in the
compiler itself. It's a first-class feature of Cargo that multiple versions of a
crate can be compiled into the same executable, and we shouldn't be warning
about our first-class features.
2015-01-06 08:22:59 -08:00
bors
8efd9901b6 auto merge of #20573 : huonw/rust/num-stab-2, r=alexcrichton
cc #19260 

Open questions:

- I still feel weird about marking functions like `exp` as `#[stable]` in `core` since they're highly likely to call into libm which is theoretically something core is designed to avoid and so we may be forced/want to move it at some point in the future, and so it feels like a lie to call it `#[stable]` (I know `core` is `#[experimental]`, but still...)
- `abs_sub` is a horrible name IMO: it feels like it is `(a - b).abs()`, but it is actually `(a - b).max(0.)`. maybe something along the lines of `pos_diff` ("positive difference") is better.
- the associated-function nature of `Int::from_be` and `Int::from_le` feel strange to me, it feels like they should be methods, but I cannot think of a good name.

I'm also not hugely in favour of `ldexp` and `frexp` but the precedent from C is large. (e.g. AFAICT,  `ldexp` must mean "load exponent" which is essentially what it does... but only for a subset of its inputs.)
2015-01-06 13:30:29 +00:00
Valerii Hiora
72e08006da iOS: CString fallout 2015-01-06 15:21:04 +02:00
Huon Wilson
f3a80ab9d2 Apply stability attributes to core::num::{Int, SignedInt, UnsignedInt}. 2015-01-06 23:21:27 +11:00
Huon Wilson
49feb0c431 Unstabilise f32/f64 constants that are int/uint.
Pending integer conventions.
2015-01-06 23:21:27 +11:00
Huon Wilson
65922dd42d Apply stability attributes to std::num::Float. 2015-01-06 23:21:27 +11:00
Huon Wilson
ae4762761c Merge core::num::Float and std::num::FloatMath.
`FloatMath` no longer exists and all functionality from both traits is
available under `Float`. Change from

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

to

    use std::num::Float;

[breaking-change]
2015-01-06 23:21:27 +11:00
Huon Wilson
1291fc76e0 Reword unstability message for core::num::Float. 2015-01-06 23:21:01 +11:00
Huon Wilson
cd4ed38404 Deprecate the constant-returning functions in Float.
These are replaced by the equivalent constants in `std::f32` and
`std::f64` respectively.

[breaking-change]
2015-01-06 23:21:01 +11:00
Huon Wilson
cfb2e2acd7 num: remove deprecated functionality. 2015-01-06 23:21:01 +11:00
Jared Roesch
b683e879e4 Add check to ensure trait bounds are only placed o
Add check to ensure trait bounds are only placed on
ty_param
2015-01-06 03:54:53 -08:00
bors
340ac040f7 auto merge of #20610 : alexcrichton/rust/rollup, r=alexcrichton 2015-01-06 08:25:32 +00:00
Alex Crichton
4b359e3aee More test fixes! 2015-01-05 22:58:37 -08:00
Peter Atashian
351e6b7255 Implement TTY::get_winsize for Windows
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-01-06 00:54:09 -05:00
Alex Crichton
ee9921aaed Revert "Remove i suffix in docs"
This reverts commit f031671c6e.

Conflicts:
	src/libcollections/slice.rs
	src/libcore/iter.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/rwlock.rs
2015-01-05 19:08:37 -08:00
Alex Crichton
f331c56869 Test fixes 2015-01-05 19:07:07 -08:00
Alex Crichton
7975fd9cee rollup merge of #20482: kmcallister/macro-reform
Conflicts:
	src/libflate/lib.rs
	src/libstd/lib.rs
	src/libstd/macros.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/parse/parser.rs
	src/libsyntax/show_span.rs
	src/test/auxiliary/macro_crate_test.rs
	src/test/compile-fail/lint-stability.rs
	src/test/run-pass/intrinsics-math.rs
	src/test/run-pass/tcp-connect-timeouts.rs
2015-01-05 19:01:17 -08:00
Alex Crichton
563f6d8218 rollup merge of #20608: nikomatsakis/assoc-types-method-dispatch 2015-01-05 18:56:45 -08:00
Alex Crichton
384e218789 Merge remote-tracking branch 'nrc/sized-2' into rollup
Conflicts:
	src/liballoc/boxed.rs
	src/libcollections/btree/map.rs
	src/libcollections/slice.rs
	src/libcore/borrow.rs
	src/libcore/cmp.rs
	src/libcore/ops.rs
	src/libstd/c_str.rs
	src/libstd/collections/hash/map.rs
	src/libsyntax/parse/obsolete.rs
	src/test/compile-fail/unboxed-closure-sugar-default.rs
	src/test/compile-fail/unboxed-closure-sugar-equiv.rs
	src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs
	src/test/compile-fail/unboxed-closure-sugar-region.rs
	src/test/compile-fail/unsized3.rs
	src/test/run-pass/associated-types-conditional-dispatch.rs
2015-01-05 18:55:41 -08:00
Niko Matsakis
e58f1bdc03 Normalize predicates during method winnowing.
Fixes #20604.
Fixes #20378.
2015-01-05 21:50:23 -05:00
Niko Matsakis
2a1ba2f1ac Permit method calls based on where clauses. 2015-01-05 21:50:22 -05:00
Alex Crichton
afbce050ca rollup merge of #20556: japaric/no-for-sized
Conflicts:
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcore/borrow.rs
	src/libcore/cmp.rs
	src/libcore/ops.rs
	src/libstd/c_str.rs
	src/test/compile-fail/issue-19009.rs
2015-01-05 18:47:45 -08:00
Alex Crichton
cf8a11e98b rollup merge of #20594: nikomatsakis/orphan-ordered
Conflicts:
	src/libsyntax/feature_gate.rs
2015-01-05 18:42:34 -08:00