]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoAuto merge of #42526 - huntiep:try_opt, r=nikomatsakis
bors [Fri, 29 Sep 2017 20:09:35 +0000 (20:09 +0000)]
Auto merge of #42526 - huntiep:try_opt, r=nikomatsakis

Impl Try for Option

This is part of #31436.

6 years agoAuto merge of #44866 - mdevlamynck:impl-trait, r=eddyb
bors [Fri, 29 Sep 2017 15:54:44 +0000 (15:54 +0000)]
Auto merge of #44866 - mdevlamynck:impl-trait, r=eddyb

First step toward implementing impl Trait in argument position

First step implementing #44721.

Add a flag to hir and ty TypeParameterDef and raise an error when using
explicit type parameters when calling a function using impl Trait in
argument position.

I don't know if there is a procedure to add an error code so I just took an available code. Is that ok ?

r? @nikomatsakis

6 years agoAuto merge of #44856 - cuviper:more-fold, r=dtolnay
bors [Fri, 29 Sep 2017 12:56:24 +0000 (12:56 +0000)]
Auto merge of #44856 - cuviper:more-fold, r=dtolnay

Add more custom folding to `core::iter` adaptors

Many of the iterator adaptors will perform faster folds if they forward
to their inner iterator's folds, especially for inner types like `Chain`
which are optimized too.  The following types are newly specialized:

| Type        | `fold` | `rfold` |
| ----------- | ------ | ------- |
| `Enumerate` | ✓      | ✓       |
| `Filter`    | ✓      | ✓       |
| `FilterMap` | ✓      | ✓       |
| `FlatMap`   | exists | ✓       |
| `Fuse`      | ✓      | ✓       |
| `Inspect`   | ✓      | ✓       |
| `Peekable`  | ✓      | N/A¹    |
| `Skip`      | ✓      | N/A²    |
| `SkipWhile` | ✓      | N/A¹    |

¹ not a `DoubleEndedIterator`

² `Skip::next_back` doesn't pull skipped items at all, but this couldn't
be avoided if `Skip::rfold` were to call its inner iterator's `rfold`.

Benchmarks
----------

In the following results, plain `_sum` computes the sum of a million
integers -- note that `sum()` is implemented with `fold()`.  The
`_ref_sum` variants do the same on a `by_ref()` iterator, which is
limited to calling `next()` one by one, without specialized `fold`.

The `chain` variants perform the same tests on two iterators chained
together, to show a greater benefit of forwarding `fold` internally.

    test iter::bench_enumerate_chain_ref_sum  ... bench:   2,216,264 ns/iter (+/- 29,228)
    test iter::bench_enumerate_chain_sum      ... bench:     922,380 ns/iter (+/- 2,676)
    test iter::bench_enumerate_ref_sum        ... bench:     476,094 ns/iter (+/- 7,110)
    test iter::bench_enumerate_sum            ... bench:     476,438 ns/iter (+/- 3,334)

    test iter::bench_filter_chain_ref_sum     ... bench:   2,266,095 ns/iter (+/- 6,051)
    test iter::bench_filter_chain_sum         ... bench:     745,594 ns/iter (+/- 2,013)
    test iter::bench_filter_ref_sum           ... bench:     889,696 ns/iter (+/- 1,188)
    test iter::bench_filter_sum               ... bench:     667,325 ns/iter (+/- 1,894)

    test iter::bench_filter_map_chain_ref_sum ... bench:   2,259,195 ns/iter (+/- 353,440)
    test iter::bench_filter_map_chain_sum     ... bench:   1,223,280 ns/iter (+/- 1,972)
    test iter::bench_filter_map_ref_sum       ... bench:     611,607 ns/iter (+/- 2,507)
    test iter::bench_filter_map_sum           ... bench:     611,610 ns/iter (+/- 472)

    test iter::bench_fuse_chain_ref_sum       ... bench:   2,246,106 ns/iter (+/- 22,395)
    test iter::bench_fuse_chain_sum           ... bench:     634,887 ns/iter (+/- 1,341)
    test iter::bench_fuse_ref_sum             ... bench:     444,816 ns/iter (+/- 1,748)
    test iter::bench_fuse_sum                 ... bench:     316,954 ns/iter (+/- 2,616)

    test iter::bench_inspect_chain_ref_sum    ... bench:   2,245,431 ns/iter (+/- 21,371)
    test iter::bench_inspect_chain_sum        ... bench:     631,645 ns/iter (+/- 4,928)
    test iter::bench_inspect_ref_sum          ... bench:     317,437 ns/iter (+/- 702)
    test iter::bench_inspect_sum              ... bench:     315,942 ns/iter (+/- 4,320)

    test iter::bench_peekable_chain_ref_sum   ... bench:   2,243,585 ns/iter (+/- 12,186)
    test iter::bench_peekable_chain_sum       ... bench:     634,848 ns/iter (+/- 1,712)
    test iter::bench_peekable_ref_sum         ... bench:     444,808 ns/iter (+/- 480)
    test iter::bench_peekable_sum             ... bench:     317,133 ns/iter (+/- 3,309)

    test iter::bench_skip_chain_ref_sum       ... bench:   1,778,734 ns/iter (+/- 2,198)
    test iter::bench_skip_chain_sum           ... bench:     761,850 ns/iter (+/- 1,645)
    test iter::bench_skip_ref_sum             ... bench:     478,207 ns/iter (+/- 119,252)
    test iter::bench_skip_sum                 ... bench:     315,614 ns/iter (+/- 3,054)

    test iter::bench_skip_while_chain_ref_sum ... bench:   2,486,370 ns/iter (+/- 4,845)
    test iter::bench_skip_while_chain_sum     ... bench:     633,915 ns/iter (+/- 5,892)
    test iter::bench_skip_while_ref_sum       ... bench:     666,926 ns/iter (+/- 804)
    test iter::bench_skip_while_sum           ... bench:     444,405 ns/iter (+/- 571)

6 years agoAuto merge of #44853 - alexcrichton:debug-codegen-units, r=michaelwoerister
bors [Fri, 29 Sep 2017 10:10:15 +0000 (10:10 +0000)]
Auto merge of #44853 - alexcrichton:debug-codegen-units, r=michaelwoerister

rustc: Default 32 codegen units at O0

This commit changes the default of rustc to use 32 codegen units when compiling
in debug mode, typically an opt-level=0 compilation. Since their inception
codegen units have matured quite a bit, gaining features such as:

* Parallel translation and codegen enabling codegen units to get worked on even
  more quickly.
* Deterministic and reliable partitioning through the same infrastructure as
  incremental compilation.
* Global rate limiting through the `jobserver` crate to avoid overloading the
  system.

The largest benefit of codegen units has forever been faster compilation through
parallel processing of modules on the LLVM side of things, using all the cores
available on build machines that typically have many available. Some downsides
have been fixed through the features above, but the major downside remaining is
that using codegen units reduces opportunities for inlining and optimization.
This, however, doesn't matter much during debug builds!

In this commit the default number of codegen units for debug builds has been
raised from 1 to 32. This should enable most `cargo build` compiles that are
bottlenecked on translation and/or code generation to immediately see speedups
through parallelization on available cores.

Work is being done to *always* enable multiple codegen units (and therefore
parallel codegen) but it requires #44841 at least to be landed and stabilized,
but stay tuned if you're interested in that aspect!

6 years agoAuto merge of #44847 - estebank:unused-signature, r=nikomatsakis
bors [Fri, 29 Sep 2017 07:05:10 +0000 (07:05 +0000)]
Auto merge of #44847 - estebank:unused-signature, r=nikomatsakis

Point at signature on unused lint

```
warning: struct is never used: `Struct`
  --> $DIR/unused-warning-point-at-signature.rs:22:1
   |
22 | struct Struct {
   | ^^^^^^^^^^^^^
```

Fix #33961.

6 years agoAuto merge of #44811 - zilbuz:issue-44596/E0506, r=arielb1
bors [Fri, 29 Sep 2017 03:54:12 +0000 (03:54 +0000)]
Auto merge of #44811 - zilbuz:issue-44596/E0506, r=arielb1

MIR-borrowck: Adding notes to E0506

This PR adds notes to the MIR borrowck error E0506.

Part of #44596

6 years agoAuto merge of #44528 - tmnilsson:attr_proc_macro_cfg_process, r=jseyfried
bors [Thu, 28 Sep 2017 23:38:52 +0000 (23:38 +0000)]
Auto merge of #44528 - tmnilsson:attr_proc_macro_cfg_process, r=jseyfried

Apply attr proc macros before cfg processing

Fixes #39336.
r? @jseyfried

6 years agoAuto merge of #44278 - Binero:master, r=BurntSushi
bors [Thu, 28 Sep 2017 18:52:49 +0000 (18:52 +0000)]
Auto merge of #44278 - Binero:master, r=BurntSushi

Allow replacing HashMap entries

This is an obvious API hole. At the moment the only way to retrieve an entry from a `HashMap` is to get an entry to it, remove it, and then insert a new entry. This PR allows entries to be replaced.

6 years agoAuto merge of #44785 - alexcrichton:update-cargo, r=nikomatsakis
bors [Thu, 28 Sep 2017 16:19:58 +0000 (16:19 +0000)]
Auto merge of #44785 - alexcrichton:update-cargo, r=nikomatsakis

Update some minor dependencies

* run `cargo update`
* Update cargo submodule
* Update to the `cc` crate from `gcc`

6 years agoUpdate to the `cc` crate
Alex Crichton [Sat, 23 Sep 2017 04:34:27 +0000 (21:34 -0700)]
Update to the `cc` crate

This is the name the `gcc` crate has moved to

6 years agoAuto merge of #44806 - KiChjang:mir-err-notes-2, r=pnkfelix
bors [Thu, 28 Sep 2017 12:40:12 +0000 (12:40 +0000)]
Auto merge of #44806 - KiChjang:mir-err-notes-2, r=pnkfelix

Add span label to E0384 for MIR borrowck

Corresponds to `report_illegal_reassignment`.

Part of #44596.

6 years agoAuto merge of #44790 - clarcharr:zip_bytes, r=sfackler
bors [Thu, 28 Sep 2017 09:10:12 +0000 (09:10 +0000)]
Auto merge of #44790 - clarcharr:zip_bytes, r=sfackler

TrustedRandomAccess specialisation for Iterator::cloned when Item: Copy.

This should fix #44424. It also provides a potential fix for more iterators using `Iterator::cloned`.

6 years agoAuto merge of #44779 - tjkirch:master, r=alexcrichton
bors [Thu, 28 Sep 2017 03:28:20 +0000 (03:28 +0000)]
Auto merge of #44779 - tjkirch:master, r=alexcrichton

Add aarch64-unknown-linux-musl target

This adds support for the aarch64-unknown-linux-musl target in the build and CI systems.

This addresses half of issue #42520.

The new file `aarch64_unknown_linux_musl.rs` is a copy of `aarch64_unknown_linux_gnu.rs` with "gnu" replaced by "musl", and the added logic in `build-arm-musl.sh` is similarly a near-copy of the arches around it, so overall the changes were straightforward.

Testing:

```
$ sudo ./src/ci/docker/run.sh cross
...
Dist std stage2 (x86_64-unknown-linux-gnu -> aarch64-unknown-linux-musl)
Building stage2 test artifacts (x86_64-unknown-linux-gnu -> aarch64-unknown-linux-musl)
   Compiling getopts v0.2.14
   Compiling term v0.0.0 (file:///checkout/src/libterm)
   Compiling test v0.0.0 (file:///checkout/src/libtest)
    Finished release [optimized] target(s) in 16.91 secs
Copying stage2 test from stage2 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / aarch64-unknown-linux-musl)
...
Build completed successfully in 0:55:22
```

```
$ rustup toolchain link local obj/build/x86_64-unknown-linux-gnu/stage2
$ rustup default local
```

After setting the local toolchain as default, and adding this in ~/.cargo/config:

```
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
```

...then the toolchain was able to build a working ripgrep as a test:

```
$ readelf -a target/aarch64-unknown-linux-musl/debug/rg | grep -i interpreter
$ readelf -a target/aarch64-unknown-linux-musl/debug/rg | grep NEEDED
$ file target/aarch64-unknown-linux-musl/debug/rg
target/aarch64-unknown-linux-musl/debug/rg: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=be11036b0988fac5dccc9f6487eb780b05186582, not stripped
```

6 years agoUpdate some minor dependencies
Alex Crichton [Wed, 27 Sep 2017 22:37:02 +0000 (15:37 -0700)]
Update some minor dependencies

6 years agoUpdate the Cargo submodule
Alex Crichton [Wed, 27 Sep 2017 22:36:38 +0000 (15:36 -0700)]
Update the Cargo submodule

6 years agoUpdate the RLS again
Nick Cameron [Mon, 25 Sep 2017 04:13:29 +0000 (17:13 +1300)]
Update the RLS again

6 years agoAdd RLS and Rustfmt to the toolstate mechanism
Nick Cameron [Fri, 22 Sep 2017 02:41:22 +0000 (14:41 +1200)]
Add RLS and Rustfmt to the toolstate mechanism

6 years agoRename rls component to rls-preview on nightly
Nick Cameron [Fri, 22 Sep 2017 01:59:04 +0000 (13:59 +1200)]
Rename rls component to rls-preview on nightly

6 years agoUpdate RLS and Rustfmt
Nick Cameron [Fri, 22 Sep 2017 01:58:35 +0000 (13:58 +1200)]
Update RLS and Rustfmt

6 years agoAuto merge of #44782 - estebank:issue-36700, r=GuillaumeGomez
bors [Wed, 27 Sep 2017 22:00:11 +0000 (22:00 +0000)]
Auto merge of #44782 - estebank:issue-36700, r=GuillaumeGomez

Point at parameter type on E0301

On "the parameter type `T` may not live long enough" error, point to the
parameter type suggesting lifetime bindings:

```
error[E0310]: the parameter type `T` may not live long enough
  --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
   |
27 | struct Foo<T> {
   |            - help: consider adding an explicit lifetime bound `T: 'static`...
28 |     foo: &'static T
   |     ^^^^^^^^^^^^^^^
   |
note: ...so that the reference type `&'static T` does not outlive the data it points at
  --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
   |
28 |     foo: &'static T
   |     ^^^^^^^^^^^^^^^
```

Fix #36700.

6 years agoAdd UI tests
Hunter Praska [Fri, 22 Sep 2017 15:24:06 +0000 (10:24 -0500)]
Add UI tests

6 years agoRename option::Missing to NoneError
Hunter Praska [Sun, 18 Jun 2017 18:07:09 +0000 (13:07 -0500)]
Rename option::Missing to NoneError

6 years agoAdd docs for Missing, correct Option's Try test
Hunter Praska [Thu, 8 Jun 2017 19:02:04 +0000 (14:02 -0500)]
Add docs for Missing, correct Option's Try test

6 years agoAdd tests for Option and Result Try impl
Hunter Praska [Thu, 8 Jun 2017 03:52:13 +0000 (22:52 -0500)]
Add tests for Option and Result Try impl

6 years agoImpl Try for Option
Hunter Praska [Thu, 8 Jun 2017 03:51:45 +0000 (22:51 -0500)]
Impl Try for Option

6 years agoApply attr proc macros before cfg processing
Tomas Nilsson [Tue, 12 Sep 2017 19:55:41 +0000 (21:55 +0200)]
Apply attr proc macros before cfg processing

Now items are not fully configured until right before expanding derives.

6 years agoAuto merge of #44709 - Badel2:inclusive-range-dotdoteq, r=petrochenkov
bors [Wed, 27 Sep 2017 16:04:31 +0000 (16:04 +0000)]
Auto merge of #44709 - Badel2:inclusive-range-dotdoteq, r=petrochenkov

Initial support for `..=` syntax

#28237

This PR adds `..=` as a synonym for `...` in patterns and expressions.
Since `...` in expressions was never stable, we now issue a warning.

cc @durka
r? @aturon

6 years agoAuto merge of #44713 - zackmdavis:fn_main_in_a_comment_in_rustdoc_breaks_tests, r...
bors [Wed, 27 Sep 2017 10:56:23 +0000 (10:56 +0000)]
Auto merge of #44713 - zackmdavis:fn_main_in_a_comment_in_rustdoc_breaks_tests, r=QuietMisdreavus

don't let rustdoc get confused by text "fn main" in a line comment

~~~Resolves~~~ (edited) partially addresses #21299.

![rustdoc_fn_main](https://user-images.githubusercontent.com/1076988/30630993-9aeecc4a-9d97-11e7-8e56-2b973f23f683.png)

r? @QuietMisdreavus

6 years agoAuto merge of #44825 - dtolnay:cratelint, r=aturon
bors [Wed, 27 Sep 2017 08:20:11 +0000 (08:20 +0000)]
Auto merge of #44825 - dtolnay:cratelint, r=aturon

Allow unused extern crate again

This is a partial revert of #42588. There is a usability concern reported in #44294 that was not considered in the discussion of the PR, so I would like to back this out of 1.21. As is, I think users would have a worse and more confusing experience with this lint enabled by default. We can re-enabled once there are better diagnostics or the case in #44294 does not trigger the lint.

6 years agoAdd span label to E0384 for MIR borrowck
Keith Yeung [Sun, 24 Sep 2017 10:56:57 +0000 (03:56 -0700)]
Add span label to E0384 for MIR borrowck

6 years agoAuto merge of #44812 - Mark-Simulacrum:rustdoc-debug, r=alexcrichton
bors [Wed, 27 Sep 2017 04:57:34 +0000 (04:57 +0000)]
Auto merge of #44812 - Mark-Simulacrum:rustdoc-debug, r=alexcrichton

Allow rustdoc to get compiled with debuginfo

Fixes #44810

cc @QuietMisdreavus
r? @alexcrichton

6 years agoAuto merge of #44802 - sfackler:vecdeque-oob, r=Gankro
bors [Wed, 27 Sep 2017 01:23:24 +0000 (01:23 +0000)]
Auto merge of #44802 - sfackler:vecdeque-oob, r=Gankro

Fix capacity comparison in reserve

You can otherwise end up in a situation where you don't actually resize
but still call into handle_cap_increase which then corrupts head/tail.

Closes #44800

Not totally sure the right way to write a test for this - there are some debug asserts the old bad behavior will hit but we don't build the stdlib with debug assertions by default.

r? @Gankro

6 years agoAllow rustdoc to get compiled with debuginfo
Mark Simulacrum [Sun, 24 Sep 2017 14:50:27 +0000 (08:50 -0600)]
Allow rustdoc to get compiled with debuginfo

6 years agodon't let rustdoc get confused by text "fn main" in a line comment
Zack M. Davis [Wed, 20 Sep 2017 05:58:33 +0000 (22:58 -0700)]
don't let rustdoc get confused by text "fn main" in a line comment

This is in the matter of #21299.

6 years agoAuto merge of #44757 - jseyfried:fix_bad_derive_collection, r=nrc
bors [Tue, 26 Sep 2017 22:26:13 +0000 (22:26 +0000)]
Auto merge of #44757 - jseyfried:fix_bad_derive_collection, r=nrc

macros: fix bug in collecting trait and impl items with derives.

Fixes #43023.
r? @nrc

6 years agomir-borrowck: Edit compile-fail tests with E0506 error to also test on MIR borrowck
Basile Desloges [Tue, 26 Sep 2017 19:56:37 +0000 (21:56 +0200)]
mir-borrowck: Edit compile-fail tests with E0506 error to also test on MIR borrowck

6 years agobump rustfmt
Badel2 [Tue, 26 Sep 2017 18:35:27 +0000 (20:35 +0200)]
bump rustfmt

6 years agoUse a different error code to avoid conflicts
Matthias Devlamynck [Tue, 26 Sep 2017 18:51:22 +0000 (20:51 +0200)]
Use a different error code to avoid conflicts

6 years agoAuto merge of #44741 - qmx:trans_fulfill_obligation_should_not_crash, r=nikomatsakis
bors [Tue, 26 Sep 2017 18:29:57 +0000 (18:29 +0000)]
Auto merge of #44741 - qmx:trans_fulfill_obligation_should_not_crash, r=nikomatsakis

use param_env on the trait_cache key

We bailed from making trans_fulfill_obligation return `Option` or `Result`, just made it less prone to crashing outside trans

r? @nikomatsakis

6 years agomir-borrowck: Add span labels to `report_illegal_mutation_of_borrowed()`
Basile Desloges [Sun, 24 Sep 2017 13:37:41 +0000 (15:37 +0200)]
mir-borrowck: Add span labels to `report_illegal_mutation_of_borrowed()`

6 years agomir-borrowck: Add borrow data parameter to `report_illegal_mutation_of_borrowed()`
Basile Desloges [Sun, 24 Sep 2017 13:25:49 +0000 (15:25 +0200)]
mir-borrowck: Add borrow data parameter to `report_illegal_mutation_of_borrowed()`

6 years agoimpl Trait in argument position desugaring:
Matthias Devlamynck [Tue, 26 Sep 2017 09:43:33 +0000 (11:43 +0200)]
impl Trait in argument position desugaring:

Add a flag to hir and ty TypeParameterDef and raise an error when using
explicit type parameters when calling a function using impl Trait in
argument position.

6 years agorustc: Default 32 codegen units at O0
Alex Crichton [Mon, 25 Sep 2017 19:26:25 +0000 (12:26 -0700)]
rustc: Default 32 codegen units at O0

This commit changes the default of rustc to use 32 codegen units when compiling
in debug mode, typically an opt-level=0 compilation. Since their inception
codegen units have matured quite a bit, gaining features such as:

* Parallel translation and codegen enabling codegen units to get worked on even
  more quickly.
* Deterministic and reliable partitioning through the same infrastructure as
  incremental compilation.
* Global rate limiting through the `jobserver` crate to avoid overloading the
  system.

The largest benefit of codegen units has forever been faster compilation through
parallel processing of modules on the LLVM side of things, using all the cores
available on build machines that typically have many available. Some downsides
have been fixed through the features above, but the major downside remaining is
that using codegen units reduces opportunities for inlining and optimization.
This, however, doesn't matter much during debug builds!

In this commit the default number of codegen units for debug builds has been
raised from 1 to 32. This should enable most `cargo build` compiles that are
bottlenecked on translation and/or code generation to immediately see speedups
through parallelization on available cores.

Work is being done to *always* enable multiple codegen units (and therefore
parallel codegen) but it requires #44841 at least to be landed and stabilized,
but stay tuned if you're interested in that aspect!

6 years agoAuto merge of #44736 - pnkfelix:mir-borrowck4, r=arielb1
bors [Tue, 26 Sep 2017 09:19:03 +0000 (09:19 +0000)]
Auto merge of #44736 - pnkfelix:mir-borrowck4, r=arielb1

Some fixes to mir-borrowck

Make the code more closely match the NLL RFC (updated description).

(The biggest visible fix the addition of the Shallow/Deep distinction, which means mir-borrowck stops falsely thinking that StorageDeads need deep access to their input L-value.)

6 years agoAuto merge of #44735 - tirr-c:issue-42143, r=arielb1
bors [Tue, 26 Sep 2017 05:02:03 +0000 (05:02 +0000)]
Auto merge of #44735 - tirr-c:issue-42143, r=arielb1

Friendlier error message for closure argument type mismatch

Rebased #42270.
Fixes #42143.

---

`test.rs`:

```rust
fn main() {
    foo(|_: i32, _: usize| ());
}

fn foo<F>(_: F) where F: Fn(&str, usize) {}
```

Before:

```
error[E0281]: type mismatch: `[closure@test.rs:2:9: 2:30]` implements the trait `std::ops::Fn<(i32, usize)>`, but the trait `for<'r> std::ops::Fn<(&'r str, usize)>` is required
 --> test.rs:2:5
  |
2 |     foo(|_: i32, _: usize| ());
  |     ^^^ --------------------- implements `std::ops::Fn<(i32, usize)>`
  |     |
  |     expected &str, found i32
  |     requires `for<'r> std::ops::Fn<(&'r str, usize)>`
  |
  = note: required by `foo`
```

After (early):

```
error[E0631]: type mismatch in closure arguments
 --> test.rs:2:5
  |
2 |     foo(|_: i32, _: usize| ());
  |     ^^^ --------------------- takes arguments of type `i32` and `usize`
  |     |
  |     expected arguments of type `&str` and `usize`
  |
  = note: required by `foo`
```

After (current):

```
error[E0631]: type mismatch in closure arguments
 --> test.rs:2:5
  |
2 |     foo(|_: i32, _: usize| ());
  |     ^^^ --------------------- found signature of `fn(i32, usize) -> _`
  |     |
  |     expected signature of `for<'r> fn(&'r str, usize) -> _`
  |
  = note: required by `foo`
```

~~Compiler output has been changed, and a few tests are failing. Help me writing/fixing tests!~~

r? @nikomatsakis

6 years agoAdd more custom folding to `core::iter` adaptors
Josh Stone [Tue, 26 Sep 2017 03:53:08 +0000 (20:53 -0700)]
Add more custom folding to `core::iter` adaptors

Many of the iterator adaptors will perform faster folds if they forward
to their inner iterator's folds, especially for inner types like `Chain`
which are optimized too.  The following types are newly specialized:

| Type        | `fold` | `rfold` |
| ----------- | ------ | ------- |
| `Enumerate` | ✓      | ✓       |
| `Filter`    | ✓      | ✓       |
| `FilterMap` | ✓      | ✓       |
| `FlatMap`   | exists | ✓       |
| `Fuse`      | ✓      | ✓       |
| `Inspect`   | ✓      | ✓       |
| `Peekable`  | ✓      | N/A¹    |
| `Skip`      | ✓      | N/A²    |
| `SkipWhile` | ✓      | N/A¹    |

¹ not a `DoubleEndedIterator`

² `Skip::next_back` doesn't pull skipped items at all, but this couldn't
be avoided if `Skip::rfold` were to call its inner iterator's `rfold`.

Benchmarks
----------

In the following results, plain `_sum` computes the sum of a million
integers -- note that `sum()` is implemented with `fold()`.  The
`_ref_sum` variants do the same on a `by_ref()` iterator, which is
limited to calling `next()` one by one, without specialized `fold`.

The `chain` variants perform the same tests on two iterators chained
together, to show a greater benefit of forwarding `fold` internally.

    test iter::bench_enumerate_chain_ref_sum  ... bench:   2,216,264 ns/iter (+/- 29,228)
    test iter::bench_enumerate_chain_sum      ... bench:     922,380 ns/iter (+/- 2,676)
    test iter::bench_enumerate_ref_sum        ... bench:     476,094 ns/iter (+/- 7,110)
    test iter::bench_enumerate_sum            ... bench:     476,438 ns/iter (+/- 3,334)

    test iter::bench_filter_chain_ref_sum     ... bench:   2,266,095 ns/iter (+/- 6,051)
    test iter::bench_filter_chain_sum         ... bench:     745,594 ns/iter (+/- 2,013)
    test iter::bench_filter_ref_sum           ... bench:     889,696 ns/iter (+/- 1,188)
    test iter::bench_filter_sum               ... bench:     667,325 ns/iter (+/- 1,894)

    test iter::bench_filter_map_chain_ref_sum ... bench:   2,259,195 ns/iter (+/- 353,440)
    test iter::bench_filter_map_chain_sum     ... bench:   1,223,280 ns/iter (+/- 1,972)
    test iter::bench_filter_map_ref_sum       ... bench:     611,607 ns/iter (+/- 2,507)
    test iter::bench_filter_map_sum           ... bench:     611,610 ns/iter (+/- 472)

    test iter::bench_fuse_chain_ref_sum       ... bench:   2,246,106 ns/iter (+/- 22,395)
    test iter::bench_fuse_chain_sum           ... bench:     634,887 ns/iter (+/- 1,341)
    test iter::bench_fuse_ref_sum             ... bench:     444,816 ns/iter (+/- 1,748)
    test iter::bench_fuse_sum                 ... bench:     316,954 ns/iter (+/- 2,616)

    test iter::bench_inspect_chain_ref_sum    ... bench:   2,245,431 ns/iter (+/- 21,371)
    test iter::bench_inspect_chain_sum        ... bench:     631,645 ns/iter (+/- 4,928)
    test iter::bench_inspect_ref_sum          ... bench:     317,437 ns/iter (+/- 702)
    test iter::bench_inspect_sum              ... bench:     315,942 ns/iter (+/- 4,320)

    test iter::bench_peekable_chain_ref_sum   ... bench:   2,243,585 ns/iter (+/- 12,186)
    test iter::bench_peekable_chain_sum       ... bench:     634,848 ns/iter (+/- 1,712)
    test iter::bench_peekable_ref_sum         ... bench:     444,808 ns/iter (+/- 480)
    test iter::bench_peekable_sum             ... bench:     317,133 ns/iter (+/- 3,309)

    test iter::bench_skip_chain_ref_sum       ... bench:   1,778,734 ns/iter (+/- 2,198)
    test iter::bench_skip_chain_sum           ... bench:     761,850 ns/iter (+/- 1,645)
    test iter::bench_skip_ref_sum             ... bench:     478,207 ns/iter (+/- 119,252)
    test iter::bench_skip_sum                 ... bench:     315,614 ns/iter (+/- 3,054)

    test iter::bench_skip_while_chain_ref_sum ... bench:   2,486,370 ns/iter (+/- 4,845)
    test iter::bench_skip_while_chain_sum     ... bench:     633,915 ns/iter (+/- 5,892)
    test iter::bench_skip_while_ref_sum       ... bench:     666,926 ns/iter (+/- 804)
    test iter::bench_skip_while_sum           ... bench:     444,405 ns/iter (+/- 571)

6 years agoFix bug in collecting trait and impl items with derives.
Jeffrey Seyfried [Thu, 21 Sep 2017 07:20:56 +0000 (00:20 -0700)]
Fix bug in collecting trait and impl items with derives.

6 years agoAuto merge of #44297 - laumann:suggest-misspelt-methods, r=arielb1
bors [Mon, 25 Sep 2017 23:09:06 +0000 (23:09 +0000)]
Auto merge of #44297 - laumann:suggest-misspelt-methods, r=arielb1

Add suggestions for misspelled method names

Use the syntax::util::lev_distance module to provide suggestions when a
named method cannot be found.

Part of #30197

6 years agoAuto merge of #44279 - smaeul:crt_static-deps, r=alexcrichton
bors [Mon, 25 Sep 2017 20:37:02 +0000 (20:37 +0000)]
Auto merge of #44279 - smaeul:crt_static-deps, r=alexcrichton

Require rlibs for dependent crates when linking static executables

This handles the case for `CrateTypeExecutable` and `+crt_static`. I reworked the match block to avoid duplicating the `attempt_static` and error checking code again (this case would have been a copy of the `CrateTypeCdylib`/`CrateTypeStaticlib` case).

On `linux-musl` targets where `std` was built with `crt_static = false` in `config.toml`, this change brings the test suite from entirely failing to mostly passing.

This change should not affect behavior for other crate types, or for targets which do not respect `+crt_static`.

6 years agoPoint at signature on unused lint
Esteban Küber [Mon, 25 Sep 2017 19:01:55 +0000 (12:01 -0700)]
Point at signature on unused lint

6 years agoAuto merge of #44085 - bjorn3:no_llvm_write_metadata, r=arielb1
bors [Mon, 25 Sep 2017 18:05:22 +0000 (18:05 +0000)]
Auto merge of #44085 - bjorn3:no_llvm_write_metadata, r=arielb1

Allow writing metadata without llvm

# Todo:

* [x] Rebase
* [x] Fix eventual errors
* [x] <strike>Find some crate to write elf files</strike> (will do it later)

Cc #43842

6 years agothose changes break miri, PR will be issued later
Douglas Campos [Mon, 25 Sep 2017 13:49:32 +0000 (09:49 -0400)]
those changes break miri, PR will be issued later

6 years agofix tidy errors
Douglas Campos [Thu, 21 Sep 2017 15:53:37 +0000 (11:53 -0400)]
fix tidy errors

6 years agoadd comment per @nikomatsakis request
Douglas Campos [Thu, 21 Sep 2017 15:19:52 +0000 (11:19 -0400)]
add comment per @nikomatsakis request

6 years agoexpose ParamEnv as a param
Douglas Campos [Thu, 21 Sep 2017 02:51:35 +0000 (22:51 -0400)]
expose ParamEnv as a param

6 years agoadd ParamEnv to the trait_cache key
Douglas Campos [Wed, 20 Sep 2017 02:39:00 +0000 (22:39 -0400)]
add ParamEnv to the trait_cache key

6 years agoAuto merge of #44809 - arielb1:small-scope, r=eddyb
bors [Mon, 25 Sep 2017 12:52:02 +0000 (12:52 +0000)]
Auto merge of #44809 - arielb1:small-scope, r=eddyb

encode region::Scope using fewer bytes

Now that region::Scope is no longer interned, its size is more important. This PR encodes region::Scope in 8 bytes instead of 12, which should speed up region inference somewhat (perf testing needed) and should improve the margins on #36799 by 64MB (that's not a lot, I did this PR mostly to speed up region inference).

This is a perf-sensitive PR. Please don't roll me up.

r? @eddyb

This is based on  #44743 so I could get more accurate measurements on #36799.

6 years agoRemove now dead code.
Felix S. Klock II [Fri, 22 Sep 2017 13:37:43 +0000 (15:37 +0200)]
Remove now dead code.

6 years agoMake mir-borrowck more closely match (draft) NLL RFC.
Felix S. Klock II [Mon, 21 Aug 2017 10:48:33 +0000 (12:48 +0200)]
Make mir-borrowck more closely match (draft) NLL RFC.

In particular:

 * introduce the shallow/deep distinction for read/write accesses

 * use the notions of prefixes, shallow prefixes, and supporting prefixes
   rather than trying to recreate the restricted sets from ast-borrowck.

 * Add shallow reads of Discriminant and ArrayLength, and treat them
   as artificial fields when doing prefix traversals.

6 years agoMore fine-grained delineation for mir-borrowck errors.
Felix S. Klock II [Tue, 22 Aug 2017 09:23:17 +0000 (11:23 +0200)]
More fine-grained delineation for mir-borrowck errors.

6 years agofix Debug impls
Ariel Ben-Yehuda [Mon, 25 Sep 2017 10:47:19 +0000 (13:47 +0300)]
fix Debug impls

6 years agoAuto merge of #44646 - petrochenkov:scompress, r=michaelwoerister
bors [Mon, 25 Sep 2017 09:01:53 +0000 (09:01 +0000)]
Auto merge of #44646 - petrochenkov:scompress, r=michaelwoerister

Compress most of spans to 32 bits

As described in https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28

Closes https://github.com/rust-lang/rust/issues/15594
r? @michaelwoerister

6 years agoAllow unused extern crate again
David Tolnay [Mon, 25 Sep 2017 06:57:42 +0000 (23:57 -0700)]
Allow unused extern crate again

This is a partial revert of #42588. There is a usability concern
reported in #44294 that was not considered in the discussion of the PR,
so I would like to back this out of 1.21. As is, I think users would
have a worse and more confusing experience with this lint enabled by
default. We can re-enabled once there are better diagnostics or the case
in #44294 does not trigger the lint.

6 years agoFix error
bjorn3 [Mon, 25 Sep 2017 06:17:37 +0000 (08:17 +0200)]
Fix error

6 years agoAuto merge of #44612 - pylaligand:magenta-to-zircon, r=alexcrichton
bors [Mon, 25 Sep 2017 05:05:14 +0000 (05:05 +0000)]
Auto merge of #44612 - pylaligand:magenta-to-zircon, r=alexcrichton

The Magenta kernel is now called Zircon.

6 years agoFix fuchsia toolchain prebuild setup
James Tucker [Mon, 25 Sep 2017 04:32:27 +0000 (21:32 -0700)]
Fix fuchsia toolchain prebuild setup

 * Adjust bootstrap to provide useful output on failure
 * Add missing package dependencies in the build environment
 * Fix permission bits on prebuilt toolchain files

6 years agoAuto merge of #44700 - arielb1:mir-effectck, r=nikomatsakis
bors [Mon, 25 Sep 2017 00:52:15 +0000 (00:52 +0000)]
Auto merge of #44700 - arielb1:mir-effectck, r=nikomatsakis

Move effect-checking to MIR

This allows emitting lints from MIR and moves the effect-checking pass to work on it.

I'll make `repr(packed)` misuse unsafe in a separate PR.

r? @eddyb

6 years agoLP_CLONE_FDIO_ROOT is now LP_CLONE_FDIO_NAMESPACE
James Tucker [Sun, 24 Sep 2017 21:31:50 +0000 (14:31 -0700)]
LP_CLONE_FDIO_ROOT is now LP_CLONE_FDIO_NAMESPACE

6 years agoensure that prebuilt toolchain binaries are +x
James Tucker [Fri, 22 Sep 2017 18:20:48 +0000 (11:20 -0700)]
ensure that prebuilt toolchain binaries are +x

6 years agoRe-add CMake package
Petr Hosek [Thu, 21 Sep 2017 23:26:10 +0000 (16:26 -0700)]
Re-add CMake package

This appears to be needed by the Rust build.

6 years agoUse Zircon's Clang rather than building our own
Petr Hosek [Thu, 21 Sep 2017 22:36:05 +0000 (15:36 -0700)]
Use Zircon's Clang rather than building our own

This toolchain is already used to build Zircon itself and is the
official Clang toolchain used by all Fuchsia developers.

6 years agobump liblibc to 0.2.31
James Tucker [Wed, 20 Sep 2017 18:56:38 +0000 (11:56 -0700)]
bump liblibc to 0.2.31

6 years agoDownload clang-tools-extra as well
Petr Hosek [Tue, 19 Sep 2017 19:05:01 +0000 (12:05 -0700)]
Download clang-tools-extra as well

6 years agoInstall unzip into Fuchsia Docker container
Petr Hosek [Tue, 19 Sep 2017 16:55:16 +0000 (09:55 -0700)]
Install unzip into Fuchsia Docker container

6 years agoTODO --> FIXME
P.Y. Laligand [Mon, 18 Sep 2017 22:54:48 +0000 (15:54 -0700)]
TODO --> FIXME

6 years agoUpdate submodules.
P.Y. Laligand [Mon, 18 Sep 2017 22:45:28 +0000 (15:45 -0700)]
Update submodules.

6 years agoUpdate Fuchsia toolchain build
Petr Hosek [Mon, 18 Sep 2017 03:02:14 +0000 (20:02 -0700)]
Update Fuchsia toolchain build

compiler-rt is now being built as part of the toolchain itself.

6 years agoUpdated Zircon version.
P.Y. Laligand [Fri, 15 Sep 2017 23:46:51 +0000 (16:46 -0700)]
Updated Zircon version.

6 years agoFixed casing issues.
P.Y. Laligand [Fri, 15 Sep 2017 21:11:04 +0000 (14:11 -0700)]
Fixed casing issues.

6 years agoTesting on Travis.
P.Y. Laligand [Fri, 15 Sep 2017 21:04:08 +0000 (14:04 -0700)]
Testing on Travis.

6 years agoThe Magenta kernel is now called Zircon.
P.Y. Laligand [Fri, 15 Sep 2017 19:38:08 +0000 (12:38 -0700)]
The Magenta kernel is now called Zircon.

6 years agoAuto merge of #44758 - arielb1:a-small-path, r=eddyb
bors [Sun, 24 Sep 2017 19:48:11 +0000 (19:48 +0000)]
Auto merge of #44758 - arielb1:a-small-path, r=eddyb

put empty generic lists behind a pointer

This reduces the size of hir::Expr from 128 to 88 bytes (!) and shaves
200MB out of #36799.

This is a performance-sensitive PR so please don't roll it up.

r? @eddyb

6 years agoPoint at parameter type on E0301
Esteban Küber [Sat, 23 Sep 2017 02:13:19 +0000 (19:13 -0700)]
Point at parameter type on E0301

On "the parameter type `T` may not live long enough" error, point to the
parameter type suggesting lifetime bindings:

```
error[E0310]: the parameter type `T` may not live long enough
  --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
   |
27 | struct Foo<T> {
   |            - help: consider adding an explicit lifetime bound `T: 'static`...
28 |     foo: &'static T
   |     ^^^^^^^^^^^^^^^
   |
note: ...so that the reference type `&'static T` does not outlive the data it points at
  --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5
   |
28 |     foo: &'static T
   |     ^^^^^^^^^^^^^^^
```

6 years agoChange Levensthein-based method to a single suggestion
Thomas Jespersen [Thu, 21 Sep 2017 11:04:11 +0000 (13:04 +0200)]
Change Levensthein-based method to a single suggestion

The convention for suggesting close matches is to provide at most one match (the
closest one). Change the suggestions for misspelt method names to obey that.

6 years agoAdd a run-pass-valgrind test for vecdeque issue
Steven Fackler [Sun, 24 Sep 2017 17:56:08 +0000 (10:56 -0700)]
Add a run-pass-valgrind test for vecdeque issue

6 years agoAuto merge of #44743 - arielb1:size-rollback, r=eddyb
bors [Sun, 24 Sep 2017 15:41:13 +0000 (15:41 +0000)]
Auto merge of #44743 - arielb1:size-rollback, r=eddyb

typeck::check::coercion - roll back failed unsizing type vars

This wraps unsizing coercions within an additional level of
`commit_if_ok`, which rolls back type variables if the unsizing coercion
fails. This prevents a large amount of type-variables from accumulating
while type-checking a large function, e.g. shaving 2GB off one of the
4GB peaks in #36799.

This is a performance-sensitive PR so please don't roll it up.

r? @eddyb
cc @nikomatsakis

6 years agoencode region::Scope using fewer bytes
Ariel Ben-Yehuda [Sun, 24 Sep 2017 14:20:37 +0000 (17:20 +0300)]
encode region::Scope using fewer bytes

Now that region::Scope is no longer interned, its size is more
important. This PR encodes region::Scope in 8 bytes instead of 12, which
should speed up region inference somewhat (perf testing needed) and
should improve the margins on #36799 by 64MB (that's not a lot, I did
this PR mostly to speed up region inference).

6 years agomove Scope behind an enum
Ariel Ben-Yehuda [Sun, 24 Sep 2017 13:13:54 +0000 (16:13 +0300)]
move Scope behind an enum

6 years agoAuto merge of #44807 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Sun, 24 Sep 2017 12:20:21 +0000 (12:20 +0000)]
Auto merge of #44807 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 4 pull requests

- Successful merges: #44103, #44625, #44789, #44795
- Failed merges:

6 years agoRollup merge of #44795 - KiChjang:mir-err-notes, r=arielb1
Guillaume Gomez [Sun, 24 Sep 2017 12:01:52 +0000 (14:01 +0200)]
Rollup merge of #44795 - KiChjang:mir-err-notes, r=arielb1

MIR borrowck: Add span labels for E0381 and E0505

Corresponds to `report_use_of_moved` and `report_move_out_when_borrowed`.

Part of #44596.

6 years agoRollup merge of #44789 - GuillaumeGomez:fix-rustdoc-display, r=QuietMisdreavus
Guillaume Gomez [Sun, 24 Sep 2017 12:01:51 +0000 (14:01 +0200)]
Rollup merge of #44789 - GuillaumeGomez:fix-rustdoc-display, r=QuietMisdreavus

Fix warning position in rustdoc code blocks

Before:

<img width="1440" alt="screen shot 2017-09-23 at 14 07 08" src="https://user-images.githubusercontent.com/3050060/30773382-b9649288-a06f-11e7-94ec-faa3c3ed999b.png">

After:

<img width="1440" alt="screen shot 2017-09-23 at 14 58 31" src="https://user-images.githubusercontent.com/3050060/30773384-bdfc9f3e-a06f-11e7-9030-9fb8a5308668.png">

r? @QuietMisdreavus

6 years agoRollup merge of #44625 - frewsxcv:frewsxcv-raii-stdin, r=QuietMisdreavus
Guillaume Gomez [Sun, 24 Sep 2017 12:01:50 +0000 (14:01 +0200)]
Rollup merge of #44625 - frewsxcv:frewsxcv-raii-stdin, r=QuietMisdreavus

Indicate how ChildStd{in,out,err} FDs are closed.

Fixes https://github.com/rust-lang/rust/issues/41452.

6 years agoRollup merge of #44103 - zackmdavis:cmp_op_must_use, r=arielb1
Guillaume Gomez [Sun, 24 Sep 2017 12:01:49 +0000 (14:01 +0200)]
Rollup merge of #44103 - zackmdavis:cmp_op_must_use, r=arielb1

add comparison operators to must-use lint (under `fn_must_use` feature)

Although RFC 1940 is about annotating functions with `#[must_use]`, a
key part of the motivation was linting unused equality operators.

(See
https://github.com/rust-lang/rfcs/pull/1812#issuecomment-265695898—it
seems to have not been clear to discussants at the time that marking the
comparison methods as `must_use` would not give us the lints on
comparison operators, at least in (what the present author understood
as) the most straightforward implementation, as landed in #43728
(3645b062).)

To rectify the situation, we here lint unused comparison operators as
part of the unused-must-use lint (feature gated by the `fn_must_use`
feature flag, which now arguably becomes a slight (tolerable in the
opinion of the present author) misnomer).

This is in the matter of #43302.

cc @crumblingstatue

6 years agosort the list of inference errors by span
Ariel Ben-Yehuda [Sun, 24 Sep 2017 10:45:19 +0000 (13:45 +0300)]
sort the list of inference errors by span

this should produce more error stability

6 years agofix test
Ariel Ben-Yehuda [Sun, 24 Sep 2017 10:15:18 +0000 (13:15 +0300)]
fix test

6 years agoremove test code accidentally checked in
Ariel Ben-Yehuda [Wed, 20 Sep 2017 21:29:32 +0000 (00:29 +0300)]
remove test code accidentally checked in

6 years agoaddress review comments
Ariel Ben-Yehuda [Wed, 20 Sep 2017 13:34:31 +0000 (16:34 +0300)]
address review comments

6 years agomove unsafety checking to MIR
Ariel Ben-Yehuda [Tue, 19 Sep 2017 13:20:02 +0000 (16:20 +0300)]
move unsafety checking to MIR

No functional changes intended.

6 years agoadd lint levels to VisibilityScope
Ariel Ben-Yehuda [Wed, 13 Sep 2017 19:33:07 +0000 (22:33 +0300)]
add lint levels to VisibilityScope

6 years agotypeck::check::coercion - roll back failed unsizing type vars
Ariel Ben-Yehuda [Thu, 21 Sep 2017 14:54:39 +0000 (17:54 +0300)]
typeck::check::coercion - roll back failed unsizing type vars

This wraps unsizing coercions within an additional level of
`commit_if_ok`, which rolls back type variables if the unsizing coercion
fails. This prevents a large amount of type-variables from accumulating
while type-checking a large function, e.g. shaving 2GB off one of the
4GB peaks in #36799.