Commit Graph

100061 Commits

Author SHA1 Message Date
Mazdak Farrokhzad 314fbf48cf Rollup merge of #64749 - matthewjasper:liveness-opt, r=nikomatsakis
Fix most remaining Polonius test differences

This fixes most of the Polonius test differences and also avoids overflow in issue-38591.rs.

r? @nikomatsakis
2019-10-04 07:24:33 +02:00
bors 31d75c4e9c Auto merge of #65076 - tmandry:rollup-ka7nzb6, r=tmandry
Rollup of 11 pull requests

Successful merges:

 - #61879 (Stabilize todo macro)
 - #64675 (Deprecate `#![plugin]` & `#[plugin_registrar]`)
 - #64690 (proc_macro API: Expose `macro_rules` hygiene)
 - #64706 (add regression test for #60218)
 - #64741 (Prevent rustdoc feature doctests)
 - #64842 (Disallow Self in type param defaults of ADTs)
 - #65004 (Replace mentions of IRC with Discord)
 - #65018 (Set RUST_BACKTRACE=0 in tests that include a backtrace in stderr)
 - #65055 (Add long error explanation for E0556)
 - #65056 (Make visit projection iterative)
 - #65057 (typo: fix typo in E0392)

Failed merges:

r? @ghost
2019-10-03 23:29:48 +00:00
Tyler Mandry cc5dcfaada Rollup merge of #65057 - mathstuf:fix-warning-typo, r=Centril
typo: fix typo in E0392

See #64931.

---
Cc: @Centril @estebank
2019-10-03 16:25:51 -07:00
Tyler Mandry 4a25c3c1ec Rollup merge of #65056 - spastorino:place-mut-visitor-adjusts, r=oli-obk
Make visit projection iterative

r? @oli-obk

/cc @nikomatsakis
2019-10-03 16:25:49 -07:00
Tyler Mandry dd9ccb20fc Rollup merge of #65055 - GuillaumeGomez:long-err-explanation-E0556, r=petrochenkov
Add long error explanation for E0556

Part of #61137
2019-10-03 16:25:47 -07:00
Tyler Mandry 211bc4a687 Rollup merge of #65018 - Aaron1011:fix/backtrace-stderr, r=nikomatsakis
Set RUST_BACKTRACE=0 in tests that include a backtrace in stderr

This removes the implicit dependency on the environment variables set
when running `./x.py test`
2019-10-03 16:25:46 -07:00
Tyler Mandry 4886f35537 Rollup merge of #65004 - BO41:mentions, r=alexcrichton
Replace mentions of IRC with Discord

Revival of #61531

closes #61524

what was the outcome of this? https://github.com/rust-lang/rust/pull/61531#issuecomment-500452638

should this be changed in this PR as well? https://github.com/rust-lang/rust/pull/61531#issuecomment-501473787
2019-10-03 16:25:44 -07:00
Tyler Mandry 27c90524a0 Rollup merge of #64842 - pnkfelix:fix-issue-61631-self-in-type-param-default, r=alexreg
Disallow Self in type param defaults of ADTs

Fix #61631

(also includes a drive-by fix to a typo in some related diagnostic output.)
2019-10-03 16:25:43 -07:00
Tyler Mandry 69837b14d6 Rollup merge of #64741 - GuillaumeGomez:prevent-rustdoc-feature-doctests, r=QuietMisdreavus
Prevent rustdoc feature doctests

Part of https://github.com/rust-lang/rust/pull/61351

cc @ollie27
2019-10-03 16:25:41 -07:00
Tyler Mandry c6999a5834 Rollup merge of #64706 - nikomatsakis:issue-60218-test-case, r=centril
add regression test for #60218

Fixes #60218
2019-10-03 16:25:40 -07:00
Tyler Mandry 2a9bd75994 Rollup merge of #64690 - petrochenkov:mixed, r=dtolnay
proc_macro API: Expose `macro_rules` hygiene

Proc macros do not have direct access to our oldest and most stable hygiene kind - `macro_rules` hygiene.

To emulate it macro authors have to go through two steps - first generate a temporary `macro_rules` item (using a derive, at least until https://github.com/rust-lang/rust/pull/64035 is merged), then generate a macro call to that item. Popular crates like [proc_macro_hack](https://crates.io/crates/proc-macro-hack) use this trick to generate hygienic identifiers from proc macros.

I'd say that these workarounds with nested macro definitions have more chances to hit some corner cases in our hygiene system, in which we don't have full confidence.
So, let's provide a direct access to `macro_rules` hygiene instead.

This PR does that by adding a new method `Span::mixed_site` (bikeshedding is welcome) in addition to existing `Span::call_site` (stable) and `Span::def_site` (unstable).
Identifiers with this span resolve at def-site in for local variables, labels and `$crate`, and resolve at call-site for everything else, i.e. exactly like identifiers produced by `macro_rules`.

This API addition opens the way to stabilizing proc macros in expression positions (https://github.com/rust-lang/rust/issues/54727), for which use of call-site hygiene or workarounds with temporary items would be quite unfortunate.
(`macro_rules` expanded in expression position, on the other hand, are stable since 1.0 and widely used.)

r? @dtolnay @alexcrichton
2019-10-03 16:25:39 -07:00
Tyler Mandry da0afc1638 Rollup merge of #64675 - Centril:deprecate-plugin, r=oli-obk
Deprecate `#![plugin]` & `#[plugin_registrar]`

This PR deprecates `#![plugin]` and `#[plugin_registrar]`.

~A removal deadline is set: 1.44.0. This will be in 9 months from now and should give everyone who is still relying on the feature ample time to rid themselves of this dependency.~

cc https://github.com/rust-lang/rust/issues/29597

r? @Mark-Simulacrum
2019-10-03 16:25:37 -07:00
Tyler Mandry f7ee31e3d7 Rollup merge of #61879 - stjepang:stabilize-todo, r=withoutboats
Stabilize todo macro

The `todo!` macro is just another name for `unimplemented!`.

Tracking issue: https://github.com/rust-lang/rust/issues/59277

This PR needs a FCP to merge.

r? @withoutboats
2019-10-03 16:25:35 -07:00
Felix S. Klock II e443e1bdf9 Regression tests.
Update: incorporate review feedback.
2019-10-03 20:21:55 +02:00
bors 032a53a06c Auto merge of #64938 - estebank:ice-ice-baby, r=matthewjasper
Avoid ICE on ReFree region on where clause

Fix #64855.
2019-10-03 16:14:32 +00:00
Santiago Pastorino b9ed64268d Make visit_projection iterative 2019-10-03 11:19:26 -03:00
Ben Boeckel 126bf3b1dd typo: fix typo in E0392
See #64931.
2019-10-03 09:22:29 -04:00
bors cfb6d84720 Auto merge of #64999 - nikomatsakis:issue-60424-async-return-inference, r=cramertj
extract expected return type for async fn generators

Fixes #60424

cc @Centril, I know you've been eager to see this fixed.

r? @cramertj
2019-10-03 12:19:21 +00:00
Guillaume Gomez 1d49f9a10a update ui tests 2019-10-03 14:11:39 +02:00
Guillaume Gomez e86af1bbeb Add long error explanation for E0556 2019-10-03 14:11:31 +02:00
Felix S. Klock II a18d424c48 Allocate a new diagnostic for defaulted type parameters cannot use Self
(Without this commit, you still get an error (a very similar one, at
that), but it complains about use of forward declaration, which is
confusing since people do not necessarily think of `Self` as being
declared at all.)

Update: incorporate review feedback.
2019-10-03 13:54:27 +02:00
Felix S. Klock II 3a4921cde1 The crux of the bug fix.
Update: review feedback
Update: placate tidy
2019-10-03 13:54:07 +02:00
Niko Matsakis 4396a1ccd4 add regression test for #60218 2019-10-03 05:59:18 -04:00
Vadim Petrochenkov d1310dc6c9 proc_macro: Add Span::mixed_site exposing macro_rules hygiene 2019-10-03 11:28:06 +03:00
Niko Matsakis a807032f9e ./x.py test --bless --compare-mode=nll 2019-10-03 04:20:51 -04:00
Mazdak Farrokhzad d1f95ef3c5 --bless ui-fulldeps tests 2019-10-03 09:33:28 +02:00
bors 0221e26562 Auto merge of #65045 - Centril:rollup-djvi539, r=Centril
Rollup of 2 pull requests

Successful merges:

 - #64941 (Inline `{min,max}_value` even in debug builds)
 - #65002 (Update llvm-project submodule)

Failed merges:

r? @ghost
2019-10-03 06:05:08 +00:00
Mazdak Farrokhzad 64ac499db5 Rollup merge of #65002 - alexcrichton:update-lvlm, r=nikic
Update llvm-project submodule

Bring in rust-lang/llvm-project#24 which brings in some wasm
improvements related to the bulk-memory proposal
2019-10-03 08:04:34 +02:00
Mazdak Farrokhzad b131230c3b Rollup merge of #64941 - lzutao:inline-max_min_value, r=nnethercote
Inline `{min,max}_value` even in debug builds

I think it is worth to inline `{min,max}_value` even in debug builds.
See this godbolt link: https://godbolt.org/z/-COkVS
2019-10-03 08:04:33 +02:00
Mazdak Farrokhzad 1b8ec975fc plugin_registrary: use normal deprecation instead of hard coded warning. 2019-10-03 07:03:01 +02:00
Mazdak Farrokhzad 287ceed469 Deprecate #![plugin] and #[plugin_registrar]. 2019-10-03 06:46:52 +02:00
Santiago Pastorino a8d70d1b4a Add visit_projection_elem method to visitors 2019-10-03 00:54:45 -03:00
bors c6293e3598 Auto merge of #65038 - Centril:rollup-m83dpfh, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #63678 (Improve HRTB error span when -Zno-leak-check is used)
 - #64931 (Reword E0392 slightly)
 - #64959 (syntax: improve parameter without type suggestions)
 - #64975 (Implement Clone::clone_from for LinkedList)
 - #64993 (BacktraceStatus: add Eq impl)
 - #64998 (Filter out RLS output directories on tidy runs)
 - #65010 (Compare `primary` with maximum of `children`s' line num instead of dropping it)

Failed merges:

r? @ghost
2019-10-03 02:08:53 +00:00
Mazdak Farrokhzad d5a0765f44 Rollup merge of #65010 - AnthonyMikh:fix_65001, r=estebank
Compare `primary` with maximum of `children`s' line num instead of dropping it

Fix #65001.
2019-10-03 04:08:19 +02:00
Mazdak Farrokhzad 4ea2be751c Rollup merge of #64998 - spastorino:filter-rls-on-tidy, r=petrochenkov
Filter out RLS output directories on tidy runs

Closes #64957

r? @petrochenkov
2019-10-03 04:08:18 +02:00
Mazdak Farrokhzad f188879a93 Rollup merge of #64993 - mathstuf:backtrace-status-eq, r=withoutboats
BacktraceStatus: add Eq impl

See discussion on #53487.

---
Is adding `Copy` too ambitious? It's a "status", so I don't forsee any non-POD data that might go in there, but it would restrict future variants more than `Eq` does.

Cc: @withoutboats @abonander
2019-10-03 04:08:17 +02:00
Mazdak Farrokhzad c4f8fd2bf5 Rollup merge of #64975 - crgl:clone-from-linked-list, r=bluss
Implement Clone::clone_from for LinkedList

See #28481. This represents a substantial speedup when the list sizes are comparable, and shouldn't ever be significantly worse. Technically split_off is doing an unnecessary search, but the code is hopefully cleaner as a result. I'm happy to rework anything that needs to be changed as well!
2019-10-03 04:08:15 +02:00
Mazdak Farrokhzad faf2e8087c Rollup merge of #64959 - davidtwco:issue-64252-self-type-help, r=Centril,estebank
syntax: improve parameter without type suggestions

Fixes #64252.

This PR improves the suggestions provided when function parameters
do not have types:

- A new suggestion is added for arbitrary self types, which suggests
adding `self: ` before the type.

- Existing suggestions are now provided when a `<` is found where a `:`
was expected (previously only `,` and `)` or trait items), this gives
suggestions in the case where the unnamed parameter type is generic
in a free function.

- The suggestion that a type name be provided (e.g. `fn foo(HashMap<u32>)`
-> `fn foo(HashMap: TypeName<u32>)`) will no longer occur when a `<` was
found instead of `:`.

- The ident will not be used for recovery when a `<` was found instead
of `:`.

r? @Centril
cc @estebank @yoshuawuyts
2019-10-03 04:08:14 +02:00
Mazdak Farrokhzad 17b1fd1a8f Rollup merge of #64931 - estebank:missing-param-ref, r=matthewjasper,Centril
Reword E0392 slightly

Make it clearer that a type or lifetime argument not being used can be
fixed by referencing it in a struct's fields, not just using `PhathomData`.

CC #53589.
2019-10-03 04:08:12 +02:00
Mazdak Farrokhzad 3e15e51acd Rollup merge of #63678 - Aaron1011:fix/hrtb-leak, r=nikomatsakis
Improve HRTB error span when -Zno-leak-check is used

As described in #57374, NLL currently produces unhelpful higher-ranked
trait bound (HRTB) errors when '-Zno-leak-check' is enabled.

This PR tackles one half of this issue - making the error message point
at the proper span. The error message itself is still the very generic
"higher-ranked subtype error", but this can be improved in a follow-up
PR.

The root cause of the bad spans lies in how NLL attempts to compute the
'blamed' region, for which it will retrieve a span for.
Consider the following code, which (correctly) does not compile:

```rust
let my_val: u8 = 25;
let a: &u8 = &my_val;
let b = a;
let c = b;
let d: &'static u8 = c;
```

This will cause NLL to generate the following subtype constraints:

d :< c
c :< b
b <: a

Since normal Rust lifetimes are covariant, this results in the following
region constraints (I'm using 'd to denote the lifetime of 'd',
'c to denote the lifetime of 'c, etc.):

'c: 'd
'b: 'c
'a: 'b

From this, we can derive that 'a: 'd holds, which implies that 'a: 'static
must hold. However, this is not the case, since 'a refers to 'my_val',
which does not outlive the current function.

When NLL attempts to infer regions for this code, it will see that the
region 'a has grown 'too large' - it will be inferred to outlive
'static, despite the fact that is not declared as outliving 'static
We can find the region responsible, 'd, by starting at the *end* of
the 'constraint chain' we generated above. This works because for normal
(non-higher-ranked) lifetimes, we generally build up a 'chain' of
lifetime constraints *away* from the original variable/lifetime.
That is, our original lifetime 'a is required to outlive progressively
more regions. If it ends up living for too long, we can look at the
'end' of this chain to determine the 'most recent' usage that caused
the lifetime to grow too large.

However, this logic does not work correctly when higher-ranked trait
bounds (HRTBs) come into play. This is because HRTBs have
*contravariance* with respect to their bound regions. For example,
this code snippet compiles:

```rust
let a: for<'a> fn(&'a ()) = |_| {};
let b: fn(&'static ()) = a;
```

Here, we require that 'a' is a subtype of 'b'. Because of
contravariance, we end up with the region constraint 'static: 'a,
*not* 'a: 'static

This means that our 'constraint chains' grow in the opposite direction
of 'normal lifetime' constraint chains. As we introduce subtypes, our
lifetime ends up being outlived by other lifetimes, rather than
outliving other lifetimes. Therefore, starting at the end of the
'constraint chain' will cause us to 'blame' a lifetime close to the original
definition of a variable, instead of close to where the bad lifetime
constraint is introduced.

This PR improves how we select the region to blame for 'too large'
universal lifetimes, when bound lifetimes are involved. If the region
we're checking is a 'placeholder' region (e.g. the region 'a' in
for<'a>, or the implicit region in fn(&())), we start traversing the
constraint chain from the beginning, rather than the end.

There are two (maybe more) different ways we generate region constraints for NLL:
requirements generated from trait queries, and requirements generated
from MIR subtype constraints. While the former always use explicit
placeholder regions, the latter is more tricky. In order to implement
contravariance for HRTBs, TypeRelating replaces placeholder regions with
existential regions. This requires us to keep track of whether or not an
existential region was originally a placeholder region. When we look for
a region to blame, we check if our starting region is either a
placeholder region or is an existential region created from a
placeholder region. If so, we start iterating from the beginning of the
constraint chain, rather than the end.
2019-10-03 04:08:11 +02:00
Esteban Küber de815653ed review comments 2019-10-02 16:19:35 -07:00
Niko Matsakis 19c07cc2b2 fix example (le sigh) 2019-10-02 18:45:44 -04:00
Niko Matsakis 4a49351e8b add unsize slice-str coercion 2019-10-02 18:13:40 -04:00
Esteban Küber a180294f8b review comment 2019-10-02 14:34:29 -07:00
Matthew Jasper 2180c24321 Make lifetimes in constants live at the point of use 2019-10-02 20:39:01 +01:00
Matthew Jasper 08a60ac6ed Calculate liveness for the same locals with and without -Zpolonius
This fixes some test differences and also avoids overflow in
issue-38591.rs.
2019-10-02 20:39:01 +01:00
Aaron Hill a336536a01 Set RUST_BACKTRACE=0 in tests that include a backtrace in stderr
This removes the implicit dependency on the environment variables set
when running `./x.py test`
2019-10-02 15:23:22 -04:00
Charles Gleason 864e6feaf8 Add test for LinkedList clone_from 2019-10-02 15:18:31 -04:00
Niko Matsakis a96bce7c06 avoid using skip_binder and instead look for bound vars properly 2019-10-02 15:07:38 -04:00
Esteban Küber a5cfc4011d Avoid ICE on ReFree region from malformed code 2019-10-02 11:39:46 -07:00