Commit Graph

94909 Commits

Author SHA1 Message Date
Niko Matsakis
59f5045a16 add more debug logs 2019-06-12 13:56:29 -04:00
Niko Matsakis
6fdcc8281a remove hacks that are no longer needed 2019-06-12 13:56:29 -04:00
Niko Matsakis
9639d8ec34 add the "provisional cache" 2019-06-12 13:56:29 -04:00
Niko Matsakis
a1a8a7b986 add in a depth-first number for stack entries 2019-06-12 13:56:28 -04:00
Niko Matsakis
c86f948714 introduce ProvisionalEvaluationCache 2019-06-12 13:56:28 -04:00
Niko Matsakis
35f5ef65e2 execute cycle check before we consider caching 2019-06-12 13:56:04 -04:00
Vadim Petrochenkov
eb09daa762 Hygienize macros in the standard library 2019-06-12 20:27:29 +03:00
John Kåre Alsaker
d3e1181b1c Use a single lifetime for MIR construction 2019-06-12 19:27:00 +02:00
Laurențiu Nicola
b888eb92c5 Bump some of the crates using rand 2019-06-12 19:39:14 +03:00
bors
55cee44671 Auto merge of #61612 - nnethercote:improve-parse_bottom_expr, r=petrochenkov
Special-case literals in `parse_bottom_expr`.

This makes parsing faster, particularly for code with large constants,
for two reasons:
- it skips all the keyword comparisons for literals;
- it skips the allocation done by the `mk_expr` call in
  `parse_literal_maybe_minus`.

r? @petrochenkov
2019-06-12 16:30:05 +00:00
Yuki Okushi
b8f1491f6e Fix typos 2019-06-13 00:37:30 +09:00
bors
24ddd16154 Auto merge of #61722 - eddyb:vowel-exclusion-zone, r=oli-obk
rustc: replace `TyCtxt<'a, 'gcx, 'tcx>` with `TyCtxt<'gcx, 'tcx>`.

This first lifetime parameter of `TyCtxt` has been phantom for a while, thanks to @Zoxc, but was never removed, and I'm doing this now in preparation for removing the `'gcx`/`'tcx` split.

I wasn't going to do this as a separate step, and instead start converting uses of `TyCtxt` to a single-lifetime alias of it (e.g. `type TyCx<'tcx> = TyCtxt<'tcx, 'tcx, 'tcx>;`) but it turns out (as @Zoxc rightly predicted) that there is far more fallout from not needing a lifetime for the first parameter of `TyCtxt`.

That is, going from `TyCtxt<'a, 'gcx, 'tcx>` to `TyCtxt<'tcx, 'gcx, 'tcx>` (the first commit in this PR) has the largest amount of fallout out of all the changes we might make (because it can require removing the `'a` parameter of `struct`s containing `tcx: TyCtxt<'a, ...>`), and is the hardest to automate (because `'a` is used everywhere, not just with `TyCtxt`, unlike, say `'gcx, 'tcx` -> `'tcx`).

So I'm submitting this now to get it out of the way and reduce further friction in the future.

**EDIT**: for the `rustfmt` commit, I used https://github.com/rust-lang/rustfmt/issues/1324#issuecomment-482109952, and manually filtered out some noise, like in #61735, but unlike that PR, there was also a weird bug to work around.
It should be reviewed separately, and dropped if unwanted.

cc @rust-lang/compiler r? @nikomatsakis
2019-06-12 13:41:43 +00:00
Eduard-Mihai Burtescu
4c98cb6f75 rustc_codegen_llvm: deny(internal). 2019-06-12 16:06:35 +03:00
Eduard-Mihai Burtescu
87b6b86468 rustc_codegen_llvm: deny(unused_lifetimes). 2019-06-12 16:02:03 +03:00
Pietro Albini
2cd516c1c3
ci: fix ci stats upload condition
The condition I suggested in #61632 was not correct and it errors out
while evaluating. This fixes the condition.

Example of a failure:
https://dev.azure.com/rust-lang/rust/_build/results?buildId=543
2019-06-12 14:21:59 +02:00
bors
3d7a1c9dc8 Auto merge of #61587 - alexcrichton:distcheck-no-assertions, r=pietroalbini
ci: Disable LLVM/debug assertions for distcheck

The purpose of distcheck is to test `./x.py test` from a tarball, not to
test that all assertions pass all the time. These assertions are largely
just redundant with other builders, so skip the assertions for now and
save a good chunk of time on CI.

cc #61185
2019-06-12 10:51:16 +00:00
Eduard-Mihai Burtescu
fff08cb043 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-12 13:38:28 +03:00
Eduard-Mihai Burtescu
21ac960334 rustc: remove some unnecessary lifetimes in -> TyCtxt methods. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
17cdd356da rustc: replace TyCtxt<'tcx, 'gcx, 'tcx> with TyCtxt<'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
2441253508 Fix fallout from deny(unused_lifetimes). 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
37799a5552 rustc: replace TyCtxt<'a, 'gcx, 'tcx> with TyCtxt<'tcx, 'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Marc-Antoine Perennou
e7b5586cd6 rustbuild: fix libtest_stamp
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2019-06-12 10:18:16 +02:00
bors
3f511ade5b Auto merge of #60669 - c410-f3r:attrs-fn, r=petrochenkov
Allow attributes in formal function parameters

Implements https://github.com/rust-lang/rust/issues/60406.

This is my first contribution to the compiler and since this is a large and complex project, I am not fully aware of the consequences of the changes I have made.

**TODO**

- [x] Forbid some built-in attributes.
- [x] Expand cfg/cfg_attr
2019-06-12 07:38:01 +00:00
bors
c4797fa4f4 Auto merge of #61758 - Centril:rollup-ew2uxng, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #60187 (Generator optimization: Overlap locals that never have storage live at the same time)
 - #61348 (Implement Clone::clone_from for Option and Result)
 - #61568 (Use Symbol, Span in libfmt_macros)
 - #61632 (ci: Collect CPU usage statistics on Azure)
 - #61654 (use pattern matching for slices destructuring)
 - #61671 (implement nth_back for Range(Inclusive))
 - #61688 (is_fp and is_floating_point do the same thing, remove the former)
 - #61705 (Pass cflags rather than cxxflags to LLVM as CMAKE_C_FLAGS)
 - #61734 (Migrate rust-by-example to MdBook2)

Failed merges:

r? @ghost
2019-06-12 04:57:35 +00:00
Scott McMurray
0150448f1b Remove the questionably-useful example 2019-06-11 21:13:48 -07:00
Mazdak Farrokhzad
4748b5b13d
Rollup merge of #61734 - mati865:books, r=alexcrichton
Migrate rust-by-example to MdBook2
2019-06-12 04:22:56 +02:00
Mazdak Farrokhzad
adea1317c2
Rollup merge of #61705 - petrhosek:llvm-cflags, r=alexcrichton
Pass cflags rather than cxxflags to LLVM as CMAKE_C_FLAGS

We mistakenly pass cxxflags from the configuration to LLVM build as
CMAKE_C_FLAGS.
2019-06-12 04:22:55 +02:00
Mazdak Farrokhzad
ba5b04ac46
Rollup merge of #61688 - RalfJung:is-floating-point, r=cramertj
is_fp and is_floating_point do the same thing, remove the former

also consistently mark all these `is_*` methods for inlining
2019-06-12 04:22:53 +02:00
Mazdak Farrokhzad
3a8dc44f3c
Rollup merge of #61671 - koalatux:nth-back-range, r=KodrAus
implement nth_back for Range(Inclusive)

This is part of  #54054.
2019-06-12 04:22:51 +02:00
Mazdak Farrokhzad
9f22708ced
Rollup merge of #61654 - Electron-libre:use_slice_patterns_in_rustc, r=oli-obk,Centril
use pattern matching for slices destructuring

refs #61542

Use slices pattern where it seems to make sense .
2019-06-12 04:22:50 +02:00
Mazdak Farrokhzad
6933034a40
Rollup merge of #61632 - alexcrichton:azure-pipelines-cpu, r=pietroalbini
ci: Collect CPU usage statistics on Azure

This commit adds a script which we'll execute on Azure Pipelines which
is intended to run in the background and passively collect CPU usage
statistics for our builders. The intention here is that we can use this
information over time to diagnose issues with builders, see where we can
optimize our build, fix parallelism issues, etc. This might not end up
being too useful in the long run but it's data we've wanted to collect
for quite some time now, so here's a stab at it!

Comments about how this is intended to work can be found in the python
script used here to collect CPU usage statistics.

Closes #48828
2019-06-12 04:22:48 +02:00
Mazdak Farrokhzad
d78260d781
Rollup merge of #61568 - Mark-Simulacrum:symbol-fmt-macros, r=estebank
Use Symbol, Span in libfmt_macros

I'm not super happy with this, personally, but I think it might be a decent start -- happy to take suggestions as to how to expand this or change things further.

r? @estebank

Fixes #60795
2019-06-12 04:22:47 +02:00
Mazdak Farrokhzad
b5184e56a4
Rollup merge of #61348 - dronesforwork-forks:clone-from, r=KodrAus
Implement Clone::clone_from for Option and Result

See https://github.com/rust-lang/rust/issues/28481
2019-06-12 04:22:45 +02:00
Mazdak Farrokhzad
a60a5db7de
Rollup merge of #60187 - tmandry:generator-optimization, r=eddyb
Generator optimization: Overlap locals that never have storage live at the same time

The specific goal of this optimization is to optimize async fns which use `await!`. Notably, `await!` has an enclosing scope around the futures it awaits ([definition](08bfe16129/src/libstd/macros.rs (L365-L381))), which we rely on to implement the optimization.

More generally, the optimization allows overlapping the storage of some locals which are never storage-live at the same time. **We care about storage-liveness when computing the layout, because knowing a field is `StorageDead` is the only way to prove it will not be accessed, either directly or through a reference.**

To determine whether we can overlap two locals in the generator layout, we look at whether they might *both* be `StorageLive` at any point in the MIR. We use the `MaybeStorageLive` dataflow analysis for this. We iterate over every location in the MIR, and build a bitset for each local of the locals it might potentially conflict with.

Next, we assign every saved local to one or more variants. The variants correspond to suspension points, and we include the set of locals live across a given suspension point in the variant. (Note that we use liveness instead of storage-liveness here; this ensures that the local has actually been initialized in each variant it has been included in. If the local is not live across a suspension point, then it doesn't need to be included in that variant.). It's important to note that the variants are a "view" into our layout.

For the layout computation, we use a simplified approach.

1. Start with the set of locals assigned to only one variant. The rest are disqualified.
2. For each pair of locals which may conflict *and are not assigned to the same variant*, we pick one local to disqualify from overlapping.

Disqualified locals go into a non-overlapping "prefix" at the beginning of our layout. This means they always have space reserved for them. All the locals that are allowed to overlap in each variant are then laid out after this prefix, in the "overlap zone".

So, if A and B were disqualified, and X, Y, and Z were all eligible for overlap, our generator might look something like this:

You can think of a generator as an enum, where some fields are shared between variants. e.g.

```rust
enum Generator {
  Unresumed,
  Poisoned,
  Returned,
  Suspend0(A, B, X),
  Suspend1(B),
  Suspend2(A, Y, Z),
}
```

where every mention of `A` and `B` refer to the same field, which does not move when changing variants. Note that `A` and `B` would automatically be sent to the prefix in this example. Assuming that `X` is never `StorageLive` at the same time as either `Y` or `Z`, it would be allowed to overlap with them.

Note that if two locals (`Y` and `Z` in this case) are assigned to the same variant in our generator, their memory would never overlap in the layout. Thus they can both be eligible for the overlapping section, even if they are storage-live at the same time.

---

Depends on:
- [x] #59897 Multi-variant layouts for generators
- [x] #60840 Preserve local scopes in generator MIR
- [x] #61373 Emit StorageDead along unwind paths for generators

Before merging:

- [x] ~Wrap the types of all generator fields in `MaybeUninitialized` in layout::ty::field~ (opened #60889)
- [x] Make PR description more complete (e.g. explain why storage liveness is important and why we have to check every location)
- [x] Clean up TODO
- [x] Fix the layout code to enforce that the same field never moves around in the generator
- [x] Add tests for async/await
- [x] ~Reduce # bits we store by half, since the conflict relation is symmetric~ (note: decided not to do this, for simplicity)
- [x] Store liveness information for each yield point in our `GeneratorLayout`, that way we can emit more useful debuginfo AND tell miri which fields are definitely initialized for a given variant (see discussion at https://github.com/rust-lang/rust/pull/59897#issuecomment-489468627)
2019-06-12 04:22:44 +02:00
bors
05083c2dee Auto merge of #60187 - tmandry:generator-optimization, r=eddyb
Generator optimization: Overlap locals that never have storage live at the same time

The specific goal of this optimization is to optimize async fns which use `await!`. Notably, `await!` has an enclosing scope around the futures it awaits ([definition](08bfe16129/src/libstd/macros.rs (L365-L381))), which we rely on to implement the optimization.

More generally, the optimization allows overlapping the storage of some locals which are never storage-live at the same time. **We care about storage-liveness when computing the layout, because knowing a field is `StorageDead` is the only way to prove it will not be accessed, either directly or through a reference.**

To determine whether we can overlap two locals in the generator layout, we look at whether they might *both* be `StorageLive` at any point in the MIR. We use the `MaybeStorageLive` dataflow analysis for this. We iterate over every location in the MIR, and build a bitset for each local of the locals it might potentially conflict with.

Next, we assign every saved local to one or more variants. The variants correspond to suspension points, and we include the set of locals live across a given suspension point in the variant. (Note that we use liveness instead of storage-liveness here; this ensures that the local has actually been initialized in each variant it has been included in. If the local is not live across a suspension point, then it doesn't need to be included in that variant.). It's important to note that the variants are a "view" into our layout.

For the layout computation, we use a simplified approach.

1. Start with the set of locals assigned to only one variant. The rest are disqualified.
2. For each pair of locals which may conflict *and are not assigned to the same variant*, we pick one local to disqualify from overlapping.

Disqualified locals go into a non-overlapping "prefix" at the beginning of our layout. This means they always have space reserved for them. All the locals that are allowed to overlap in each variant are then laid out after this prefix, in the "overlap zone".

So, if A and B were disqualified, and X, Y, and Z were all eligible for overlap, our generator might look something like this:

You can think of a generator as an enum, where some fields are shared between variants. e.g.

```rust
enum Generator {
  Unresumed,
  Poisoned,
  Returned,
  Suspend0(A, B, X),
  Suspend1(B),
  Suspend2(A, Y, Z),
}
```

where every mention of `A` and `B` refer to the same field, which does not move when changing variants. Note that `A` and `B` would automatically be sent to the prefix in this example. Assuming that `X` is never `StorageLive` at the same time as either `Y` or `Z`, it would be allowed to overlap with them.

Note that if two locals (`Y` and `Z` in this case) are assigned to the same variant in our generator, their memory would never overlap in the layout. Thus they can both be eligible for the overlapping section, even if they are storage-live at the same time.

---

Depends on:
- [x] #59897 Multi-variant layouts for generators
- [x] #60840 Preserve local scopes in generator MIR
- [x] #61373 Emit StorageDead along unwind paths for generators

Before merging:

- [x] ~Wrap the types of all generator fields in `MaybeUninitialized` in layout::ty::field~ (opened #60889)
- [x] Make PR description more complete (e.g. explain why storage liveness is important and why we have to check every location)
- [x] Clean up TODO
- [x] Fix the layout code to enforce that the same field never moves around in the generator
- [x] Add tests for async/await
- [x] ~Reduce # bits we store by half, since the conflict relation is symmetric~ (note: decided not to do this, for simplicity)
- [x] Store liveness information for each yield point in our `GeneratorLayout`, that way we can emit more useful debuginfo AND tell miri which fields are definitely initialized for a given variant (see discussion at https://github.com/rust-lang/rust/pull/59897#issuecomment-489468627)
2019-06-12 02:13:11 +00:00
bors
961a9d6e97 Auto merge of #61741 - Centril:rollup-fgro5kz, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #61518 (Add loops to doc list of things not stable in const fn)
 - #61526 (move some tests into subfolders)
 - #61550 (Windows 10 SDK is also required now.)
 - #61606 (Remove some legacy proc macro flavors)
 - #61652 (Mention slice patterns in array)
 - #61686 (librustc_errors: Add some more documentation)
 - #61698 (typeck: Fix const generic in repeat param ICE.)
 - #61707 (Azure: retry failed awscli installs)
 - #61715 (make sure make_ascii_lowercase actually leaves upper-case non-ASCII characters alone)
 - #61724 (core: use memcmp optimization for 128 bit integer slices)
 - #61726 (Use `for_each` in `Iterator::partition`)

Failed merges:

r? @ghost
2019-06-11 23:29:20 +00:00
Niko Matsakis
5486a860f1 propagate depth that was reached, not just whether there was a cycle
I tried to propagate this information with the return value, but I
found a curiosity (actually, something that I'm not keen on in
general) -- in particular, the candidate cache urrently invokes
evaluation, which may detect a cycle, but the "depth" that results
from that are is easily propagated back out. This probably means that
the candidate caching mechanism *itself* is sort of problematic, but
I'm choosing to ignore that in favor of a more ambitious rewrite
later.
2019-06-11 19:07:32 -04:00
Niko Matsakis
e64a7bf64b introduce a stack depth 2019-06-11 19:07:32 -04:00
Niko Matsakis
db1dfb2f36 rename evaluate_obligation_recursively
It does not, in fact, execute in a recursive context.
2019-06-11 19:07:32 -04:00
Tyler Mandry
4f3cd3ca07 Fix x.py install
Make sure we look for save analysis in the right place. Fixes #61703.
2019-06-11 14:27:37 -07:00
Tyler Mandry
aeefbc4cba More review fixes 2019-06-11 14:26:07 -07:00
bors
5f3656ce9a Auto merge of #61735 - eddyb:must-use-life, r=oli-obk
Add deny(unused_lifetimes) to all the crates that have deny(internal).

@Zoxc brought up, regarding #61722, that we don't force the removal of unused lifetimes.
Turns out that it's not that bad to enable for compiler crates (I wonder why it's not `warn` by default?).

I would've liked to enable `single_use_lifetimes` as well, but https://github.com/rust-lang/rust/issues/53738 makes it unusable for now.

For the `rustfmt` commit, I used https://github.com/rust-lang/rustfmt/issues/1324#issuecomment-482109952, and manually filtered out some noise.

r? @oli-obk cc @rust-lang/compiler
2019-06-11 20:45:17 +00:00
Ralf Jung
87d5fe0e53 is_fp and is_floating_point do the same thing, remove the former
also consistently mark all these is_* methods for inlining
2019-06-11 19:46:16 +02:00
Mazdak Farrokhzad
681712be09
Rollup merge of #61726 - cuviper:partition-for_each, r=scottmcm
Use `for_each` in `Iterator::partition`

We already use this for `unzip`, but `partition` is not much different.
2019-06-11 17:14:12 +02:00
Mazdak Farrokhzad
2f1d360206
Rollup merge of #61724 - aschampion:128-bit-memcmp, r=sfackler
core: use memcmp optimization for 128 bit integer slices

All other sized integer slices do this. From #61665.
2019-06-11 17:14:11 +02:00
Mazdak Farrokhzad
231b0375f6
Rollup merge of #61715 - RalfJung:test-ascii-lowercase, r=varkor
make sure make_ascii_lowercase actually leaves upper-case non-ASCII characters alone

Cc https://github.com/rust-lang/rust/pull/61677 @napen123
2019-06-11 17:14:09 +02:00
Mazdak Farrokhzad
e6a948feb7
Rollup merge of #61707 - wesleywiser:awscli_retry, r=alexcrichton
Azure: retry failed awscli installs

Fixes #61604

r? @pietroalbini
2019-06-11 17:14:08 +02:00
Mazdak Farrokhzad
bd57c187fb
Rollup merge of #61698 - davidtwco:ice-const-generic-length, r=varkor
typeck: Fix const generic in repeat param ICE.

Fixes #61336. Turns out this wasn't related to #49147 after all.

r? @varkor
2019-06-11 17:14:04 +02:00
Mazdak Farrokhzad
b3169552e2
Rollup merge of #61686 - phansch:librustc_errors_docs, r=estebank
librustc_errors: Add some more documentation

r? @estebank
2019-06-11 17:14:03 +02:00
Mazdak Farrokhzad
79ac254703
Rollup merge of #61652 - JohnTitor:docs-improve-array, r=Centril
Mention slice patterns in array

Fixes #61650

r? @scottmcm
2019-06-11 17:14:01 +02:00