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.)
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!~~
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`.
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.
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
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.
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.
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).
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).
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.
Auto merge of #44786 - thombles:tk/i41314, r=petrochenkov
Improve diagnostics when attempting to match tuple enum variant with struct pattern
Adds an extra note as below to explain that a tuple pattern was probably intended.
```
error[E0026]: variant `X::Y` does not have a field named `data`
--> src/main.rs:18:16
|
18 | X::Y { data } => println!("The data is {}", data)
| ^^^^ variant `X::Y` does not have field `data`
error[E0027]: pattern does not mention field `0`
--> src/main.rs:18:9
|
18 | X::Y { data } => println!("The data is {}", data)
| ^^^^^^^^^^^^^ missing field `0`
|
= note: trying to match a tuple variant with a struct variant pattern
```
Auto merge of #44772 - michaelwoerister:new-graph, r=nikomatsakis
incr.comp.: Add new DepGraph implementation.
This commits does a few things:
1. It adds the new dep-graph implementation -- *in addition* to the old one. This way we can start testing the new implementation without switching all tests at once.
2. It persists the new dep-graph (which includes query result fingerprints) to the incr. comp. caching directory and also loads this data.
3. It removes support for loading fingerprints of metadata imported from other crates (except for when running autotests). This is not needed anymore with red/green. It could provide a performance advantage but that's yet to be determined. For now, as red/green is not fully implemented yet, the cross-crate incremental tests are disabled.
Note, this PR is based on top of soon-to-be-merged #44696 and only the last 4 commits are new:
```
- incr.comp.: Initial implemenation of append-only dep-graph. (c90147c)
- incr.comp.: Do some various cleanup. (8ce20c5)
- incr.comp.: Serialize and deserialize new DepGraph. (0e13c1a)
- incr.comp.: Remove support for loading metadata fingerprints. (270a134)
EDIT 2:
- incr.comp.: Make #[rustc_dirty/clean] test for fingerprint equality ... (d8f7ff9)
```
(EDIT: GH displays the commits in the wrong order for some reason)
Also note that this PR is expected to certainly result in performance regressions in the incr. comp. test cases, since we are adding quite a few things (a whole additional dep-graph, for example) without removing anything. End-to-end performance measurements will only make sense again after red/green is enabled and all the legacy tracking has been turned off.
EDIT 2: Pushed another commit that makes the `#[rustc_dirty]`/`#[rustc_clean]` based autotests compared query result fingerprints instead of testing `DepNode` existence.
Auto merge of #44633 - petrochenkov:priv2, r=nikomatsakis
Record semantic types for all syntactic types in bodies
... and use recorded types in type privacy checking (types are recorded after inference, so there are no `_`s left).
Also use `hir_ty_to_ty` for types in signatures in type privacy checking.
This could also be potentially useful for save-analysis and diagnostics.