Commit Graph

36530 Commits

Author SHA1 Message Date
Alex Crichton
0393a1602f rollup merge of #20650: klutzy/omg-windows-error-mode
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-06 15:38:56 -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
0631b466c2 rollup merge of #19430: pczarn/interp_tt-cleanup
Conflicts:
	src/libsyntax/parse/parser.rs
2015-01-06 15:38:10 -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
Alex Crichton
3892dd1eaa rollup merge of #20593: nikomatsakis/unused-tps-in-impl
Conflicts:
	src/libcollections/lib.rs
	src/librustc/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
2015-01-06 15:31:39 -08:00
Alex Crichton
e3f047c8c5 rollup merge of #20653: alexcrichton/entry-unstable
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 15:29:18 -08:00
Alex Crichton
ed61bd8693 rollup merge of #20652: vhbit/thread-key-type
This is a manual merge of #20627 and #20634 to avoid conflicts in rollup and also avoid one roundtrip. I've leave copyright to original author.  If this one is moved to rollup original PR could be closed. cc @mneumann

@alexcrichton r?

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 15:29:17 -08:00
Alex Crichton
acc5d7914a rollup merge of #20647: aturon/stab-2-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 15:29:15 -08:00
Alex Crichton
0b3b957554 rollup merge of #20645: nikomatsakis/rustbook-ice
Conflicts:
	src/librustc/middle/mem_categorization.rs
	src/librustc/middle/ty.rs
	src/librustc_trans/trans/base.rs
	src/librustc_trans/trans/expr.rs
	src/librustc_trans/trans/foreign.rs
	src/librustc_typeck/check/mod.rs
2015-01-06 15:29:09 -08:00
Alex Crichton
e0f546a07e rollup merge of #20643: scialex/update-zsh 2015-01-06 15:25:02 -08:00
Alex Crichton
0f1bd6f105 rollup merge of #20623: jroesch/reject-non-param-bounds
This closes #20019, and should reject any where clauses placed on types not involving type parameters.

r? @nikomatsakis
2015-01-06 15:25:00 -08:00
Alex Crichton
6ccfd3f2c8 rollup merge of #20612: retep998/winsize
This calculates the width and height using the bounding box of the window in the buffer. Bounding box coordinates are inclusive so I have to add 1 to both dimensions.
2015-01-06 15:24:58 -08:00
Alex Crichton
cc20935ad8 rollup merge of #20570: sanxiyn/no-analysis 2015-01-06 15:24:55 -08:00
Alex Crichton
f358dbf1e7 rollup merge of #20557: cactorium/prettyprinters
As per https://github.com/rust-lang/rust/issues/20405. To be more precise, the changes just the processing of enums when the name is "RUST$ENCODED$ENUM$..." so it correctly parses when there is more than one number encoding the location of the field it's looking for to determine state of the enum
2015-01-06 15:24:52 -08:00
Piotr Czarnecki
d85c017f92 Cleanup and followup to PR #17830: parsing changes
Prevents breaking down `$name` tokens into separate `$` and `name`.
Reports unknown macro variables.

Fixes #18775
Fixes #18839
Fixes #15640
2015-01-07 00:24:48 +01:00
Alex Crichton
e2f97f51ad Register new snapshots
Conflicts:
	src/librbml/lib.rs
	src/libserialize/json_stage0.rs
	src/libserialize/serialize_stage0.rs
	src/libsyntax/ast.rs
	src/libsyntax/ext/deriving/generic/mod.rs
	src/libsyntax/parse/token.rs
2015-01-06 15:24:24 -08:00
Alex Crichton
5c3ddcb15d rollup merge of #20481: seanmonstar/fmt-show-string
Conflicts:
	src/compiletest/runtest.rs
	src/libcore/fmt/mod.rs
	src/libfmt_macros/lib.rs
	src/libregex/parse.rs
	src/librustc/middle/cfg/construct.rs
	src/librustc/middle/dataflow.rs
	src/librustc/middle/infer/higher_ranked/mod.rs
	src/librustc/middle/ty.rs
	src/librustc_back/archive.rs
	src/librustc_borrowck/borrowck/fragments.rs
	src/librustc_borrowck/borrowck/gather_loans/mod.rs
	src/librustc_resolve/lib.rs
	src/librustc_trans/back/link.rs
	src/librustc_trans/save/mod.rs
	src/librustc_trans/trans/base.rs
	src/librustc_trans/trans/callee.rs
	src/librustc_trans/trans/common.rs
	src/librustc_trans/trans/consts.rs
	src/librustc_trans/trans/controlflow.rs
	src/librustc_trans/trans/debuginfo.rs
	src/librustc_trans/trans/expr.rs
	src/librustc_trans/trans/monomorphize.rs
	src/librustc_typeck/astconv.rs
	src/librustc_typeck/check/method/mod.rs
	src/librustc_typeck/check/mod.rs
	src/librustc_typeck/check/regionck.rs
	src/librustc_typeck/collect.rs
	src/libsyntax/ext/format.rs
	src/libsyntax/ext/source_util.rs
	src/libsyntax/ext/tt/transcribe.rs
	src/libsyntax/parse/mod.rs
	src/libsyntax/parse/token.rs
	src/test/run-pass/issue-8898.rs
2015-01-06 15:22:24 -08:00
Nick Cameron
9f07d055f7 markers -> marker 2015-01-07 12:10:31 +13:00
Alex Crichton
5f27b50080 rollup merge of #20609: cmr/mem 2015-01-06 15:07:48 -08:00
Alex Crichton
1afe8a4fb8 rollup merge of #20562: nick29581/arrays-3 2015-01-06 15:05:53 -08:00
Nick Cameron
0c7f7a5fb8 fallout 2015-01-07 12:02:52 +13:00
Aaron Turon
caca9b2e71 Fallout from stabilization 2015-01-06 14:57:52 -08:00
Sean McArthur
44440e5c18 core: split into fmt::Show and fmt::String
fmt::Show is for debugging, and can and should be implemented for
all public types. This trait is used with `{:?}` syntax. There still
exists #[derive(Show)].

fmt::String is for types that faithfully be represented as a String.
Because of this, there is no way to derive fmt::String, all
implementations must be purposeful. It is used by the default format
syntax, `{}`.

This will break most instances of `{}`, since that now requires the type
to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the
correct fix. Types that were being printed specifically for users should
receive a fmt::String implementation to fix this.

Part of #20013

[breaking-change]
2015-01-06 14:49:42 -08:00
Niko Matsakis
d31105e4f5 Add new tests covering various cases. 2015-01-06 17:17:49 -05:00
Niko Matsakis
d91323992c Fix fallout in tests. 2015-01-06 17:17:49 -05:00
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
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
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
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