Commit Graph

53106 Commits

Author SHA1 Message Date
Steve Klabnik
4b8e7cb504 Rollup merge of #33539 - nikomatsakis:static-error, r=pnkfelix
fix DFS for region error reporting

This was causing terrible error reports, because the algorithm was incorrectly identifying the constraints.

r? @eddyb
2016-05-11 09:27:44 -04:00
Steve Klabnik
130e76b46a Rollup merge of #33528 - cramertj:E0061typeo, r=jseyfried
E0061 typo fix

Fixed silly typo.
2016-05-11 09:27:44 -04:00
Steve Klabnik
8c6796f0a7 Rollup merge of #33524 - briangreenery:briangreenery-fast-and-loose, r=steveklabnik
doc: Fix tiny typo in vec-alloc.md

Change `fast an loose` to `fast and loose`.
2016-05-11 09:27:44 -04:00
Steve Klabnik
30df9d0201 Rollup merge of #33522 - mbrubeck:inline-rawvec-cap, r=nagisa
Inline RawVec::cap

This was showing up in a Servo profile.
2016-05-11 09:27:43 -04:00
Steve Klabnik
4fe787134a Rollup merge of #33386 - cramertj:E0504, r=steveklabnik
Add detailed error explanation for E0504

Part of #32777
2016-05-11 09:27:43 -04:00
Steve Klabnik
3b75f4b56e Rollup merge of #33345 - birkenfeld:issue-31754, r=pnkfelix
middle: reset loop labels while visiting closure

This should fix #31754 and follow-up #25343.  Before the latter, the closure was visited twice in the context of the enclosing fn, which made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context of the main fn (which is intended, since it is not a separate item) but resets the found loop labels while being visited.

Fixes: #31754

Note: I amended the test file from #25343, but I don't know if the original or amended test are effective, since as far as I could see, compiletest's run-pass tests do not check for zero warnings emitted?

/cc @Manishearth
2016-05-11 09:27:43 -04:00
Steve Klabnik
82c4f5915b Rollup merge of #33260 - mrmiywj:help-on-pattern-guard, r=guillaumegomez
add help on pattern guard
2016-05-11 09:27:42 -04:00
Steve Klabnik
c5e0099a20 Rollup merge of #33129 - GuillaumeGomez:fmt_doc, r=steveklabnik
Doc improvement on std::fmt module

Part of #29355.

r? @steveklabnik
2016-05-11 09:27:42 -04:00
bors
c7ab8840c8 Auto merge of #33425 - eddyb:rift, r=nikomatsakis
Split the type context into a global and a local (inference-only) one.

After this change, each `InferCtxt` creates its own local type interner for types with inference by-products.
Most of the code which handles both a global and a local interner uses `'gcx` and `'tcx` for them.
A reference to the type context in that situation (e.g. `infcx.tcx`) is `TyCtxt<'a, 'gcx, 'tcx>`.
The global type context which used to be `&'a TyCtxt<'tcx>` is now `TyCtxt<'a, 'tcx, 'tcx>`.

In order to minimize the number of extra lifetime parameters, many functions became methods.
Where possible (some inherent impls), lifetime parameters were added on the impl, not each method.

As inference by-products no longer escape their inference contexts, memory usage is lower.
Example of `-Z time-passes` excerpt for `librustc`, stage1 (~100MB gains):
Before "rustc: Split local type contexts interners from the global one.":
```
time: 0.395; rss: 335MB item-types checking
time: 15.392; rss: 472MB        item-bodies checking
time: 0.000; rss: 472MB drop-impl checking
time: 1.140; rss: 478MB const checking
time: 0.139; rss: 478MB privacy checking
time: 0.024; rss: 478MB stability index
time: 0.072; rss: 478MB intrinsic checking
time: 0.038; rss: 478MB effect checking
time: 0.255; rss: 478MB match checking
time: 0.128; rss: 484MB liveness checking
time: 1.372; rss: 484MB rvalue checking
time: 1.404; rss: 597MB MIR dump
time: 0.809; rss: 599MB MIR passes
```
After:
```
time: 0.467; rss: 337MB item-types checking
time: 17.443; rss: 395MB        item-bodies checking
time: 0.000; rss: 395MB drop-impl checking
time: 1.423; rss: 401MB const checking
time: 0.141; rss: 401MB privacy checking
time: 0.024; rss: 401MB stability index
time: 0.116; rss: 401MB intrinsic checking
time: 0.038; rss: 401MB effect checking
time: 0.382; rss: 401MB match checking
time: 0.132; rss: 407MB liveness checking
time: 1.678; rss: 407MB rvalue checking
time: 1.614; rss: 503MB MIR dump
time: 0.957; rss: 512MB MIR passes
```

**NOTE**: Functions changed to methods weren't re-indented to keep this PR easier to review.
Once approved, the changes will be mechanically performed.
However, indentation changes of function arguments are there - and I believe there's a way to hide whitespace-only changes in diffs on GitHub.
2016-05-10 23:40:09 -07:00
Eduard Burtescu
42eb7032fa Fixup indentation after methodification. 2016-05-11 08:48:12 +03:00
bors
80ec1b9f10 Auto merge of #33512 - birkenfeld:issue-25944, r=sanxiyn
rustdoc: remove artificial indentation of doctest code

The indentation makes the examples look nicer when printed (when is this done?), but breaks tests using multi-line string literals.

Fixes: #25944
2016-05-10 20:14:46 -07:00
Eduard Burtescu
a1c170fc35 rustc: Split local type contexts interners from the global one. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
31a07b0ce6 rustc_typeck: Generalize over 'tcx != 'gcx. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
3a3013613a rustc: Remove the unnecessary ast_ty_to_ty_cache. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
20652162ca rustc: More interning for data used in Ty<'tcx>. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
8f72d8127f rustc: Generalize a minimum set of functions over 'tcx != 'gcx. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
f0b2b3c441 rustc: Remove a redundant lifetime parameter from ExprUseVisitor. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
12e56ea56b rustc: Wrap users of InferCtxt in an anonymous scope. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
8a704f6dc7 rustc: Remove the TyCtxt field from ParameterEnvironment. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
0053b442f8 rustc_typeck: Use Deref for FnCtxt, Inherited and InferCtxt fields and methods. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
76affa5d6f rustc: Split 'tcx into 'gcx and 'tcx for InferCtxt and its users. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
166dbc3273 rustc: Keep a reference to the interners in TyCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
2fbbaf2f17 rustc: Use set recovery APIs in the TyCtxt interners. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
513d392f7e rustc: Replace &'a TyCtxt<'tcx> with a TyCtxt<'a, 'tcx> wrapper. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
8fc2c4652c regionck: Use methods on RegionCtxt instead of free functions. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
f8ea24edc8 rustc: Avoid free functions taking &TyCtxt and &InferCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
d7ee56e862 typeck: Turn everything operating on FnCtxt into a method. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
ef2f5f6d8e typeck: Avoid passing &TyCtxt around where possible. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
e387e6c7c8 typeck: merge CollectCtxt and collect::CollectCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
8600a67782 mem_categorization: freely_aliasable doesn't need to take TyCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
6e290998c3 infer: Turn normalize_associated_type into a method on TyCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
0907c198c4 infer: Use methods for creating an InferCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
b5122d5c4c rustc: Always refer to TyCtxt as tcx. 2016-05-11 04:14:58 +03:00
Guillaume Gomez
0908d66882 Doc improvement on std::fmt module 2016-05-10 23:56:57 +02:00
bors
6dbb0e86ae Auto merge of #33319 - birkenfeld:issue31424, r=jseyfried
borrowck: do not suggest to change "&mut self" to "&mut mut self"

Matching the snippet string might not be the cleanest, but matching
the AST node instead seems to end in a lot of nested `if let`s, so I
don't know what's better.

Of course it's entirely possible that there is another API altogether
that I just don't know of?

Fixes #31424.
2016-05-10 14:36:46 -07:00
bors
04308ceefa Auto merge of #33488 - eddyb:trans-fixes, r=Aatch
Fix several -Z orbit crater blockers.

Fixes 3 of the issues found by @nikomatsakis' crater run with `-Z orbit` forced on:
https://gist.github.com/nikomatsakis/6688c30a0e5d3fed07cc1ebd4efb1412

Two of the regressions seemed to be fixed by #33130 and the remaining two are timeouts.
2016-05-10 10:40:02 -07:00
Niko Matsakis
de0906fe12 fix DFS for region error reporting
This was causing terrible error reports, because the algorithm was
incorrectly identifying the constraints.
2016-05-10 12:22:20 -04:00
Georg Brandl
fef827672d borrowck: do not suggest to change "&mut self" to "&mut mut self"
Matching the snippet string might not be the cleanest, but matching
the AST node instead seems to end in a lot of nested `if let`s...

Fixes #31424.
2016-05-10 14:57:44 +02:00
bors
d6588097d4 Auto merge of #33471 - birkenfeld:issue-33464, r=jseyfried
resolve: do not modify span of non-importable name

This span modification is probably leftover from a time when import spans were assigned differently.

With this change, error spans for the following are properly reported:

```
use abc::one_el;
use abc::{a, bbb, cccccc};
use a_very_long_name::{el, el2};
```

before (spans only):
```
x.rs:3 use abc::one_el;
           ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~
(internal compiler error: unprintable span)
(internal compiler error: unprintable span)
```

after:
```
x.rs:3 use abc::one_el;
           ^~~~~~~~~~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~~~~
x.rs:5 use a_very_long_name::{el, el2};
                              ^~
x.rs:5 use a_very_long_name::{el, el2};
                                  ^~~
```

Fixes: #33464
2016-05-10 05:22:17 -07:00
bors
3585321d1e Auto merge of #33337 - birkenfeld:issue-27842, r=jseyfried
typeck: show a note about tuple indexing for erroneous tup[i]

Fixes: #27842
2016-05-10 03:06:05 -07:00
bors
1939b76903 Auto merge of #33473 - michaelwoerister:split-cratecontext, r=nikomatsakis
Preparatory refactorings for collector-driven trans.

This is a set of refactorings that allows to do translation item collection and partitioning before LocalCrateContext instances or LLVM modules are generated. As a consequence we can now create LocalCrateContexts already with knowledge of the codegen unit it will be used for. This is a preparation step for driving trans by the results of codegen unit partitioning.
2016-05-09 23:50:10 -07:00
Georg Brandl
b62e7ff18d resolve: do not modify span of non-importable name
This span modification is probably leftover from a time when
import spans were assigned differently.

With this change, error spans for the following are properly reported:

```
use abc::one_el;
use abc::{a, bbb, cccccc};
use a_very_long_name::{el, el2};
```

before (spans only):
```
x.rs:3 use abc::one_el;
           ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~
(internal compiler error: unprintable span)
(internal compiler error: unprintable span)
```

after:
```
x.rs:3 use abc::one_el;
           ^~~~~~~~~~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~~~~
x.rs:5 use a_very_long_name::{el, el2};
                              ^~
x.rs:5 use a_very_long_name::{el, el2};
                                  ^~~
```

Fixes: #33464
2016-05-10 08:35:37 +02:00
bors
a4d2424cc3 Auto merge of #33443 - jseyfried:resolve_ast, r=nrc
Perform name resolution before and during ast->hir lowering

This PR performs name resolution before and during ast->hir lowering instead of in phase 3.
r? @nrc
2016-05-09 21:31:55 -07:00
bors
72ed7e7894 Auto merge of #32900 - alexcrichton:panic2abort, r=nikomatsakis
rustc: Implement custom panic runtimes

This commit is an implementation of [RFC 1513] which allows applications to
alter the behavior of panics at compile time. A new compiler flag, `-C panic`,
is added and accepts the values `unwind` or `panic`, with the default being
`unwind`. This model affects how code is generated for the local crate, skipping
generation of landing pads with `-C panic=abort`.

[RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md

Panic implementations are then provided by crates tagged with
`#![panic_runtime]` and lazily required by crates with
`#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic
runtime must match the final product, and if the panic strategy is not `abort`
then the entire DAG must have the same panic strategy.

With the `-C panic=abort` strategy, users can expect a stable method to disable
generation of landing pads, improving optimization in niche scenarios,
decreasing compile time, and decreasing output binary size. With the `-C
panic=unwind` strategy users can expect the existing ability to isolate failure
in Rust code from the outside world.

Organizationally, this commit dismantles the `sys_common::unwind` module in
favor of some bits moving part of it to `libpanic_unwind` and the rest into the
`panicking` module in libstd. The custom panic runtime support is pretty similar
to the custom allocator support with the only major difference being how the
panic runtime is injected (takes the `-C panic` flag into account).

Closes #32837
2016-05-09 18:23:48 -07:00
Taylor Cramer
d8882e263b E0061 typo fix 2016-05-09 18:18:57 -07:00
Alex Crichton
38e6e5d0a9 rustc: Use C++ personalities on MSVC
Currently the compiler has two relatively critical bugs in the implementation of
MSVC unwinding:

* #33112 - faults like segfaults and illegal instructions will run destructors
           in Rust, meaning we keep running code after a super-fatal exception
           has happened.

* #33116 - When compiling with LTO plus `-Z no-landing-pads` (or `-C
           panic=abort` with the previous commit) LLVM won't remove all `invoke`
           instructions, meaning that some landing pads stick around and
           cleanups may be run due to the previous bug.

These both stem from the flavor of "personality function" that Rust uses for
unwinding on MSVC. On 32-bit this is `_except_handler3` and on 64-bit this is
`__C_specific_handler`, but they both essentially are the "most generic"
personality functions for catching exceptions and running cleanups. That is,
thse two personalities will run cleanups for all exceptions unconditionally, so
when we use them we run cleanups for **all SEH exceptions** (include things like
segfaults).

Note that this also explains why LLVM won't optimize away `invoke` instructions.
These functions can legitimately still unwind (the `nounwind` attribute only
seems to apply to "C++ exception-like unwining"). Also note that the standard
library only *catches* Rust exceptions, not others like segfaults and illegal
instructions.

LLVM has support for another personality, `__CxxFrameHandler3`, which does not
run cleanups for general exceptions, only C++ exceptions thrown by
`_CxxThrowException`. This essentially ideally matches our use case, so this
commit moves us over to using this well-known personality function as well as
exception-throwing function.

This doesn't *seem* to pull in any extra runtime dependencies just yet, but if
it does we can perhaps try to work out how to implement more of it in Rust
rather than relying on MSVCRT runtime bits.

More details about how this is actually implemented can be found in the changes
itself, but this...

Closes #33112
Closes #33116
2016-05-09 17:28:48 -07:00
bors
e0fd34bba0 Auto merge of #33523 - Manishearth:rollup, r=Manishearth
Rollup of 10 pull requests

- Successful merges: #33129, #33224, #33370, #33383, #33431, #33474, #33480, #33496, #33509, #33514
- Failed merges:
2016-05-09 16:11:51 -07:00
Manish Goregaokar
52f48bdcb5
Rollup merge of #33493 - Manishearth:more-diag, r=Manishearth
r? @GuillaumeGomez
2016-05-09 15:00:20 -07:00
Manish Goregaokar
433f907050
Rollup merge of #33514 - birkenfeld:issue-29503, r=alexcrichton
rustdoc: do not strip blanket impls in crate of origin

In `impl<T> Trait for T`, the blanket type parameters `T` were recognized as "local" and "not exported", so these impls were thrown out.

Now we check if they are generic, and keep them in that case.

Fixes: #29503
2016-05-09 14:59:44 -07:00
Manish Goregaokar
fb382df1f8
Rollup merge of #33509 - birkenfeld:issue-30219, r=alexcrichton
rustdoc: fix emitting duplicate implementors in .js files

The collect() fn checks for double quotes; use them here as well.

Fixes: #30219
2016-05-09 14:59:42 -07:00