Commit graph

70091 commits

Author SHA1 Message Date
bors
79a138594f Auto merge of #45989 - davidtwco:issue-45360, r=nikomatsakis
MIR-borrowck: emit "`foo` does not live long enough" instead of borrow errors

Fixes #45360. As of writing, contains deduplication of existing errors.

r? @nikomatsakis
2017-11-18 03:11:18 +00:00
bors
8752aeed3a Auto merge of #45899 - eddyb:meta-race, r=alexcrichton
rustc_trans: atomically write .rmeta outputs to avoid races.

Fixes #45841 in a similar vein to how LLVM writes archives: write a temporary file and then rename it.

r? @alexcrichton
2017-11-18 00:44:58 +00:00
Wesley Wiser
f726634198 [incremental] Collect stats about duplicated edge reads from queries
Part of #45873
2017-11-17 18:03:29 -05:00
Keith Yeung
f8ba371b1e Add run-pass test for assignment to static mut 2017-11-17 14:22:04 -08:00
Keith Yeung
c9d1db7bc5 Do not registor borrows for unsafe lvalues 2017-11-17 14:16:37 -08:00
bors
18d8acf41d Auto merge of #45853 - nikomatsakis:chalk-simplify-hr-lub-glb, r=arielb1
Simplify higher-ranked LUB/GLB

This is a better version of https://github.com/rust-lang/rust/pull/44211. It still makes higher-ranked LUB/GLB into a hard equality test, however, it does try to identify that something changed and issue a notice to the user. I wroteup https://github.com/rust-lang/rust/issues/45852 as a tracking issue for this change.

Currently, this moves straight to a hard-error, on the basis that the crater run in #44211 saw no impact. It might be good to retest -- or perhaps to try for a warning period. Trying to do the latter in a precise way would be somewhat painful, but an imprecise way might suffice -- that is, we could issue warning *whenever* a LUB/GLB operation succeeds that will later fail, even if it doesn't ultimately impact the type check. I could experiment with this.

~~I am *mildly* wary about landing this independently of other code that moves to a universe-based system. In particular, I was nervous that this change would make coherence accepts new pairs of impls that will later be errors. I have the code for the universe-based approach available, I hope to open an PR and run some tests on its impact very shortly.~~ @arielb1 points out that I was being silly.

r? @arielb1
2017-11-17 22:16:11 +00:00
Guillaume Gomez
d86621f69e Add trait methods as well 2017-11-17 22:50:15 +01:00
Guillaume Gomez
85dcf2ecb6 Improve modal display and add JS events 2017-11-17 22:50:15 +01:00
Guillaume Gomez
aca1bd7d7e First step for important traits UI 2017-11-17 22:50:15 +01:00
QuietMisdreavus
be68d34a7e update links and tracking issue for doc_spotlight 2017-11-17 22:50:15 +01:00
QuietMisdreavus
831fd78341 add doc_highlight feature flag and tests 2017-11-17 22:50:15 +01:00
QuietMisdreavus
cbe4ac3079 spotlight Iterator/Read/Write impls on function return types 2017-11-17 22:50:15 +01:00
Guillaume Gomez
955c054ab1 Fix primitive types not showing up 2017-11-17 22:33:02 +01:00
David Wood
a1d55be3e1
Fixed bug with the implementation that was suppressing expected errors from the same line in other tests. 2017-11-17 19:58:11 +00:00
Marc-Antoine Perennou
90e54f4340 update openssl{,-sys} to fix build with libressl 2.6.x
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2017-11-17 20:40:25 +01:00
Keith Yeung
3be597acf3 Allow assignment to static muts 2017-11-17 11:21:43 -08:00
Taylor Cramer
bc4810d907 Fix impl Trait Lifetime Handling
After this change, impl Trait existentials are
desugared to a new `abstract type` definition
paired with a set of lifetimes to apply.

In-scope generics are included as parents of the
`abstract type` generics. Parent regions are
replaced with static, and parent regions
referenced in the `impl Trait` type are duplicated
at the end of the `abstract type`'s generics.
2017-11-17 10:01:54 -08:00
Eduard-Mihai Burtescu
fab2532ef9 rustc_trans: move const & lvalue access helpers from adt. 2017-11-17 18:25:31 +02:00
David Wood
bf76ffe4e3
Corrected error output with many labels. 2017-11-17 16:20:34 +00:00
Niko Matsakis
9877fa048d use a BTreeMap instead of an FxHasMap for the skol regions
The ordering can affect error msg, and this map is not a high
performance pathway.
2017-11-17 10:32:53 -05:00
Niko Matsakis
ff8cd2e428 strip old lub-glb tests from librustc_driver
Good riddance.
2017-11-17 10:32:15 -05:00
Niko Matsakis
b224397b7c issue better error message when LUB/GLB diverge under new behavior 2017-11-17 10:32:15 -05:00
Niko Matsakis
397973b601 make LUB/GLB of higher-ranked things actually do EQ 2017-11-17 10:32:15 -05:00
bors
aabfed5e0c Auto merge of #45996 - eddyb:even-mirer-1, r=arielb1
MIR: hide .rodata constants vs by-ref ABI clash in trans.

Back in #45380, constants were copied into locals during MIR creation to ensure that arguments ' memory can be used by the callee, if the constant is placed in `.rodata` and the ABI passes it by-ref.

However, there are several drawbacks (see https://github.com/rust-lang/rust/pull/45380#discussion_r150447709), most importantly the complication of constant propagation (UB if a constant ends up in `Call` arguments) and inconveniencing analyses.

Instead, I've modified the `rustc_trans` implementation of calls to copy an `Operand::Constant` argument locally if it's not immediate, and added a test that segfaults without the copy.

cc @dotdash @arielb1
2017-11-17 13:30:24 +00:00
bors
02eed2e9a5 Auto merge of #46004 - michaelwoerister:cached-mir-wip-3, r=nikomatsakis
incr.comp.: Implement query result cache and use it to cache type checking tables.

This is a spike implementation of caching more than LLVM IR and object files when doing incremental compilation. At the moment, only the `typeck_tables_of` query is cached but MIR and borrow-check will follow shortly. The feature is activated by running with `-Zincremental-queries` in addition to `-Zincremental`, it is not yet active by default.

r? @nikomatsakis
2017-11-17 10:12:21 +00:00
bors
b32267f2c1 Auto merge of #45595 - scottmcm:iter-try-fold, r=dtolnay
Short-circuiting internal iteration with Iterator::try_fold & try_rfold

These are the core methods in terms of which the other methods (`fold`, `all`, `any`, `find`, `position`, `nth`, ...) can be implemented, allowing Iterator implementors to get the full goodness of internal iteration by only overriding one method (per direction).

Based off the `Try` trait, so works with both `Result` and `Option` (🎉 https://github.com/rust-lang/rust/pull/42526).  The `try_fold` rustdoc examples use `Option` and the `try_rfold` ones use `Result`.

AKA continuing in the vein of PRs https://github.com/rust-lang/rust/pull/44682 & https://github.com/rust-lang/rust/pull/44856 for more of `Iterator`.

New bench following the pattern from the latter of those:
```
test iter::bench_take_while_chain_ref_sum          ... bench:   1,130,843 ns/iter (+/- 25,110)
test iter::bench_take_while_chain_sum              ... bench:     362,530 ns/iter (+/- 391)
```

I also ran the benches without the `fold` & `rfold` overrides to test their new default impls, with basically no change.  I left them there, though, to take advantage of existing overrides and because `AlwaysOk` has some sub-optimality due to https://github.com/rust-lang/rust/issues/43278 (which 45225 should fix).

If you're wondering why there are three type parameters, see issue https://github.com/rust-lang/rust/issues/45462

Thanks for @bluss for the [original IRLO thread](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434) and the rfold PR and to @cuviper for adding so many folds, [encouraging me](https://github.com/rust-lang/rust/pull/45379#issuecomment-339424670) to make this PR, and finding a catastrophic bug in a pre-review.
2017-11-17 07:43:08 +00:00
bors
3bcb00dbc2 Auto merge of #45991 - gnzlbg:fix_i586, r=alexcrichton
fix linking error on i586

Try to fix this linking error on i586 in cross:

https://travis-ci.org/japaric/cross/builds/302095949#L8670

The problem is that `std` is built in Ubuntu 16.04 and `cross` uses a linker from 12.04.

Currently this fix solves the problem for `i686-musl`  making it "supercompatible", this PR applies the fix to `i586` as well.

The cross PR is here: https://github.com/japaric/cross/pull/157
2017-11-17 05:18:45 +00:00
bors
8fbb46c4a1 Auto merge of #45980 - Keruspe:master, r=alexcrichton
rustbuild: Install rustfmt as part of extended build

Now that we distribute it, this allows `./x.py install` to install it too
2017-11-17 02:34:08 +00:00
Dan Gohman
6b1a3bc80a Optimize read_to_end.
This patch makes `read_to_end` use Vec's memory-growth pattern rather
than using a custom pattern.

This has some interesting effects:

 - If memory is reserved up front, `read_to_end` can be faster, as it
   starts reading at the buffer size, rather than always starting at 32
   bytes. This speeds up file reading by 2x in one of my use cases.

 - It can reduce the number of syscalls when reading large files.
   Previously, `read_to_end` would settle into a sequence of 8192-byte
   reads. With this patch, the read size follows Vec's allocation
   pattern. For example, on a 16MiB file, it can do 21 read syscalls
   instead of 2057. In simple benchmarks of large files though, overall
   speed is still dominated by the actual I/O.

 - A downside is that Read implementations that don't implement
   `initializer()` may see increased memory zeroing overhead.

I benchmarked this on a variety of data sizes, with and without
preallocated buffers. Most benchmarks see no difference, but reading
a small/medium file with a pre-allocated buffer is faster.
2017-11-16 16:12:36 -08:00
David Wood
ce8967a7b3
Modified to output intended error. 2017-11-17 00:09:18 +00:00
David Wood
a98aff7a5d
Updated test to reflect expected Mir output. 2017-11-17 00:08:34 +00:00
David Wood
7db49b9612
Deduplicated borrow checking errors. 2017-11-16 23:37:28 +00:00
Eduard-Mihai Burtescu
6db68938ac MIR: hide .rodata constants vs by-ref ABI clash in trans. 2017-11-17 01:37:10 +02:00
bors
d59f66d9b8 Auto merge of #45897 - tromey:trait-object-debug, r=michaelwoerister
Trait object debug

This enables better debugging of trait objects.  See the individual commits for explanations.  This required an LLVM bump.
2017-11-16 23:28:00 +00:00
Taylor Cramer
31c7218af4 Update libc to include Fuchsia changes 2017-11-16 13:54:38 -08:00
bors
d0f8e2913a Auto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1
integrate MIR type-checker with NLL inference

This branch refactors NLL type inference so that it uses the MIR type-checker to gather constraints. Along the way, it also refactors how region constraints are gathered in the normal inference context mildly. The new setup is like this:

- What used to be `region_inference` is split into two parts:
    - `region_constraints`, which just collects up sets of constraints
    - `lexical_region_resolve`, which does the iterative, lexical region resolution
- When `resolve_regions_and_report_errors` is invoked, the inference engine converts the constraints into final values.
- In the MIR type checker, however, we do not invoke this method, but instead periodically take the region constraints and package them up for the NLL solver to use later.
    - This allows us to track when and where those constraints were incurred.
    - We also remove the central fulfillment context from the MIR type checker, instead instantiating new fulfillment contexts at each point. This allows us to capture the set of obligations that occurred at a particular point, and also to ensure that if the same obligation arises at two points, we will enforce the region constraints at both locations.
- The MIR type checker is also enhanced to instantiate late-bound-regions with fresh variables and handle a few other corner cases that arose.
- I also extracted some of the 'outlives' logic from the regionck, which will be needed later (see future work) to handle the type-outlives relationships.

One concern I have with this branch: since the MIR type checker is used even without the `-Znll` switch, I'm not sure if it will impact performance. One simple fix here would be to only enable the MIR type-checker if debug-assertions are enabled, since it just serves to validate the MIR. Longer term I hope to address this by improving the interface to the trait solver to be more query-based (ongoing work).

There is plenty of future work left. Here are two things that leap to mind:

- **Type-region outlives.** Currently, the NLL solver will ICE if it is required to handle a constraint like `T: 'a`. Fixing this will require a small amount of refactoring to extract the implied bounds code. I plan to follow a file-up bug on this (hopefully with mentoring instructions).
- **Testing.** It's a good idea to enumerate some of the tricky scenarios that need testing, but I think it'd be nice to try and parallelize some of the actual test writing (and resulting bug fixing):
    - Same obligation occurring at two points.
    - Well-formedness and trait obligations of various kinds (which are not all processed by the current MIR type-checker).
    - More tests for how subtyping and region inferencing interact.
    - More suggestions welcome!

r? @arielb1
2017-11-16 20:56:26 +00:00
Collin Anderson
261d4d8185 fix some python3 incompatibilities 2017-11-16 13:34:13 -05:00
bors
58d8761ab3 Auto merge of #46029 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests

- Successful merges: #45951, #45973, #45984, #45993, #46005, #46010
- Failed merges:
2017-11-16 18:24:17 +00:00
Michael Woerister
0a1f6dd8a8 Add doc comment for LocalDefId. 2017-11-16 18:09:04 +01:00
Michael Woerister
4c4f7a3189 Fix some tidy errors in ty::codec. 2017-11-16 17:42:39 +01:00
Michael Woerister
cb1ff24425 incr.comp.: Remove default serialization implementations for things in rustc::hir::def_id so that we get an ICE instead of silently doing the wrong thing. 2017-11-16 17:13:39 +01:00
Oliver Schneider
47c7e430d3
Remove left over dead code from suggestion diagnostic refactoring 2017-11-16 16:36:49 +01:00
bors
481b42b507 Auto merge of #45528 - alexcrichton:avx512, r=arielb1
rustc: Add some more compatibility with AVX-512

* Increase the maximum vector size in the ABI calculations to ensure that
  AVX-512 operands are immediates.
* Add a few more `target_feature` matchings for AVX-512 features
2017-11-16 15:32:13 +00:00
Michael Woerister
723028f308 incr.comp.: Remove some code duplication around TyDecoder by factoring things into a macro. 2017-11-16 15:26:00 +01:00
Michael Woerister
2f44ef282e incr.comp.: Encode DefIds as DefPathHashes instead of recomputing those during deserialization. 2017-11-16 14:09:44 +01:00
Michael Woerister
24e54ddefa Introduce LocalDefId which provides a type-level guarantee that the DefId is from the local crate. 2017-11-16 14:04:01 +01:00
bors
c81f201d48 Auto merge of #46028 - oli-obk:clippy, r=kennytm
Reenable Clippy

r? @kennytm
2017-11-16 10:59:39 +00:00
Niko Matsakis
8c109f5681 infer/outlives/obligations.rs: wrap some long lines 2017-11-16 05:58:16 -05:00
Niko Matsakis
9e29662a98 obligations.rs: rustfmt 2017-11-16 05:58:16 -05:00
Niko Matsakis
a94d2a6b88 Nit: fix typo 2017-11-16 05:58:13 -05:00