Commit Graph

53326 Commits

Author SHA1 Message Date
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
Jeffrey Seyfried
946efcd4ca Refactor the hir::lowering::lower_* functions into methods of LoweringContext 2016-05-10 05:41:01 +00:00
Anton Blanchard
0a380897a8 Copy more libraries from local Rust to stage0
When bootstrapping Rust using a previously built toolchain, I noticed
a number of libraries were not copied in. As a result the copied in
rustc fails to execute because it can't find all its dependences.

Add them into the local_stage0.sh script.
2016-05-10 15:12:19 +10:00
Jeffrey Seyfried
8d5c5785d5 Remove needless pubs 2016-05-10 04:58:14 +00:00
Jeffrey Seyfried
eed8d70ac5 Give lowering functions mutable access to the lowering context 2016-05-10 04:58:09 +00:00
Jeffrey Seyfried
417fe6d16e Refactor away method LoweringContext::diagnostic 2016-05-10 04:58:03 +00:00
Jeffrey Seyfried
df572fcf4e Remove unused function lower_opt_bounds 2016-05-10 04:57:50 +00: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
Manish Goregaokar
6436b6080c
Rollup merge of #33496 - silvo38:master, r=apasel422
Fix minor typo in E0312
2016-05-09 14:59:41 -07:00
Manish Goregaokar
35cc6b0c2c
Rollup merge of #33480 - birkenfeld:issue-33422, r=steveklabnik
book: fixup code in error handling tutorial

A few oversights happened while porting the example from docopt to getopts.  I retraced all the steps, fixing code and description as necessary.

Fixes: #33422
2016-05-09 14:59:40 -07:00
Manish Goregaokar
fffaf665f2
Rollup merge of #33474 - frewsxcv:unwrap-err, r=alexcrichton
Utilize `Result::unwrap_err` in more places.

None
2016-05-09 14:59:38 -07:00
Manish Goregaokar
c45d4816ca
Rollup merge of #33431 - GuillaumeGomez:issue-30416, r=steveklabnik
Update CSS for future rustdoc merge

cc #33382

r? @steveklabnik
cc @Manishearth
cc @birkenfeld
2016-05-09 14:59:36 -07:00
Manish Goregaokar
57fa783d3c
Rollup merge of #33383 - cramertj:E0509, r=Manishearth
Add detailed error explanation for E0509

Part of #32777
2016-05-09 14:59:33 -07:00
Manish Goregaokar
9f5f997c13
Rollup merge of #33370 - aochagavia:dump, r=nrc
save-analysis: use a decoupled representation for dumped data

Closes #33348

This will probably break any tool relying on the csv backend of save_analysis, for the following reasons:

1. Dumped spans don't contain extents anymore (`Dump` uses `SpanData` now instead of internal `Span`s). In case we still want to dump extents we could add them to `SpanData`.
1. `DefId`s are no longer dumped as a pair of `(ref_id, ref_crate)`. Instead, they are dumped as a single `Id`.

@nrc You said something about storing the id in a `u64`, but you didn't explain why. I kept using `u32` in this branch but I can change it if you prefer that.

r? @nrc

By the way, the fact that this breaks tools relying on CSV may be a good occasion to start dumping CSV in a different way (i.e. using the serializer like in the JSON backend).
2016-05-09 14:59:29 -07:00
Manish Goregaokar
d394aa064e
Rollup merge of #33224 - alexcrichton:create-exit-status, r=aturon
std: Allow creating ExitStatus from raw values

Sometimes a process may be waited on externally from the standard library, in
which case it can be useful to create a raw `ExitStatus` structure to return.
This commit extends the existing Unix `ExitStatusExt` extension trait and adds a
new Windows-specific `ExitStatusExt` extension trait to do this. The methods are
currently called `ExitStatus::from_raw`.

cc #32713
2016-05-09 14:59:20 -07:00
Brian Green
9d2c45d0e7 doc: Fix tiny typo in vec-alloc.md
Change `fast an loose` to `fast and loose`.
2016-05-09 14:28:42 -07:00
bors
0e7cb8bc31 Auto merge of #33224 - alexcrichton:create-exit-status, r=aturon
std: Allow creating ExitStatus from raw values

Sometimes a process may be waited on externally from the standard library, in
which case it can be useful to create a raw `ExitStatus` structure to return.
This commit extends the existing Unix `ExitStatusExt` extension trait and adds a
new Windows-specific `ExitStatusExt` extension trait to do this. The methods are
currently called `ExitStatus::from_raw`.

cc #32713
2016-05-09 14:04:08 -07:00
Georg Brandl
5606b42981 rustdoc: remove artificial indentation of doctest code
This makes the examples look nicer when printed (when is this
done?), but breaks tests using multi-line string literals.

Fixes: #25944
2016-05-09 22:46:40 +02:00
Michael Woerister
118cc9e8e1 Fix some rebasing fallout. 2016-05-09 16:17:00 -04:00
Michael Woerister
00eabcbefa trans::context: Remove some tcx::tls wackiness 2016-05-09 16:17:00 -04:00
Michael Woerister
86a691a5c7 trans: Consistently name SharedCrateContext instances 'scx' 2016-05-09 16:17:00 -04:00
Michael Woerister
b89a5d1f7c Make FixedCount partitioning handle case where codegen units have to be added. 2016-05-09 16:17:00 -04:00
Michael Woerister
0142336a2a trans: Add some explanatory comments to trans::context types. 2016-05-09 16:17:00 -04:00
Michael Woerister
a8e34dfc29 trans: Make partitioning available in LocalCrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
bebcb285ad Restructure trans_crate() so that codegen unit partitioning happens before creating LocalCrateContexts. 2016-05-09 16:17:00 -04:00
Michael Woerister
bb8c8c58d3 Make trans::collector only depend on SharedCrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
75bf6173e5 trans: Make glue::get_drop_glue_type() independent of CrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
3f74c6afe0 trans: Make base::custom_coerce_unsize_info only depend on SharedCrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
566aa54b49 trans: Make common::fulfill_obligation only depend on SharedCrateContext.
Plus make it produce a nicer dependency graph via DepTrackingMap::memoize().
2016-05-09 16:17:00 -04:00
Michael Woerister
d24ead0f93 trans: Make various trans::collector functions independent of CrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
2564199d8f trans: Make meth::get_vtable_methods() not depend on CrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
100a4f5699 trans: Make normalize_and_test_predicates() not depend on CrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
60259b9d90 Make trans::collector item printing methods independent of CrateContext. 2016-05-09 16:17:00 -04:00
Michael Woerister
b2ea54d2c6 trans: Split LocalCrateContext ownership out of SharedCrateContext. 2016-05-09 16:17:00 -04:00
Eduard Burtescu
cb3a557e0c trans: deal with the fact that ZSTs are always "initialized". 2016-05-09 22:52:06 +03:00
Eduard Burtescu
d460597e33 trans: monomorphize varidiac call argument types. 2016-05-09 22:52:01 +03:00
Matt Brubeck
06f5fa4a0c Inline RawVec::cap 2016-05-09 11:44:55 -07:00
Taylor Cramer
38a5338c63 Add detailed error explanation for E0504
Removed unnecessary use of threads from E0504

Cleaned up line ending on E0504

Added more examples for E0504

Changed to erroneous code wording

Switched Rc example to thread/Arc example

Added comments describing why errors no longer occur
2016-05-09 11:05:11 -07:00
bors
faca79fc33 Auto merge of #33457 - oli-obk:const_err/cast_u8_ptr, r=eddyb
casting `&[u8]` to `* const u8` doesn't work in const_eval

fixes #33452

r? @eddyb

cc @Ms2ger
2016-05-09 10:57:35 -07:00
bors
af0a433865 Auto merge of #33048 - Amanieu:integer_atomics, r=alexcrichton
Add integer atomic types

Tracking issue: #32976
RFC: rust-lang/rfcs#1543

The changes to AtomicBool in the RFC are not included, they are in a separate PR (#32365).
2016-05-09 08:48:58 -07:00
Alex Crichton
0ec321f7b5 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).
2016-05-09 08:22:36 -07:00
Alex Crichton
96b228835a trans: Always lower to frem
Long ago LLVM unfortunately didn't handle the 32-bit MSVC case of `frem` where
it can't be lowered to `fmodf` because that symbol doesn't exist. That was since
fixed in http://reviews.llvm.org/D12099 (landed as r246615) and was released in
what appears to be LLVM 3.8. Now that we're using that branch of LLVM let's
remove our own hacks and help LLVM optimize a little better by giving it
knowledge about what we're doing.
2016-05-09 08:17:46 -07:00
Georg Brandl
6100b70b98 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 16:50:47 +02:00