Commit Graph

65395 Commits

Author SHA1 Message Date
Alex Crichton
695dee063b rustc: Implement the #[global_allocator] attribute
This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/197

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389
2017-07-05 14:37:01 -07:00
bors
4c225c4d17 Auto merge of #42976 - ids1024:redoxfix, r=sfackler
Fix Redox build, apparently broken by #42687
2017-07-03 12:20:57 +00:00
bors
1d2db7b9e8 Auto merge of #43010 - stjepang:stabilize-sort-unstable, r=alexcrichton
Stabilize feature sort_unstable

Closes #40585
2017-07-02 23:54:32 +00:00
Stjepan Glavina
66f8cddae5 Remove the remaining feature gates 2017-07-02 21:29:39 +02:00
Stjepan Glavina
21149bcd53 Fix lint errors 2017-07-02 19:14:16 +02:00
bors
0679711398 Auto merge of #42938 - est31:col_number, r=eddyb
Output column number info when panicking

Outputs the column number when panicking. Useful when you e.g. have code like `foo[i] = bar[k] + bar[l]` and you get a panic with index out of bounds, or when you have an expression like `a = b + c + d + e` and the addition overflows. Now you know which operation to blame!

The format is `file:line:column`, just like for compiler errors. Example output with the patch:

```
thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 8', src/main.rs:3:8
```

As some of the API between the compiler and the library landscape gets broken, this is a bit hackier than I'd originally wanted it to be.

* `panic` and `panic_bounds_check` lang items got an additional column param, on stage0 I still have to use the previous version. After a SNAP this should be resolved.
* For `#[derive(RustcDeserialze)]`, stage0 requires a fixed signature for `std::rt::begin_panic`, so we can't change it right away. What we need to do instead is to keep the signature, and add a `begin_panic_new` function that we use in later stages instead. After a SNAP we can change the `begin_panic` function and rely on it instead of `begin_panic_new`, and one SNAP later we can remove `begin_panic_new`.
* Fortunately I didn't have to break anything about the panic hook API, I could easily extend it.

Note that debuginfo remains unchanged, so RUST_BACKTRACE output won't contain any column info. See issue #42921 for discussion on including the column in debuginfo.
2017-07-02 15:40:26 +00:00
est31
3b91f9406c Update cargo
... to get https://github.com/rust-lang/cargo/pull/4244 and
https://github.com/rust-lang/cargo/pull/4246
2017-07-02 16:42:13 +02:00
bors
2a992167c5 Auto merge of #43015 - arielb1:every-error-counts, r=eddyb
report the total number of errors on compilation failure

Prior to this PR, when we aborted because a "critical pass" failed, we displayed the number of errors from that critical pass. While that's the number of errors that caused compilation to abort in *that place*, that's not what people really want to know. Instead, always report the total number of errors, and don't bother to track the number of errors from the last pass that failed.

This changes the compiler driver API to handle errors more smoothly, therefore is a compiler-api-[breaking-change].

Fixes #42793.

r? @eddyb
2017-07-02 13:22:23 +00:00
Ariel Ben-Yehuda
fb7ab9e43d report the total number of errors on compilation failure
Prior to this PR, when we aborted because a "critical pass" failed, we
displayed the number of errors from that critical pass. While that's the
number of errors that caused compilation to abort in *that place*,
that's not what people really want to know. Instead, always report the
total number of errors, and don't bother to track the number of errors
from the last pass that failed.

This changes the compiler driver API to handle errors more smoothly,
and therefore is a compiler-api-[breaking-change].

Fixes #42793.
2017-07-02 16:16:44 +03:00
est31
57f0514feb Style fix 2017-07-02 13:53:29 +02:00
est31
1561954ea4 Documentation 2017-07-02 13:53:29 +02:00
est31
eb5fb21bd5 Fix the test failure, add comment, and refactor a little bit 2017-07-02 13:53:29 +02:00
est31
da887074fc Output line column info when panicking 2017-07-02 13:53:29 +02:00
Ariel Ben-Yehuda
77f4022303 Revert "Change error count messages"
This reverts commit 5558c64f33.
2017-07-02 13:49:30 +03:00
Stjepan Glavina
bfbe4039f8 Fix tidy errors 2017-07-02 11:16:37 +02:00
bors
c3a130cffc Auto merge of #43003 - milmazz:bootstrap-pep8, r=alexcrichton
bootstrap: Fix all the pep-8 issues reported by flake8

This commit also adds a few missing docstrings.

Today, after reading this [article](https://blog.rust-lang.org/2017/06/27/Increasing-Rusts-Reach.html), I downloaded this project and started building from source. In the meantime, I began to read the `bootstrap.py`, to know more about the building process, and I made a few changes, this is my first contribution to the project, hope you like it.

BTW, I have a few doubts about the `bootstrap.py`, any guidance is more than welcome:

* Where can I find the unit tests for this script? In case it doesn't exist yet, do you like to include some unit tests with pytest?
* Some methods like `fix_executable`, `get_string`, and `exe_suffix` in the `RustBuild` class should be converted to a function because it doesn't use `self` anywhere. What do you think?
2017-07-02 01:51:30 +00:00
Stjepan Glavina
5350e22366 Stabilize feature sort_unstable 2017-07-02 02:09:21 +02:00
bors
a19693a54c Auto merge of #43002 - SergioBenitez:more-io-inner-stable, r=BurntSushi
Stabilize 'more_io_inner_methods' feature.

As in the title. Closes #41519.
2017-07-01 21:54:13 +00:00
bors
05b5797664 Auto merge of #42882 - stjepang:improve-sort-tests-and-benches, r=alexcrichton
Improve tests and benchmarks for slice::sort and slice::sort_unstable

This PR just hardens the tests and improves benchmarks.
More specifically:

1. Benchmarks don't generate vectors in `Bencher::iter` loops, but simply clone pregenerated vectors.
2. Benchmark `*_strings` doesn't allocate Strings in `Bencher::iter` loops, but merely clones a `Vec<&str>`.
3. Benchmarks use seeded `XorShiftRng` to be more consistent.
4. Additional tests for `slice::sort` are added, which test sorting on slices with several ascending/descending runs. The implementation identifies such runs so it's a good idea to test that scenario a bit.
5. More checks are added to `run-pass/vector-sort-panic-safe.rs`. Sort algorithms copy elements around a lot (merge sort uses an auxilliary buffer and pdqsort copies the pivot onto the stack before partitioning, then writes it back into the slice). If elements that are being sorted are internally mutable and comparison function mutates them, it is important to make sure that sort algorithms always use the latest "versions" of elements. New checks verify that this is true for both `slice::sort` and `slice::sort_unstable`.

As a side note, all of those improvements were made as part of the parallel sorts PR in Rayon (nikomatsakis/rayon#379) and now I'm backporting them into libcore/libstd.

r? @alexcrichton
2017-07-01 13:31:32 +00:00
Milton Mazzarri
44c6781cef
Simplify print arguments 2017-07-01 07:16:57 -05:00
bors
a5d34e1d03 Auto merge of #42991 - sfackler:unstable-rangeargument, r=alexcrichton
Revert "Stabilize RangeArgument"

This reverts commit 143206d54d.

From the discussion in #30877 it seems like this is premature.
2017-07-01 11:21:53 +00:00
bors
7a2c09b6f5 Auto merge of #42977 - Keruspe:master, r=alexcrichton
rustbuild: set __CARGO_DEFAULT_LIB_METADATA to channel

Also, update the cargo submodule to handle the new value.
2017-07-01 09:10:13 +00:00
bors
d41b791c1a Auto merge of #42971 - stepancheg:ir-demangle, r=nagisa
When writing LLVM IR output demangled fn name in comments

`--emit=llvm-ir` looks like this now:

```
; <alloc::vec::Vec<T> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
; Function Attrs: inlinehint uwtable
define internal { i8*, i64 } @"_ZN106_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..index..IndexMut$LT$core..ops..range..RangeFull$GT$$GT$9index_mut17h7f7b576609f30262E"(%"alloc::vec::Vec<u8>"* dereferenceable(24)) unnamed_addr #0 {
start:
  ...
```

cc https://github.com/integer32llc/rust-playground/issues/15
2017-07-01 05:52:08 +00:00
Milton Mazzarri
ebf24ad3e9
bootstrap: Fix some PEP8 issues
This commit also adds a few missing docstrings
2017-06-30 23:24:35 -05:00
bors
4a92ae2524 Auto merge of #42896 - llogiq:clippy_compiletest, r=alexcrichton
fixed some clippy warnings in compiletest

This is mainly readability stuff. Whenever the `clone_ref` lint asked me to clone the dereferenced object, I removed the `.clone()` instead, relying on the fact that it has worked so far and the immutable borrow ensures that the value won't change.
2017-07-01 03:26:29 +00:00
Sergio Benitez
d280b40b18 Stabilize 'more_io_inner_methods' feature. 2017-06-30 18:05:04 -07:00
Stepan Koltsov
b62bdaafe0 When writing LLVM IR output demangled fn name in comments
`--emit=llvm-ir` looks like this now:

```
; <alloc::vec::Vec<T> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
; Function Attrs: inlinehint uwtable
define internal { i8*, i64 } @"_ZN106_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..index..IndexMut$LT$core..ops..range..RangeFull$GT$$GT$9index_mut17h7f7b576609f30262E"(%"alloc::vec::Vec<u8>"* dereferenceable(24)) unnamed_addr #0 {
start:
  ...
```

cc https://github.com/integer32llc/rust-playground/issues/15
2017-07-01 03:16:43 +03:00
bors
7d89b20669 Auto merge of #42995 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests

- Successful merges: #42669, #42911, #42925, #42957, #42985, #42987
- Failed merges: #42936
2017-06-30 22:14:56 +00:00
Guillaume Gomez
bda06de5dc Rollup merge of #42987 - cuviper:iterator_for_each, r=Mark-Simulacrum
Track `iterator_for_each` in #42986

None
2017-06-30 22:44:48 +02:00
Guillaume Gomez
953d679362 Rollup merge of #42985 - venkatagiri:issue_42444, r=Mark-Simulacrum
rustc_llvm: re-run build script when env var LLVM_CONFIG changes

This removes the changes done in #42429 and use the newly introduced `cargo:rerun-if-env-changed` in https://github.com/rust-lang/cargo/pull/4125.
As `LLVM_CONFIG` env var points to the `llvm-config` and changes when it gets configured in `config.toml` or removed from it, we can re-run the build script if this env var changes.

closes #42444

r? @alexcrichton
2017-06-30 22:44:47 +02:00
Guillaume Gomez
bbdb21efbf Rollup merge of #42957 - GuillaumeGomez:add-e0619, r=nikomatsakis
Add E0619 error explanation

r? @eddyb
2017-06-30 22:44:46 +02:00
Guillaume Gomez
db004d4f55 Rollup merge of #42925 - tbu-:pr_document_file_open_errors, r=GuillaumeGomez
Document possible `io::ErrorKind`s of `fs::open`

Try to make clear that this isn't an API guarantee for now, as we likely
want to refine these errors in the future, e.g. `ENOSPC` "No space left
on device".

CC #40322
2017-06-30 22:44:45 +02:00
Guillaume Gomez
ed04f56e9d Rollup merge of #42911 - nrc:rls-update, r=brson
Update RLS submodule
2017-06-30 22:44:44 +02:00
Guillaume Gomez
fc0fb0328b Rollup merge of #42669 - gaurikholkar:master, r=nikomatsakis
Adding diagnostic code 0611 for lifetime errors with one named, one anonymous lifetime parameter

This is a fix for #42517
Note that this only handles the above case for **function declarations** and **traits**.
`impl items` and `closures` will be handled in a later PR.
Example
```
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
    if x > y { x } else { y }
}
```
now displays the following error message. ui tests have been added for the same.
```
error[E0611]: explicit lifetime required in the type of `x`
11 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
   |                     ^ consider changing the type of `x` to `&'a i32`
12 |     if x > y { x } else { y }
   |                  - lifetime `'a` required
```
#42516
r? @nikomatsakis
2017-06-30 22:44:43 +02:00
Guillaume Gomez
162b5a3475 Fix error codes mixup 2017-06-30 22:43:35 +02:00
Guillaume Gomez
aa3fa25476 Add E0619 error explanation 2017-06-30 22:38:57 +02:00
bors
37849a002e Auto merge of #42969 - arielb1:struct-err, r=eddyb
mem_categorization: handle type-based paths in variant patterns

These can't be used in correct programs, but must be handled in order to
prevent ICEs.

Fixes #42880.

r? @eddyb
2017-06-30 19:51:19 +00:00
Steven Fackler
0a9c13624d Revert "Stabilize RangeArgument"
This reverts commit 143206d54d.
2017-06-30 08:34:53 -10:00
Venkata Giri Reddy
4f13da7362 rustc_{a,l,m,t}san: re-run build script if env var LLVM_CONFIG changes 2017-06-30 17:35:00 +00:00
Josh Stone
741dc2bad5 Track iterator_for_each in #42986 2017-06-30 10:21:46 -07:00
Venkata Giri Reddy
401614b75a rustc_llvm: re-run build script when env var LLVM_CONFIG changes 2017-06-30 16:55:32 +00:00
bors
e72580cf09 Auto merge of #42807 - arielb1:consistent-coercion, r=eddyb
Coerce fields to the expected field type

Fully fixes #31260.

This needs a crater run. I was supposed to do this last month but it slipped. Let's get this done.
2017-06-30 13:39:25 +00:00
gaurikholkar
37a88f478d rename compile-fail test 2017-06-30 02:33:33 -07:00
bors
919c4a6707 Auto merge of #42782 - cuviper:iterator_for_each, r=alexcrichton
Add `Iterator::for_each`

This works like a `for` loop in functional style, applying a closure to
every item in the `Iterator`.  It doesn't allow `break`/`continue` like
a `for` loop, nor any other control flow outside the closure, but it may
be a more legible style for tying up the end of a long iterator chain.

This was tried before in #14911, but nobody made the case for using it
with longer iterators.  There was also `Iterator::advance` at that time
which was more capable than `for_each`, but that no longer exists.

The `itertools` crate has `Itertools::foreach` with the same behavior,
but thankfully the names won't collide.  The `rayon` crate also has a
`ParallelIterator::for_each` where simple `for` loops aren't possible.

> I really wish we had `for_each` on seq iterators. Having to use a
> dummy operation is annoying.  - [@nikomatsakis][1]

[1]: https://github.com/nikomatsakis/rayon/pull/367#issuecomment-308455185
2017-06-30 09:15:21 +00:00
Niko Matsakis
a43377773f move ERROR line 2017-06-30 05:11:28 -04:00
Marc-Antoine Perennou
93528d9072 update cargo submodule
This brings in several fixes and the new handling of __CARGO_DEFAULT_LIB_METADATA

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2017-06-30 09:38:13 +02:00
Marc-Antoine Perennou
d23a62ba71 rustbuild: set __CARGO_DEFAULT_LIB_METADATA to channel
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2017-06-30 09:16:00 +02:00
bors
4c5b437176 Auto merge of #42930 - arielb1:llvm-next, r=alexcrichton
Rebase LLVM on top of LLVM 4.0.1

Fixes #42893.

Please don't backport this to beta as-is - I'm not sure I want rust-lang/llvm#84 to sneak to beta before it gets sufficient testing.

r? @alexcrichton
2017-06-30 06:17:52 +00:00
bors
a4c68c62f0 Auto merge of #42924 - pnkfelix:mir-dataflow, r=arielb1
Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate.

Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate.

Turn `elaborate_drops` and `rustc_peek` implementations into MIR passes that also live in `rustc_mir` crate.

Rewire things so `rustc_driver` uses the `ElaborateDrops` from `rustc_mir` crate.

(This PR is another baby step for mir-borrowck; it is a piece of work that other people want to rebase their stuff on top of, namely developers who are doing other dataflow analyses on top of MIR.)

I have deliberately architected this PR in an attempt to minimize the number of actual code changes. The majority of the diff should be little more than changes to mod and use declarations, as well as a few visibility promotions to pub(crate) when a declaration was moved downward in the module hierarchy.

(I have no problem with other PR's that move declarations around to try to clean this up; my goal was to ensure that the diff here was as small as possible, to make the review nearly trivial.)
2017-06-30 03:56:33 +00:00
Ian Douglas Scott
8ed83f4aaf
Fix Redox build, apparently broken by #42687 2017-06-29 18:18:32 -07:00