Commit Graph

100007 Commits

Author SHA1 Message Date
Tyler Mandry
bd9d843ae4
Rollup merge of #64801 - nnethercote:improve-find_constraint_paths_between_regions, r=estebank
Avoid `chain()` in `find_constraint_paths_between_regions()`.

This iterator can be hot, and chained iterators are slow. The second
half of the chain is almost always empty, so this commit specializes the
code to avoid the chained iteration.

This change reduces instruction counts for the `wg-grammar` benchmark by
up to 1.5%.
2019-10-01 23:06:12 -07:00
Tyler Mandry
65a050fddc
Rollup merge of #64722 - Mark-Simulacrum:alt-parallel, r=alexcrichton
Make all alt builders produce parallel-enabled compilers

We're not quite ready to ship parallel compilers by default, but the alt
builders are not used too much (in theory), so we believe that shipping
a possibly-broken compiler there is not too problematic.

r? @nikomatsakis
2019-10-01 23:06:11 -07:00
Tyler Mandry
c11cb25262
Rollup merge of #64649 - estebank:returnator, r=varkor
Avoid ICE on return outside of fn with literal array

Do not ICE when encountering `enum E { A = return [0][0] }`.

Fix #64638.
2019-10-01 23:06:09 -07:00
Dylan MacKenzie
33aa5e855e Add test exposing unsoundness in IndirectlyMutableLocals 2019-10-01 22:16:15 -07:00
Dylan MacKenzie
767550ef0f Add rustc_peek support for IndirectlyMutableLocals 2019-10-01 20:29:57 -07:00
Dylan MacKenzie
f18535fa46 Refactor rustc_peek
We now use `DataflowResultsCursor` to get the dataflow state before
calls to `rustc_peek`. The original version used a custom implementation
that only looked at assignment statements. This also extends
`rustc_peek` to take arguments by-value as well as by-reference, and
allows *all* dataflow analyses, not just those dependent on `MoveData`,
to be inspected.
2019-10-01 20:28:08 -07:00
Eric Huss
04427b159d Update books 2019-10-01 19:35:13 -07:00
bors
ff191b54cc Auto merge of #64963 - Manishearth:clippyup, r=Manishearth
Update clippy

r? @ghost
2019-10-02 02:01:20 +00:00
Aaron Hill
ba54ef8110
Add comments, rename variable 2019-10-01 21:44:13 -04:00
Aaron Hill
9c5a5c471a
Rename to was_placeholder to from_forall 2019-10-01 21:39:19 -04:00
Aaron Hill
1caa6dc546
Fixup tests 2019-10-01 21:22:46 -04:00
AnthonyMikh
bd7cd80299
Fully clear HandlerInner in Handler::reset_err_count 2019-10-02 04:13:02 +03:00
Manish Goregaokar
56b269af74 Update clippy 2019-10-01 17:53:57 -07:00
Aaron Hill
1245467322
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-01 19:47:28 -04:00
Charles Gleason
7b480cdec6 Implement Clone::clone_from for LinkedList 2019-10-01 18:23:08 -04:00
Dylan MacKenzie
ffc52a7fe6 Update example table to match current output 2019-10-01 15:23:04 -07:00
Dylan MacKenzie
161123898f Reset row background for each block
Now the first row of each basic block is always light instead of
changing seemingly at random.
2019-10-01 15:21:58 -07:00
Dylan MacKenzie
cf984d22d6 This needs to be build-pass since it involves debuginfo 2019-10-01 15:10:29 -07:00
Dylan MacKenzie
242702965b Fix typo passing flags to rustc 2019-10-01 15:09:53 -07:00
bors
7130fc54e0 Auto merge of #64972 - Centril:rollup-gcawast, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #63416 (apfloat: improve doc comments)
 - #64820 (BTreeSet intersection, is_subset & difference optimizations)
 - #64910 (syntax: cleanup param, method, and misc parsing)
 - #64912 (Remove unneeded `fn main` blocks from docs)
 - #64933 (Fixes #64919. Suggest fix based on operator precendence.)
 - #64943 (Add lower bound doctests for `saturating_{add,sub}` signed ints)
 - #64950 (Simplify interners)

Failed merges:

r? @ghost
2019-10-01 22:04:23 +00:00
Alex Crichton
8d9abcd870 Update rls submodule 2019-10-01 15:03:25 -07:00
Alex Crichton
4447388f17 Update Cargo.lock for cargo update 2019-10-01 15:02:45 -07:00
Dylan MacKenzie
4eeedd0953 Add test cases for #64945
This also tests that `&&[]` no longer causes an ICE in this PR (although
the test fails the borrow checker). This could be more complete.
2019-10-01 14:59:16 -07:00
Mazdak Farrokhzad
adc0dc5871
Rollup merge of #64950 - nnethercote:simplify-interners, r=varkor,spastorino
Simplify interners

Some code readability improvements.
2019-10-01 23:56:27 +02:00
Mazdak Farrokhzad
66148f6393
Rollup merge of #64943 - lzutao:doc-saturating, r=shepmaster
Add lower bound doctests for `saturating_{add,sub}` signed ints

Closes #64940
2019-10-01 23:56:26 +02:00
Mazdak Farrokhzad
67cbeee9ee
Rollup merge of #64933 - sam09:master, r=estebank
Fixes #64919. Suggest fix based on operator precendence.

Fixes https://github.com/rust-lang/rust/issues/64919
2019-10-01 23:56:24 +02:00
Mazdak Farrokhzad
7628cada4f
Rollup merge of #64912 - lzutao:unneeded-main-doc, r=jonas-schievink
Remove unneeded `fn main` blocks from docs

## [No whitespace diff](https://github.com/rust-lang/rust/pull/64912/files?w=1)
2019-10-01 23:56:23 +02:00
Mazdak Farrokhzad
db9689333a
Rollup merge of #64910 - Centril:params-cleanup, r=petrochenkov
syntax: cleanup param, method, and misc parsing

Do some misc cleanup of the parser:
- Method and parameter parsing is refactored.
- A parser for `const | mut` is introduced that https://github.com/rust-lang/rust/pull/64588 can reuse.
- Some other misc parsing.

Next up in a different PR:
- ~Implementing https://github.com/rust-lang/rust/issues/64252.~ -- maybe some other time...
- Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^).

r? @petrochenkov
2019-10-01 23:56:21 +02:00
Mazdak Farrokhzad
69028ae85b
Rollup merge of #64820 - ssomers:master, r=bluss
BTreeSet intersection, is_subset & difference optimizations

...based on the range of values contained; in particular, a massive improvement when these ranges are disjoint (or merely touching), like in the neg-vs-pos benchmarks already in liballoc. Inspired by #64383 but none of the ideas there worked out.

I introduced another variant in IntersectionInner and in DifferenceInner, because I couldn't find a way to initialize these iterators as empty if there's no empty set around.

Also, reduced the size of "large" sets in test cases - if Miri can't handle it, it was needlessly slowing down everyone.
2019-10-01 23:56:20 +02:00
Mazdak Farrokhzad
baba6284bf
Rollup merge of #63416 - RalfJung:apfloat, r=eddyb
apfloat: improve doc comments

r? @eddyb @nagisa
2019-10-01 23:56:16 +02:00
Dylan MacKenzie
8d84646c7b Don't mark zero-sized arrays as indirectly mutable when borrowed 2019-10-01 12:05:14 -07:00
Dylan MacKenzie
a1ad38f99c Pass attrs to do_dataflow in new const checker
This is needed to dump graphviz results for the `IndirectlyMutableLocals` analysis.
2019-10-01 11:35:50 -07:00
Alex Zatelepin
75fdb95932 change .node -> .kind after rebase 2019-10-01 20:04:41 +03:00
Santiago Pastorino
738baa734b
Update src/librustc/ty/mod.rs
Co-Authored-By: Oliver Scherer <github35764891676564198441@oli-obk.de>
2019-10-01 13:03:33 -03:00
Santiago Pastorino
6acdea4336
Make comment about dummy type a bit more clear 2019-10-01 12:51:15 -03:00
Alex Zatelepin
cb4ed52fd0 fix test after rebase 2019-10-01 17:49:19 +03:00
Alex Zatelepin
ffa526937e address review comments 2019-10-01 17:49:19 +03:00
Alex Zatelepin
c474c6e825 add tests 2019-10-01 17:48:37 +03:00
Alex Zatelepin
057569e2c2 fix spurious unreachable_code lints for try{} block ok-wrapping 2019-10-01 17:48:37 +03:00
Alex Zatelepin
48081065f4 fix typo 2019-10-01 17:44:24 +03:00
Yuki Okushi
f10d2e2d23 Fix clippy warnings 2019-10-01 23:15:47 +09:00
Felix S. Klock II
9fe138aa43 regression test for 64453 borrow check error. 2019-10-01 15:57:27 +02:00
Stein Somers
d132a70bf4 BTreeSet intersection, difference & is_subnet optimizations 2019-10-01 15:50:11 +02:00
Lzu Tao
6c1b447f2e Remove unneeded fn main blocks from docs 2019-10-01 11:55:46 +00:00
Michael Woerister
e1d9f82605 Update cargo. 2019-10-01 13:53:17 +02:00
Sam Radhakrishnan
9e4eb46790 Change to use exprPrecedence instead of exprKind. 2019-10-01 05:00:22 -04:00
Guillaume Gomez
4aa526f809 Improve sidebar styling to make its integration easier 2019-10-01 10:32:45 +02:00
bors
702b45e409 Auto merge of #64946 - Centril:rollup-66mj5o0, r=Centril
Rollup of 10 pull requests

Successful merges:

 - #63674 (syntax: Support modern attribute syntax in the `meta` matcher)
 - #63931 (Stabilize macros in some more positions)
 - #64887 (syntax: recover trailing `|` in or-patterns)
 - #64895 (async/await: improve not-send errors)
 - #64896 (Remove legacy grammar)
 - #64907 (A small amount of tidying-up factored out from PR #64648)
 - #64928 (Add tests for some issues)
 - #64930 (Silence unreachable code lint from await desugaring)
 - #64935 (Improve code clarity)
 - #64937 (Deduplicate closure type errors)

Failed merges:

r? @ghost
2019-10-01 07:56:52 +00:00
Mazdak Farrokhzad
46bf6ad416
Rollup merge of #64937 - estebank:dedup-closure-err, r=Centril
Deduplicate closure type errors

Closure typing obligations flow in both direcitons to properly infer
types. Because of this, we will get 2 type errors whenever there's
an unfulfilled obligation. To avoid this, we deduplicate them in the
`InferCtxt`.
2019-10-01 09:55:39 +02:00
Mazdak Farrokhzad
5c6a8ee9dd
Rollup merge of #64935 - AnthonyMikh:librustc_errors/emmiter__code-clarity, r=estebank
Improve code clarity

No commit except 55b54285c8 address performance, just making the existing code more clear.

r? @estebank
2019-10-01 09:55:38 +02:00