]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #64342 - glorv:master, r=varkor
Mazdak Farrokhzad [Sat, 21 Sep 2019 14:01:26 +0000 (16:01 +0200)]
Rollup merge of #64342 - glorv:master, r=varkor

factor out pluralisation remains after #64280

there are two case that doesn't not match the original macro pattern at [here](https://github.com/rust-lang/rust/blob/master/src/librustc_lint/unused.rs#L146) and [here](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/diagnostics.rs#L539) as the provided param is already a bool or the check condition is not `x != 1`, so I change the macro accept a boolean expr instead of number to fit all the cases.

@Centril  please review

Fixes #64238.

4 years agoRollup merge of #64136 - crgl:doc-from-parser-lhs, r=Centril
Mazdak Farrokhzad [Sat, 21 Sep 2019 14:01:25 +0000 (16:01 +0200)]
Rollup merge of #64136 - crgl:doc-from-parser-lhs, r=Centril

Document From trait for LhsExpr in parser

Add doc for From trait for converting P<Expr> and Option<ThinVec<Attribute>> to LhsExpr

As part of issue rust-lang#51430 (cc @skade).

Both of these should just be moving an address and setting a discriminant in an enum. The main thing I'm not sure about is whether it's worth documenting the branch in the From<Option<ThinVec<Attribute>>. As far as I can tell it doesn't seem like it is optimized away (although if the discriminant happened to work out you could just copy the pointer and the discriminant which might be cheaper, but that's not guaranteed). So it seems like if it's being called often, it's doubling the number of possible branch mispredictions on this Option, which could be a significant cost.

Let me know if there's anything that needs fixing and I'll get to it as soon as possible!

4 years agoRollup merge of #64010 - c410-f3r:stabilize-attrs-fn, r=Centril
Mazdak Farrokhzad [Sat, 21 Sep 2019 14:01:23 +0000 (16:01 +0200)]
Rollup merge of #64010 - c410-f3r:stabilize-attrs-fn, r=Centril

Stabilize `param_attrs` in Rust 1.39.0

# Stabilization proposal

I propose that we stabilize `#![feature(param_attrs)]`.

Tracking issue: #60406
Version: 1.39 (2019-09-26 => beta, 2019-11-07 => stable).

## What is stabilized

It is now possible to add outer attributes like `#[cfg(..)]` on formal parameters of functions, closures, and function pointer types. For example:

```rust
fn len(
    #[cfg(windows)] slice: &[u16],
    #[cfg(not(windows))] slice: &[u8],
) -> usize {
    slice.len()
}
```

## What isn't stabilized

* Documentation comments like `/// Doc` on parameters.

* Code expansion of a user-defined `#[proc_macro_attribute]` macro used on parameters.

* Built-in attributes other than `cfg`, `cfg_attr`, `allow`, `warn`, `deny`, and `forbid`. Currently, only the lints `unused_variables` and `unused_mut` have effect and may be controlled on parameters.

## Motivation

The chief motivations for stabilizing `param_attrs` include:

* Finer conditional compilation with `#[cfg(..)]` and linting control of variables.

* Richer macro DSLs created by users.

* External tools and compiler internals can take advantage of the additional information that the parameters provide.

For more examples, see the [RFC][rfc motivation].

## Reference guide

In the grammar of function and function pointer, the grammar of variadic tails (`...`) and parameters are changed respectively from:

```rust
FnParam = { pat:Pat ":" }? ty:Type;
VaradicTail = "...";
```

into:

```rust
FnParam = OuterAttr* { pat:Pat ":" }? ty:Type;
VaradicTail = OuterAttr* "...";
```

The grammar of a closure parameter is changed from:

```rust
ClosureParam = pat:Pat { ":" ty:Type }?;
```

into:

```rust
ClosureParam = OuterAttr* pat:Pat { ":" ty:Type }?;
```

More generally, where there's a list of formal (value) parameters separated or terminated by `,` and delimited by `(` and `)`. Each parameter in that list may optionally be prefixed by `OuterAttr+`.

Note that in all cases, `OuterAttr*` applies to the whole parameter and not just the pattern. This distinction matters in pretty printing and in turn for macros.

## History

* On 2018-10-15, @Robbepop proposes [RFC 2565][rfc], "Attributes in formal function parameter position".

* On 2019-04-30, [RFC 2565][rfc] is merged and the tracking issue is made.

* On 2019-06-12, a partial implementation was completed. The implementation was done in [#60669][60669] by @c410-f3r and the PR was reviewed by @petrochenkov and @Centril.

* On 2019-07-29, [#61238][61238] was fixed in [#61856][61856]. The issue fixed was that lint attributes on function args had no effect. The PR was written by @c410-f3r and reviewed by @matthewjasper, @petrochenkov, and @oli-obk.

* On 2019-08-02, a bug [#63210][63210] was filed wherein the attributes on formal parameters would not be passed to macros. The issue was about forgetting to call the relevant method in `fn print_arg` in the pretty printer. In [#63212][63212], written by @Centril on 2019-08-02 and reviewed by @davidtwco, the issue aforementioned was fixed.

* This PR stabilizes `param_attrs`.

## Tests

* [On Rust 2018, attributes aren't permitted on function parameters without a pattern in trait definitions.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs)

* [All attributes that should be allowed. This includes `cfg`, `cfg_attr`, and lints check attributes.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs)

* [Built-in attributes, which should be forbidden, e.g., `#[test]`, are.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs)

* [`cfg` and `cfg_attr` are properly evaluated.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs)

* [`unused_mut`](https://github.com/rust-lang/rust/blob/46f405ec4d7c6bf16fc2eaafe7541019f1da2996/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) and [`unused_variables`](https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/lint-unused-variables.rs) are correctly applied to parameter patterns.

* [Pretty printing takes formal parameter attributes into account.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs)

## Possible future work

* Custom attributes inside function parameters aren't currently supported but it is something being worked on internally.

* Since documentation comments are syntactic sugar for `#[doc(...)]`, it is possible to allow literal `/// Foo` comments on function parameters.

[rfc motivation]: https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md#motivation
[rfc]: https://github.com/rust-lang/rfcs/pull/2565
[60669]: https://github.com/rust-lang/rust/pull/60669
[61856]: https://github.com/rust-lang/rust/pull/61856
[63210]: https://github.com/rust-lang/rust/issues/63210
[61238]: https://github.com/rust-lang/rust/issues/61238
[63212]: https://github.com/rust-lang/rust/pull/63212

This report is a collaborative work with @Centril.

4 years agoAuto merge of #64047 - timvermeulen:cmp_min_max_by, r=cuviper
bors [Sat, 21 Sep 2019 04:21:25 +0000 (04:21 +0000)]
Auto merge of #64047 - timvermeulen:cmp_min_max_by, r=cuviper

Add `cmp::{min_by, min_by_key, max_by, max_by_key}`

This adds the following functions to `core::cmp`:

- `min_by`
- `min_by_key`
- `max_by`
- `max_by_key`

`min_by` and `max_by` are somewhat trivial to implement, but not entirely because `min_by` returns the first value in case the two are equal (and `max_by` the second). `min` and `max` can be implemented in terms of `min_by` and `max_by`, but not as easily the other way around.

To give an example of why I think these functions could be useful: the `Iterator::{min_by, min_by_key, max_by, max_by_key}` methods all currently hard-code the behavior mentioned above which is an ever so small duplication of logic. If we delegate them to `cmp::{min_by, max_by}` methods instead, we get the correct behavior for free. (edit: this is now included in the PR)

I added `min_by_key` / `max_by_key` for consistency's sake but I wouldn't mind removing them. I don't have a particular use case in mind for them, and `min_by` / `max_by` seem to be more useful.

Tracking issue: #64460

4 years agoAuto merge of #64584 - nikomatsakis:issue-64477-generator-capture-types, r=eddyb
bors [Fri, 20 Sep 2019 15:35:51 +0000 (15:35 +0000)]
Auto merge of #64584 - nikomatsakis:issue-64477-generator-capture-types, r=eddyb

record fewer adjustment types in generator witnesses, avoid spurious drops in MIR construction

Don't record all intermediate adjustment types -- That's way more than is needed, and winds up recording types that will never appear in MIR.

Note: I'm like 90% sure that this logic is correct, but this stuff is subtle and can be hard to keep straight.  However, the risk of this PR is fairly low -- if we miss types here, I believe the most common outcome is an ICE.

This fixes the original issue cited by #64477, but I'm leaving the issue open for now since there may be other cases we can detect and improve in a targeted way.

r? @Zoxc

4 years agoAuto merge of #64553 - alexcrichton:windows-bash-install-scripts, r=Mark-Simulacrum
bors [Fri, 20 Sep 2019 11:38:56 +0000 (11:38 +0000)]
Auto merge of #64553 - alexcrichton:windows-bash-install-scripts, r=Mark-Simulacrum

azure: Convert Windows installations scripts to `bash`

Looks like `script`, which uses `cmd.exe`, doesn't have fail-fast
behavior and if a leading command fails the script doesn't actually fail
so long as the last command succeeds. We instead want the opposite
behavior where if any step fails the whole script fails.

I don't really know `cmd.exe` that well, nor powershell, so I've opted
to move everything to `bash` which should be a good common denominator
amongst all platforms to work with. Additionally I know that `set -e`
works to cause scripts to fail fast.

Closes #64551

4 years agoAuto merge of #64498 - estebank:point-at-arg, r=Centril
bors [Fri, 20 Sep 2019 07:53:23 +0000 (07:53 +0000)]
Auto merge of #64498 - estebank:point-at-arg, r=Centril

When possible point at argument causing item obligation failure

Fix https://github.com/rust-lang/rust/issues/41781, fix https://github.com/rust-lang/rust/issues/42855, fix https://github.com/rust-lang/rust/issues/46658, fix https://github.com/rust-lang/rust/issues/48099, fix https://github.com/rust-lang/rust/issues/63143.

4 years agoAuto merge of #64576 - pietroalbini:split-aws-tokens, r=alexcrichton
bors [Fri, 20 Sep 2019 02:43:06 +0000 (02:43 +0000)]
Auto merge of #64576 - pietroalbini:split-aws-tokens, r=alexcrichton

ci: split aws credentials in two separate users with scoped perms

This commit changes our CI to use two separate IAM users to authenticate with AWS:

* `ci--rust-lang--rust--sccache`: has access to the `rust-lang-ci-sccache2` S3 bucket and its credentials are available during the whole build.
* `ci--rust-lang--rust--upload`: has access to the `rust-lang-ci2` S3 bucket and its credentials are available just during the upload step.

The new tokens are available in the `prod-credentials` library.

r? @alexcrichton

4 years agoAuto merge of #64616 - Centril:rollup-du6728f, r=Centril
bors [Thu, 19 Sep 2019 22:41:46 +0000 (22:41 +0000)]
Auto merge of #64616 - Centril:rollup-du6728f, r=Centril

Rollup of 6 pull requests

Successful merges:

 - #63448 (fix Miri discriminant handling)
 - #64592 (Point at original span when emitting unreachable lint)
 - #64601 (Fix backticks in documentation)
 - #64606 (Remove unnecessary `mut` in doc example)
 - #64611 (rustbuild: Don't package libstd twice)
 - #64613 (rustbuild: Copy crate doc files fewer times)

Failed merges:

r? @ghost

4 years agoadd comments
Esteban Küber [Thu, 19 Sep 2019 21:52:38 +0000 (14:52 -0700)]
add comments

4 years agoadd a mir-opt test that we don't add the spurious drop
Niko Matsakis [Thu, 19 Sep 2019 20:12:48 +0000 (16:12 -0400)]
add a mir-opt test that we don't add the spurious drop

4 years agoremove duplicated code
Esteban Küber [Thu, 19 Sep 2019 17:16:48 +0000 (10:16 -0700)]
remove duplicated code

4 years agoreview comments
Esteban Küber [Thu, 19 Sep 2019 00:33:15 +0000 (17:33 -0700)]
review comments

4 years agoreview comments
Esteban Küber [Wed, 18 Sep 2019 19:05:37 +0000 (12:05 -0700)]
review comments

4 years agoWhen possible, suggest fn call
Esteban Küber [Mon, 16 Sep 2019 22:54:31 +0000 (15:54 -0700)]
When possible, suggest fn call

4 years agoReview comment: move to its own method
Esteban Küber [Mon, 16 Sep 2019 17:15:17 +0000 (10:15 -0700)]
Review comment: move to its own method

4 years agoIgnore obligations coming from desugared call spans
Esteban Küber [Mon, 16 Sep 2019 15:49:53 +0000 (08:49 -0700)]
Ignore obligations coming from desugared call spans

4 years agoWhen possible point at argument causing item obligation failure
Esteban Küber [Mon, 16 Sep 2019 04:58:20 +0000 (21:58 -0700)]
When possible point at argument causing item obligation failure

4 years agofix mir-opt tests
Niko Matsakis [Thu, 19 Sep 2019 18:30:05 +0000 (14:30 -0400)]
fix mir-opt tests

4 years agowhoops, only trigger this path for avoiding DROP, not StorageDead
Niko Matsakis [Thu, 19 Sep 2019 17:42:46 +0000 (13:42 -0400)]
whoops, only trigger this path for avoiding DROP, not StorageDead

4 years agofix tests for 2018
Niko Matsakis [Thu, 19 Sep 2019 17:15:54 +0000 (13:15 -0400)]
fix tests for 2018

4 years agoRollup merge of #64613 - alexcrichton:less-doc-copies, r=Mark-Simulacrum
Mazdak Farrokhzad [Thu, 19 Sep 2019 16:31:44 +0000 (18:31 +0200)]
Rollup merge of #64613 - alexcrichton:less-doc-copies, r=Mark-Simulacrum

rustbuild: Copy crate doc files fewer times

Previously when building documentation for the standard library we'd
copy all the files 5 times, and these files include libcore/libstd docs
which are huge! This commit instead only copies the files after rustdoc
has been run for each crate, reducing the number of redundant copies
we're making.

4 years agoRollup merge of #64611 - alexcrichton:no-libstd-twice, r=Mark-Simulacrum
Mazdak Farrokhzad [Thu, 19 Sep 2019 16:31:43 +0000 (18:31 +0200)]
Rollup merge of #64611 - alexcrichton:no-libstd-twice, r=Mark-Simulacrum

rustbuild: Don't package libstd twice

Looks like the packaging step for the standard library was happening
twice on CI, but it only needs to happen once! The `Analysis` packaging
step accidentally packaged `Std` instead of relying on compiling `Std`,
which meant that we ended up packaging it twice erroneously.

4 years agoRollup merge of #64606 - adrianheine:patch-1, r=sfackler
Mazdak Farrokhzad [Thu, 19 Sep 2019 16:31:41 +0000 (18:31 +0200)]
Rollup merge of #64606 - adrianheine:patch-1, r=sfackler

Remove unnecessary `mut` in doc example

4 years agoRollup merge of #64601 - grovesNL:two-backticks, r=jonas-schievink
Mazdak Farrokhzad [Thu, 19 Sep 2019 16:31:40 +0000 (18:31 +0200)]
Rollup merge of #64601 - grovesNL:two-backticks, r=jonas-schievink

Fix backticks in documentation

Fix a few typos in comments/documentation where backticks were doubled-up on one side.

4 years agoRollup merge of #64592 - Aaron1011:feature/unreachable-span, r=Centril
Mazdak Farrokhzad [Thu, 19 Sep 2019 16:31:39 +0000 (18:31 +0200)]
Rollup merge of #64592 - Aaron1011:feature/unreachable-span, r=Centril

Point at original span when emitting unreachable lint

Fixes #64590

When we emit an 'unreachable' lint, we now add a note pointing at the
expression that actually causes the code to be unreachable (e.g.
`return`, `break`, `panic`).

This is especially useful when macros are involved, since a diverging
expression might be hidden inside of a macro invocation.

4 years agoRollup merge of #63448 - RalfJung:miri-discriminant, r=eddyb
Mazdak Farrokhzad [Thu, 19 Sep 2019 16:31:37 +0000 (18:31 +0200)]
Rollup merge of #63448 - RalfJung:miri-discriminant, r=eddyb

fix Miri discriminant handling

This can be reviewed commit-by-commit fairly well.

The Miri side is at https://github.com/rust-lang/miri/pull/903.

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

r? @eddyb @oli-obk

4 years agofactor out pluralisation remains after #64280
gaolei [Thu, 19 Sep 2019 07:13:40 +0000 (15:13 +0800)]
factor out pluralisation remains after #64280

4 years agoavoid generating drops for moved operands of calls
Niko Matsakis [Thu, 19 Sep 2019 15:41:10 +0000 (11:41 -0400)]
avoid generating drops for moved operands of calls

Currently, after a CALL terminator is created in MIR, we insert DROP
statements for all of its operands -- even though they were just moved
shortly before! These spurious drops are later removed, but not before
causing borrow check errors.

This PR series modifies the drop code to track operands that were
moved and avoid creating drops for them.

Right now, I'm only using this mechanism for calls, but it seems
likely it could be used in more places.

4 years agorustbuild: Copy crate doc files fewer times
Alex Crichton [Thu, 19 Sep 2019 14:48:04 +0000 (07:48 -0700)]
rustbuild: Copy crate doc files fewer times

Previously when building documentation for the standard library we'd
copy all the files 5 times, and these files include libcore/libstd docs
which are huge! This commit instead only copies the files after rustdoc
has been run for each crate, reducing the number of redundant copies
we're making.

4 years agorustbuild: Don't package libstd twice
Alex Crichton [Thu, 19 Sep 2019 14:46:24 +0000 (07:46 -0700)]
rustbuild: Don't package libstd twice

Looks like the packaging step for the standard library was happening
twice on CI, but it only needs to happen once! The `Analysis` packaging
step accidentally packaged `Std` instead of relying on compiling `Std`,
which meant that we ended up packaging it twice erroneously.

4 years agomake clear that `invalidate` just replaces with `default`
Niko Matsakis [Thu, 19 Sep 2019 14:30:46 +0000 (10:30 -0400)]
make clear that `invalidate` just replaces with `default`

4 years agoazure: Convert Windows installations scripts to `bash`
Alex Crichton [Tue, 17 Sep 2019 14:40:27 +0000 (07:40 -0700)]
azure: Convert Windows installations scripts to `bash`

Looks like `script`, which uses `cmd.exe`, doesn't have fail-fast
behavior and if a leading command fails the script doesn't actually fail
so long as the last command succeeds. We instead want the opposite
behavior where if any step fails the whole script fails.

I don't really know `cmd.exe` that well, nor powershell, so I've opted
to move everything to `bash` which should be a good common denominator
amongst all platforms to work with. Additionally I know that `set -e`
works to cause scripts to fail fast.

Note that some scripts remain as `script` since they don't appear to
work in` bash`. I'm not really sure why but I reorganized them slightly
to have the "meaty command" run at the end.

4 years agoreplace boolean with lazy iteration
Niko Matsakis [Thu, 19 Sep 2019 14:07:50 +0000 (10:07 -0400)]
replace boolean with lazy iteration

Should probably check how this performs, but it's always nicer to
track just a bit less mutable state.

4 years agoRemove unnecessary `mut` in doc example
Adrian Heine né Lang [Thu, 19 Sep 2019 11:36:10 +0000 (13:36 +0200)]
Remove unnecessary `mut` in doc example

4 years agofirst determine if the variant is a niche-variant, then compute absolute variant
Ralf Jung [Thu, 19 Sep 2019 07:02:45 +0000 (09:02 +0200)]
first determine if the variant is a niche-variant, then compute absolute variant

4 years agoAuto merge of #64545 - nnethercote:ObligForest-more, r=nmatsakis
bors [Thu, 19 Sep 2019 06:53:54 +0000 (06:53 +0000)]
Auto merge of #64545 - nnethercote:ObligForest-more, r=nmatsakis

More `ObligationForest` improvements

Following on from #64500, these commits alsomake the code both nicer and faster.

r? @nikomatsakis

4 years agoci: split aws credentials in two separate users with scoped perms
Pietro Albini [Wed, 18 Sep 2019 09:10:46 +0000 (11:10 +0200)]
ci: split aws credentials in two separate users with scoped perms

This commit changes our CI to use two separate IAM users to
authenticate with AWS:

* ci--rust-lang--rust--sccache: has access to the rust-lang-ci-sccache2
  S3 bucket and its credentials are available during the whole build.
* ci--rust-lang--rust--upload: has access to the rust-lang-ci2 S3 bucket
  and its credentials are available just during the upload step.

The new tokens are available in the `prod-credentials` library.

4 years agoFix backticks in documentation
Joshua Groves [Thu, 19 Sep 2019 05:17:36 +0000 (23:17 -0600)]
Fix backticks in documentation

4 years agoAuto merge of #64598 - Centril:rollup-htmf39p, r=Centril
bors [Thu, 19 Sep 2019 02:54:11 +0000 (02:54 +0000)]
Auto merge of #64598 - Centril:rollup-htmf39p, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #63630 (Update installed compiler dependencies)
 - #64536 (Update Cargo)
 - #64554 (Polonius: more `ui` test suite fixes)
 - #64566 (A more generic interface for dataflow analysis)
 - #64591 (Fix a minor grammar nit, update UI tests)

Failed merges:

r? @ghost

4 years agoRollup merge of #64591 - jamesmunns:grammar-fix, r=jonas-schievink
Mazdak Farrokhzad [Thu, 19 Sep 2019 02:53:12 +0000 (04:53 +0200)]
Rollup merge of #64591 - jamesmunns:grammar-fix, r=jonas-schievink

Fix a minor grammar nit, update UI tests

Minor fix, but I noticed it while debugging some code

4 years agoRollup merge of #64566 - ecstatic-morse:generic-dataflow, r=oli-obk
Mazdak Farrokhzad [Thu, 19 Sep 2019 02:53:11 +0000 (04:53 +0200)]
Rollup merge of #64566 - ecstatic-morse:generic-dataflow, r=oli-obk

A more generic interface for dataflow analysis

#64470 requires a transfer function that is slightly more complex than the typical `gen`/`kill` one. Namely, it must copy state bits between locals when assignments occur (see #62547 for an attempt to make this fit into the existing framework). This PR contains a dataflow interface that allows for arbitrary transfer functions. The trade-off is efficiency: we can no longer coalesce transfer functions for blocks and must visit each statement individually while iterating to fixpoint.

Another issue is that poorly behaved transfer functions can result in an analysis that fails to converge. `gen`/`kill` sets do not have this problem. I believe that, in order to guarantee convergence, flipping a bit from `false` to `true` in the entry set cannot cause an output bit to go from `true` to `false` (negate all preceding booleans when `true` is the bottom value). Perhaps someone with a more formal background can confirm and we can add a section to the docs?

This approach is not maximally generic: it still requires that the lattice used for analysis is the powerset of values of `Analysis::Idx` for the `mir::Body` of interest. This can be done at a later date. Also, this is the bare minimum to get #64470 working. I've not adapted the existing debug framework to work with the new analysis, so there are no `rustc_peek` tests either. I'm planning to do this after #64470 is merged.

Finally, my ultimate plan is to make the existing, `gen`/`kill`-based `BitDenotation` a special case of `generic::Analysis`. Currently they share a ton of code. I should be able to do this without changing any implementers of `BitDenotation`. Something like:

```rust
struct GenKillAnalysis<A: BitDenotation> {
    trans_for_block: IndexVec<BasicBlock, GenKillSet<A::Idx>>,
    analysis: A,
}

impl<A> generic::Analysis for GenKillAnalysis<A> {
    // specializations of `apply_{partial,whole}_block_effect`...
}
```

r? @pnkfelix

4 years agoRollup merge of #64554 - lqd:polonius_tests4, r=nikomatsakis
Mazdak Farrokhzad [Thu, 19 Sep 2019 02:53:09 +0000 (04:53 +0200)]
Rollup merge of #64554 - lqd:polonius_tests4, r=nikomatsakis

Polonius: more `ui` test suite fixes

Since #62736, new tests have been added, and the `run-pass` suite was merged into the `ui` suite.

This PR adds the missing tests expectations for Polonius, and updates the existing ones where the NLL output has changed in some manner (e.g. ordering of notes)

Those are the trivial cases, but a more-detailed explanation is available [in this write-up](https://hackmd.io/CjYB0fs4Q9CweyeTdKWyEg?both#26-async-awaitasync-borrowck-escaping-closure-errorrs-outputs-from-NLL-Polonius-diff) starting at test case 26: they are only differing in diagnostics and instances of other existing test cases differences.

Only 3 of the 9020 tests are still "failing" at the moment (1 failure, 2 OOMs).

r? @nikomatsakis

4 years agoRollup merge of #64536 - Aaron1011:cargo-crate-type, r=ehuss
Mazdak Farrokhzad [Thu, 19 Sep 2019 02:53:08 +0000 (04:53 +0200)]
Rollup merge of #64536 - Aaron1011:cargo-crate-type, r=ehuss

Update Cargo

This pulls in https://github.com/rust-lang/cargo/pull/7159, which
ensures that documenting proc macros works correctly.

4 years agoRollup merge of #63630 - andjo403:bump_compiler, r=nikomatsakis
Mazdak Farrokhzad [Thu, 19 Sep 2019 02:53:07 +0000 (04:53 +0200)]
Rollup merge of #63630 - andjo403:bump_compiler, r=nikomatsakis

Update installed compiler dependencies

As llvm have updated the minimum toolchain
https://reviews.llvm.org/D66188

4 years agoMerge inherent impl blocks for `Diverges
Aaron Hill [Thu, 19 Sep 2019 01:57:50 +0000 (21:57 -0400)]
Merge inherent impl blocks for `Diverges

4 years agoUpdate Cargo
Aaron Hill [Mon, 16 Sep 2019 18:45:40 +0000 (14:45 -0400)]
Update Cargo

This pulls in https://github.com/rust-lang/cargo/pull/7159, which
ensures that documenting proc macros works correctly.

4 years agoAnother formatting fix
Aaron Hill [Thu, 19 Sep 2019 00:14:56 +0000 (20:14 -0400)]
Another formatting fix

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
4 years agoUse 'if let' instead of 'match'
Aaron Hill [Thu, 19 Sep 2019 00:07:33 +0000 (20:07 -0400)]
Use 'if let' instead of 'match'

4 years agoIntroduce Diverges::always constructor
Aaron Hill [Thu, 19 Sep 2019 00:04:01 +0000 (20:04 -0400)]
Introduce Diverges::always constructor

Rename the existing Diverges.always method to Diverges.is_always

4 years agoApply formatting fixes
Aaron Hill [Wed, 18 Sep 2019 23:48:37 +0000 (19:48 -0400)]
Apply formatting fixes

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
4 years agoSome formatting cleanup
Aaron Hill [Wed, 18 Sep 2019 23:31:38 +0000 (19:31 -0400)]
Some formatting cleanup

4 years agoMake note better when all arms in a `match` diverge
Aaron Hill [Wed, 18 Sep 2019 23:07:39 +0000 (19:07 -0400)]
Make note better when all arms in a `match` diverge

4 years agoRestore whitespace
James Munns [Wed, 18 Sep 2019 22:50:03 +0000 (00:50 +0200)]
Restore whitespace

4 years agoPoint at original span when emitting unreachable lint
Aaron Hill [Wed, 18 Sep 2019 22:22:13 +0000 (18:22 -0400)]
Point at original span when emitting unreachable lint

Fixes #64590

When we emit an 'unreachable' lint, we now add a note pointing at the
expression that actually causes the code to be unreachable (e.g.
`return`, `break`, `panic`).

This is especially useful when macros are involved, since a diverging
expression might be hidden inside of a macro invocation.

4 years agoFix a minor grammar nit, update UI tests
James Munns [Wed, 18 Sep 2019 22:16:16 +0000 (00:16 +0200)]
Fix a minor grammar nit, update UI tests

4 years agoAdd a specialized version of `shallow_resolve()`.
Nicholas Nethercote [Tue, 17 Sep 2019 08:05:57 +0000 (18:05 +1000)]
Add a specialized version of `shallow_resolve()`.

The super-hot call site of `inlined_shallow_resolve()` basically does
`r.inlined_shallow_resolve(ty) != ty`. This commit introduces a
version of that function specialized for that particular call pattern,
`shallow_resolve_changed()`. Incredibly, this reduces the instruction
count for `keccak` by 5%.

The commit also renames `inlined_shallow_resolve()` as
`shallow_resolve()` and removes the `inline(always)` annotation, as it's
no longer nearly so hot.

4 years agoUse explicit iteration instead of `all()` in `process_obligation()`.
Nicholas Nethercote [Tue, 17 Sep 2019 06:48:21 +0000 (16:48 +1000)]
Use explicit iteration instead of `all()` in `process_obligation()`.

Amazingly enough, this is a 3.5% instruction count win on `keccak`.

4 years agodon't record all intermediate adjustment types
Niko Matsakis [Wed, 18 Sep 2019 18:13:36 +0000 (14:13 -0400)]
don't record all intermediate adjustment types

That's way more than is needed, and winds up recording types
that will never appear in MIR.

4 years agoAuto merge of #64583 - tmandry:rollup-b793x81, r=tmandry
bors [Wed, 18 Sep 2019 17:58:45 +0000 (17:58 +0000)]
Auto merge of #64583 - tmandry:rollup-b793x81, r=tmandry

Rollup of 5 pull requests

Successful merges:

 - #64207 (Make rustc_mir::dataflow module pub (for clippy))
 - #64348 (PR: documentation spin loop hint)
 - #64532 (Replace `state_for_location` with `DataflowResultsCursor`)
 - #64578 (Fix issue22656 with LLDB 8)
 - #64580 (Update books)

Failed merges:

r? @ghost

4 years agoRollup merge of #64580 - ehuss:update-books, r=ehuss
Tyler Mandry [Wed, 18 Sep 2019 17:58:09 +0000 (10:58 -0700)]
Rollup merge of #64580 - ehuss:update-books, r=ehuss

Update books

## book

24 commits in 7ddc46460f09a5cd9bd2a620565bdc20b3315ea9..871416b85c1a73717d65d6f4a9ea29e5aef3db0e
2019-06-27 09:50:36 -0400 to 2019-09-16 09:46:20 -0400
- Ch16-2 add missing Ferris (rust-lang/book#2033)
- Update version mentioned on the front page
- Update error messages (rust-lang/book#1737)
- Update version of Rust used to 1.37
- Replace Cargo docs link with a more specific link (rust-lang/book#2066)
- Added missing await reserved keyword (rust-lang/book#2064)
- add does_not_compile for a snippet (rust-lang/book#2056)
- Added second missing dyn (rust-lang/book#2046)
- Removed unnecessary & in function call (rust-lang/book#2038)
- Printing non-Display structs is a *compile* error (rust-lang/book#2031)
- Update Readme mdBook version to match linked file (rust-lang/book#2012)
- Update loose mdbook version reference (rust-lang/book#2003)
- Added a bullet point to have list of things unsafe allows for match u… (rust-lang/book#1993)
- Rewrote a confusing sentence (rust-lang/book#1986)
- Replace deprecated `...` range syntax with `..=` (rust-lang/book#1977)
- correct wording for integration test doc (rust-lang/book#1971)
- Mark the dangle function as does_not_compile (rust-lang/book#1965)
- Add more words to the quote from the actual Go documentation (rust-lang/book#1960)
- Remove unused import in lfp (rust-lang/book#1944)
- A small typo? (rust-lang/book#1931)
- Make the code not compile to match the text (rust-lang/book#1926)
- Ferris does-not-compile added (ch9.2) (rust-lang/book#1925)
- ch07 - remove note regarding use and relative path (rust-lang/book#1820)
- tweak opening paragraph of deref coercions (rust-lang/book#1749)

## rust-by-example

9 commits in e76be6b2dc84c6a992e186157efe29d625e29b94..67cfbf31df880728dcf7cb35b15b028ec92caf31
2019-09-03 07:42:26 -0300 to 2019-09-18 09:36:40 -0300
- Fix rust-lang/rust-by-example#90: Add supertraits and Fully Qualified syntax (rust-lang/rust-by-example#1259)
- Fix some broken links. (rust-lang/rust-by-example#1258)
- Fix rust-lang/rust-by-example#1253: Document enum type aliases (rust-lang/rust-by-example#1255)
- Inline code in some new/changed chapters (rust-lang/rust-by-example#1254)
- fix rust-lang/rust-by-example#1067: explain that unit tests can return Result&lt;()&gt; (rust-lang/rust-by-example#1252)
- Fix rust-lang/rust-by-example#1060: add page on Impl Trait (rust-lang/rust-by-example#1251)
- Fix rust-lang/rust-by-example#1053: Added a page about the dyn keyword (rust-lang/rust-by-example#1249)
- Fix rust-lang/rust-by-example#1110: add examples of ? and Option (rust-lang/rust-by-example#1250)
- fix 1037: add the TryFrom chapter back in (rust-lang/rust-by-example#1247)

4 years agoRollup merge of #64578 - max-sixty:22656-lldb-8, r=alexcrichton
Tyler Mandry [Wed, 18 Sep 2019 17:58:07 +0000 (10:58 -0700)]
Rollup merge of #64578 - max-sixty:22656-lldb-8, r=alexcrichton

Fix issue22656 with LLDB 8

Closes https://github.com/rust-lang/rust/issues/64074

4 years agoRollup merge of #64532 - ecstatic-morse:dataflow-cursor-get, r=tmandry
Tyler Mandry [Wed, 18 Sep 2019 17:58:06 +0000 (10:58 -0700)]
Rollup merge of #64532 - ecstatic-morse:dataflow-cursor-get, r=tmandry

Replace `state_for_location` with `DataflowResultsCursor`

These are two different ways of getting the same data from the result of a dataflow analysis. However, `state_for_location` goes quadratic if you try to call it for every statement in the body.

4 years agoRollup merge of #64348 - arnohaase:pr_documentation_spin_loop_hint, r=alexcrichton
Tyler Mandry [Wed, 18 Sep 2019 17:58:05 +0000 (10:58 -0700)]
Rollup merge of #64348 - arnohaase:pr_documentation_spin_loop_hint, r=alexcrichton

PR: documentation spin loop hint

The documentation for 'spin loop hint' explains that yield is better if the lock holder is running on the same CPU. I suggest that 'CPU or core' would be clearer.

4 years agoRollup merge of #64207 - sinkuu:pub_dataflow, r=tmandry
Tyler Mandry [Wed, 18 Sep 2019 17:58:03 +0000 (10:58 -0700)]
Rollup merge of #64207 - sinkuu:pub_dataflow, r=tmandry

Make rustc_mir::dataflow module pub (for clippy)

I'm working on fixing false-positives of a MIR-based clippy lint (https://github.com/rust-lang/rust-clippy/pull/4509), and in need of the dataflow infrastructure.

4 years agoFix bug where `is_call_return_effect_applied` was never set
Dylan MacKenzie [Wed, 18 Sep 2019 16:22:02 +0000 (09:22 -0700)]
Fix bug where `is_call_return_effect_applied` was never set

4 years agoUpdate books
Eric Huss [Wed, 18 Sep 2019 15:54:06 +0000 (08:54 -0700)]
Update books

4 years agoAdd summary of the current state and future plans
Dylan MacKenzie [Wed, 18 Sep 2019 15:41:38 +0000 (08:41 -0700)]
Add summary of the current state and future plans

4 years agofix debuginfo/issue22656 with LLDB 8
Maximilian Roos [Wed, 18 Sep 2019 14:42:55 +0000 (10:42 -0400)]
fix debuginfo/issue22656 with LLDB 8

4 years agoPublish `rustc_mir::dataflow` and remove `#[allow(unused)]`
Dylan MacKenzie [Wed, 18 Sep 2019 14:35:44 +0000 (07:35 -0700)]
Publish `rustc_mir::dataflow` and remove `#[allow(unused)]`

4 years agoFix typo
Dylan MacKenzie [Wed, 18 Sep 2019 14:32:57 +0000 (07:32 -0700)]
Fix typo

4 years agoUse an associated const for `name`
Dylan MacKenzie [Wed, 18 Sep 2019 14:32:42 +0000 (07:32 -0700)]
Use an associated const for `name`

4 years agoFix `Analysis` example
Dylan MacKenzie [Wed, 18 Sep 2019 14:32:15 +0000 (07:32 -0700)]
Fix `Analysis` example

4 years agoAuto merge of #64575 - lzutao:fmt-primitives-doc, r=jonas-schievink
bors [Wed, 18 Sep 2019 12:31:00 +0000 (12:31 +0000)]
Auto merge of #64575 - lzutao:fmt-primitives-doc, r=jonas-schievink

doc: Format some primitives examples

r? @jonas-schievink

4 years agobroken hyperlinks in documentation
Arno Haase [Wed, 18 Sep 2019 10:31:34 +0000 (12:31 +0200)]
broken hyperlinks in documentation

4 years agodoc: Format some primitives examples
Lzu Tao [Wed, 18 Sep 2019 08:24:24 +0000 (08:24 +0000)]
doc: Format some primitives examples

4 years agoAuto merge of #64570 - tmandry:rollup-3pg02lj, r=tmandry
bors [Wed, 18 Sep 2019 04:29:01 +0000 (04:29 +0000)]
Auto merge of #64570 - tmandry:rollup-3pg02lj, r=tmandry

Rollup of 4 pull requests

Successful merges:

 - #64486 (Print out more information for `-Zunpretty=expanded,hygiene`)
 - #64503 (rename Allocation::retag -> with_tags_and_extra)
 - #64516 (update Nomicon and Reference)
 - #64528 (Load proc macro metadata in the correct order.)

Failed merges:

r? @ghost

4 years agoRollup merge of #64528 - Aaron1011:fix/proc-macro-type, r=alexcrichton
Tyler Mandry [Wed, 18 Sep 2019 04:27:26 +0000 (21:27 -0700)]
Rollup merge of #64528 - Aaron1011:fix/proc-macro-type, r=alexcrichton

Load proc macro metadata in the correct order.

Serialized proc macro metadata is assumed to have a one-to-one
correspondence with the entries in static array generated by proc_macro_harness.
However, we were previously serializing proc macro metadata in a
different order than proc macros were laied out in the static array.
This lead to us associating the wrong data with a proc macro when
generating documentation, causing Rustdoc to generate incorrect docs for
proc macros.

This commit keeps track of the order in which we insert proc macros into
the generated static array. We use this same order when serializing proc
macro metadata, ensuring that we can later associate the metadata for a
proc macro with its entry in the static array.

Fixes #64251

4 years agoRollup merge of #64516 - RalfJung:nomicon, r=Centril
Tyler Mandry [Wed, 18 Sep 2019 04:27:25 +0000 (21:27 -0700)]
Rollup merge of #64516 - RalfJung:nomicon, r=Centril

update Nomicon and Reference

Cc @Centril

4 years agoRollup merge of #64503 - RalfJung:miri-retag, r=oli-obk
Tyler Mandry [Wed, 18 Sep 2019 04:27:23 +0000 (21:27 -0700)]
Rollup merge of #64503 - RalfJung:miri-retag, r=oli-obk

rename Allocation::retag -> with_tags_and_extra

This is more consistent with `Pointer::with_tag`. Also, "retag" is a [term from Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md#retagging) with a [corresponding Machine hook](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/interpret/machine/trait.Machine.html#method.retag), and this function has nothing to do with that other use of the term.

r? @oli-obk

4 years agoRollup merge of #64486 - matthewjasper:hygiene-debugging, r=petrochenkov
Tyler Mandry [Wed, 18 Sep 2019 04:27:22 +0000 (21:27 -0700)]
Rollup merge of #64486 - matthewjasper:hygiene-debugging, r=petrochenkov

Print out more information for `-Zunpretty=expanded,hygiene`

I've found this helpful when trying to understand how hygiene works.

Closes #16420

4 years agoAdd ignore reason to placate `tidy`
Dylan MacKenzie [Wed, 18 Sep 2019 00:49:13 +0000 (17:49 -0700)]
Add ignore reason to placate `tidy`

4 years agoTemporarily add `#[allow(unused)]` for CI
Dylan MacKenzie [Wed, 18 Sep 2019 00:22:20 +0000 (17:22 -0700)]
Temporarily add `#[allow(unused)]` for CI

This can be removed once dataflow-based const validation is merged.

4 years agoDocument new dataflow analysis
Dylan MacKenzie [Wed, 18 Sep 2019 00:22:05 +0000 (17:22 -0700)]
Document new dataflow analysis

4 years agoAdd generic dataflow impl
Dylan MacKenzie [Tue, 17 Sep 2019 23:25:29 +0000 (16:25 -0700)]
Add generic dataflow impl

4 years agoGenerate proc macro harness in AST order.
Aaron Hill [Tue, 17 Sep 2019 23:07:35 +0000 (19:07 -0400)]
Generate proc macro harness in AST order.

This ensures that we match the order used by proc macro metadata
serialization.

Fixes #64251

4 years agoAuto merge of #64562 - tmandry:rollup-kfk0nuo, r=tmandry
bors [Tue, 17 Sep 2019 22:21:10 +0000 (22:21 +0000)]
Auto merge of #64562 - tmandry:rollup-kfk0nuo, r=tmandry

Rollup of 10 pull requests

Successful merges:

 - #61626 (Get rid of special const intrinsic query in favour of `const_eval`)
 - #64283 (Updated RELEASES.md for 1.38.0)
 - #64394 (Shrink `SubregionOrigin`.)
 - #64429 (Fix failure note `to_str` implementation)
 - #64436 (improve Vec example soundness in mem::transmute docs)
 - #64502 (avoid duplicate issues for Miri build failures)
 - #64505 (Fix inconsistent link formatting)
 - #64529 (Add an example to Pin::as_mut)
 - #64541 (document Miri error categories)
 - #64544 (build-manifest: re-add some comments)

Failed merges:

r? @ghost

4 years agoRollup merge of #64544 - RalfJung:build-manifest, r=pietroalbini
Tyler Mandry [Tue, 17 Sep 2019 21:10:56 +0000 (14:10 -0700)]
Rollup merge of #64544 - RalfJung:build-manifest, r=pietroalbini

build-manifest: re-add some comments

https://github.com/rust-lang/rust/pull/64543 also reverted the comments I added. This adds them back.
Includes https://github.com/rust-lang/rust/pull/64543.

r? @pietroalbini

4 years agoRollup merge of #64541 - RalfJung:miri-errors, r=oli-obk
Tyler Mandry [Tue, 17 Sep 2019 21:10:55 +0000 (14:10 -0700)]
Rollup merge of #64541 - RalfJung:miri-errors, r=oli-obk

document Miri error categories

r? @oli-obk

4 years agoRollup merge of #64529 - taiki-e:docs-pin-as-mut, r=RalfJung
Tyler Mandry [Tue, 17 Sep 2019 21:10:54 +0000 (14:10 -0700)]
Rollup merge of #64529 - taiki-e:docs-pin-as-mut, r=RalfJung

Add an example to Pin::as_mut

https://github.com/taiki-e/pin-project/issues/89#issuecomment-531701172

r? @RalfJung

4 years agoRollup merge of #64505 - pickfire:patch-1, r=Mark-Simulacrum
Tyler Mandry [Tue, 17 Sep 2019 21:10:52 +0000 (14:10 -0700)]
Rollup merge of #64505 - pickfire:patch-1, r=Mark-Simulacrum

Fix inconsistent link formatting

4 years agoRollup merge of #64502 - RalfJung:miri-toolstate, r=pietroalbini
Tyler Mandry [Tue, 17 Sep 2019 21:10:51 +0000 (14:10 -0700)]
Rollup merge of #64502 - RalfJung:miri-toolstate, r=pietroalbini

avoid duplicate issues for Miri build failures

Currently, when Miri regressed from test-pass to test-fail, we pen an issue -- and then when it regresses further from test-fail to build-fail, we open a *second* issue.

This changes the logic to avoid the redundant second issue for Miri.

r? @pietroalbini @kennytm

4 years agoRollup merge of #64436 - llogiq:transmute-docs, r=RalfJung
Tyler Mandry [Tue, 17 Sep 2019 21:10:50 +0000 (14:10 -0700)]
Rollup merge of #64436 - llogiq:transmute-docs, r=RalfJung

improve Vec example soundness in mem::transmute docs

The previous version of the `Vec` example had a case of questionable soundness, because at one point `v_orig` was aliased.

r? @RalfJung

4 years agoRollup merge of #64429 - afnanenayet:afnan/fix-failure-note-json-level, r=Mark-Simulacrum
Tyler Mandry [Tue, 17 Sep 2019 21:10:48 +0000 (14:10 -0700)]
Rollup merge of #64429 - afnanenayet:afnan/fix-failure-note-json-level, r=Mark-Simulacrum

Fix failure note `to_str` implementation

Serialize the level to something a little more useful for a failure note struct. This fixes #60425.

4 years agoRollup merge of #64394 - nnethercote:shrink-SubregionOrigin, r=Mark-Simulacrum
Tyler Mandry [Tue, 17 Sep 2019 21:10:47 +0000 (14:10 -0700)]
Rollup merge of #64394 - nnethercote:shrink-SubregionOrigin, r=Mark-Simulacrum

Shrink `SubregionOrigin`.

It's currently 120 bytes on x86-64, due to one oversized variant
(`Subtype`). This commit boxes `Subtype`'s contents, reducing the size
of `SubregionOrigin` to 32 bytes.

The change speeds things up by avoiding lots of `memcpy` calls, mostly
relating to `RegionConstraintData::constraints`, which is a `BTreeMap`
with `SubregionOrigin` values.

4 years agoRollup merge of #64283 - XAMPPRocky:master, r=Mark-Simulacrum
Tyler Mandry [Tue, 17 Sep 2019 21:10:45 +0000 (14:10 -0700)]
Rollup merge of #64283 - XAMPPRocky:master, r=Mark-Simulacrum

Updated RELEASES.md for 1.38.0

### [Rendered](https://github.com/XAMPPRocky/rust/blob/master/RELEASES.md)

r? @Mark-Simulacrum
cc @rust-lang/release

4 years agoRollup merge of #61626 - oli-obk:const_eval_intrinsics, r=eddyb
Tyler Mandry [Tue, 17 Sep 2019 21:10:44 +0000 (14:10 -0700)]
Rollup merge of #61626 - oli-obk:const_eval_intrinsics, r=eddyb

Get rid of special const intrinsic query in favour of `const_eval`

r? @eddyb

4 years agoupdate Nomicon and Reference
Ralf Jung [Tue, 17 Sep 2019 20:28:49 +0000 (22:28 +0200)]
update Nomicon and Reference

4 years agoPrint syntax contexts and marks when printing hygiene information
Matthew Jasper [Sun, 14 Jul 2019 20:17:37 +0000 (21:17 +0100)]
Print syntax contexts and marks when printing hygiene information

4 years agoAuto merge of #64525 - nikomatsakis:issue-64512-drop-order-tail-temp, r=davidtwco
bors [Tue, 17 Sep 2019 18:23:30 +0000 (18:23 +0000)]
Auto merge of #64525 - nikomatsakis:issue-64512-drop-order-tail-temp, r=davidtwco

adjust desugaring for async fn to correct drop order

Old desugaring, given a user function body `{ $stmts; $expr }`

```
{
    let $param_pattern0 = $raw_param0;
    ...
    let $param_patternN = $raw_paramN;
    $stmts;
    $expr
}
```

New desugaring:

```
{
    let $param_pattern0 = $raw_param0;
    ...
    let $param_patternN = $raw_paramN;
    drop-temps {
        $stmts;
        $expr
    }
}
```

The drop-temps is an internal bit of HIR that drops temporaries from the resulting expression, but it should be equivalent to `return { $stmts; $expr }`.

Fixes #64512
Fixes #64391