Commit Graph

95056 Commits

Author SHA1 Message Date
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
Mazdak Farrokhzad
b4419a8b05
Rollup merge of #61606 - petrochenkov:legclean, r=pnkfelix
Remove some legacy proc macro flavors

Namely
- `IdentTT` (`foo! ident { ... }`). Can be replaced with `foo! { ident ... }` or something similar.
- `MultiDecorator`. Can be replaced by `MultiModifier` (aka `LegacyAttr` after renaming).
- `DeclMacro`. It was a less powerful duplicate of `NormalTT` (aka `LegacyBang` after renaming) and can be replaced by it.

Stuff like this slows down any attempts to refactor the expansion infra, so it's desirable to retire it already.
I'm not sure whether a lang team decision is necessary, but would be nice to land this sooner because I have some further work in this area scheduled.

The documentation commit (a9397fd0d5) describes how the remaining variants are different from each other and shows that there's actually some system behind them.

The last commit renames variants of `SyntaxExtension` in more systematic way.
- `ProcMacro` -> `Bang`
- `NormalTT` -> `LegacyBang`
- `AttrProcMacro` -> `Attr`
- `MultiModifier` -> `LegacyAttr`
- `ProcMacroDerive` -> `Derive`
- `BuiltinDerive` -> `LegacyDerive`

All the `Legacy*` variants are AST-based, as opposed to "modern" token-based variants.
2019-06-11 17:13:59 +02:00
Mazdak Farrokhzad
b81986c2af
Rollup merge of #61550 - jacobsun:patch-1, r=alexcrichton
Windows 10 SDK is also required now.
2019-06-11 17:13:58 +02:00
Mazdak Farrokhzad
c2bb8b9c08
Rollup merge of #61526 - lcnr:test_reorder, r=nikomatsakis
move some tests into subfolders

This reduces the size of the test folders without making the moved tests harder to find.

Is this kind of change desired/worth the effort?
2019-06-11 17:13:56 +02:00
Mazdak Farrokhzad
17393b26b9
Rollup merge of #61518 - czipperz:const-fn-doc-disallow-loops, r=Centril
Add loops to doc list of things not stable in const fn

Closes #61508
2019-06-11 17:13:54 +02:00
Alex Crichton
f2c37a55a4 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-11 06:56:30 -07:00
Eduard-Mihai Burtescu
1d720ec27c Run rustfmt --file-lines ... for changes from previous commits. 2019-06-11 14:11:59 +03:00
Eduard-Mihai Burtescu
630ec8880c Add deny(unused_lifetimes) to all the crates that have deny(internal). 2019-06-11 14:11:59 +03:00
Eduard-Mihai Burtescu
4a219685ff rustdoc: deny(unused_lifetimes). 2019-06-11 14:11:59 +03:00
Eduard-Mihai Burtescu
8ee1814062 rustc_codegen_*: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
7b353f215f rustc_borrowck: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
8dddfde6e3 rustc_traits: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
d110d309b6 rustc_mir: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
7dc34945e4 rustc_lint: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
26a03405a5 rustc_incremental: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
774724be3c rustc: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
ce0ba38921 syntax_ext: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
Eduard-Mihai Burtescu
4d426bb1c0 rustc_target: deny(unused_lifetimes). 2019-06-11 14:11:58 +03:00
bors
8e948df707 Auto merge of #60463 - mjbshaw:transparent, r=varkor,rkruppe
Implement RFC 2645 (transparent enums and unions)

Tracking issue: #60405
2019-06-11 11:06:38 +00:00
Mateusz Mikuła
7d3211339b Migrate rust-by-example to MdBook2 2019-06-11 11:49:38 +02:00
bors
912d22e369 Auto merge of #61673 - RalfJung:miri-no-hard-float, r=eddyb,oli-obk
Miri: convert to/from apfloat instead of host floats

Cc @oli-obk @eddyb
2019-06-11 08:15:12 +00:00
bors
9d9c7ad323 Auto merge of #61492 - RalfJung:const-qualif-comments, r=eddyb
Const qualification comments

I extracted some const-qualif knowledge from @eddyb. This is my attempt to turn that into comments.

Cc @oli-obk 	@eddyb
2019-06-11 05:24:41 +00:00
Michael Bradshaw
dac1c6a731 Implement RFC 2645 (transparent enums and unions)
Tracking issue: #60405
2019-06-10 22:07:24 -07:00