Commit Graph

96145 Commits

Author SHA1 Message Date
Niko Matsakis
e6b6873525 switch to Lrc 2019-07-02 12:25:22 -04:00
Niko Matsakis
fb2c997d4e fix silly bugs in binary_search_util test 2019-07-02 12:25:22 -04:00
Niko Matsakis
5d44bebb32 bless test output 2019-07-02 12:25:21 -04:00
Niko Matsakis
adba6a8f90 address nits by mattewjasper 2019-07-02 12:25:21 -04:00
Niko Matsakis
0b15a66a80 account for the pick-constraint edges when reporting errors
Also, thread through better span info to improve the error message to
something tolerable.
2019-07-02 12:25:21 -04:00
Niko Matsakis
3e01c7416a just create a binary search slice helper fn 2019-07-02 12:25:16 -04:00
Niko Matsakis
89a205bf44 add a VecMap data structure 2019-07-02 12:15:21 -04:00
Niko Matsakis
e9de08a5ea test with explicit existential type 2019-07-02 12:15:21 -04:00
Niko Matsakis
b170c0f1c4 add a preliminary existential test; not really enough 2019-07-02 12:15:21 -04:00
Niko Matsakis
a18c779fa2 pacify the mercilous tidy
long lines, trailing newlines
2019-07-02 12:15:21 -04:00
Niko Matsakis
4831146afa remove outdated TODO markers
These were left behind to remind me to cleanup the code -- but the
relevant cleanups were already done.
2019-07-02 12:15:21 -04:00
Niko Matsakis
2ea6094938 explain why pick-constraints can be an empty vector 2019-07-02 12:15:21 -04:00
Niko Matsakis
4de99600b0 add a FIXME related to the non-free-region case
I don't think it would actually be harmful to just ignore such cases
but I'm inclined not to take chances.
2019-07-02 12:15:21 -04:00
Niko Matsakis
2057136326 update the async-fn-multiple-lifetimes test 2019-07-02 12:15:20 -04:00
Niko Matsakis
b5fb906766 fix tests and remove outdated stderr files 2019-07-02 12:15:20 -04:00
Niko Matsakis
8d39bdd5f9 integrate reverse graph and upper-bound computation 2019-07-02 12:15:20 -04:00
Niko Matsakis
7fd0db7dd3 add a depth_first_search helper function 2019-07-02 12:15:20 -04:00
Niko Matsakis
4c91bb9571 introduce a VecGraph abstraction that cheaply stores graphs
This is perhaps better than the linked list approach I was using
before. Lower memory overhead, Theta(N+E) storage. Does require a
sort. =)
2019-07-02 12:15:20 -04:00
Niko Matsakis
4e85665e08 implement the graph traits for SCC 2019-07-02 12:15:20 -04:00
Niko Matsakis
07ee532031 improve tests with migration mode, mir mode 2019-07-02 12:15:20 -04:00
Niko Matsakis
cc581bfa0e remove old error and add an explanation 2019-07-02 12:15:20 -04:00
Niko Matsakis
ec48b4ebe2 preliminary integration of "pick constraints" into nll solver 2019-07-02 12:15:20 -04:00
Niko Matsakis
3b5a7276d2 construct pick-constraints and give them to region inference 2019-07-02 12:15:20 -04:00
Niko Matsakis
d9596692a5 implement PickConstraintSet type 2019-07-02 12:15:20 -04:00
Niko Matsakis
330cb7668c pass more than outlives constraints to constraint conversion 2019-07-02 12:15:20 -04:00
Niko Matsakis
3aad20d8f8 [WIP] fix Lift impl for Rc 2019-07-02 12:15:20 -04:00
Niko Matsakis
6ead1c8699 rename ConstraintSet to OutlivesConstraintSet 2019-07-02 12:15:20 -04:00
Niko Matsakis
ddc63ce19f propagate the pick-constraints through queries 2019-07-02 12:15:20 -04:00
Niko Matsakis
f933e0971b pass a &mut QueryRegionConstraints not just outlives constraints 2019-07-02 12:15:20 -04:00
Niko Matsakis
ec560e2c6d remove deref impl and add an index impl
The constraint set is going to be more than just a set of outlives
constraints.
2019-07-02 12:15:19 -04:00
Niko Matsakis
f673b24ba2 rename ConstraintIndex to OutlivesConstraintIndex 2019-07-02 12:15:19 -04:00
Niko Matsakis
09bba9b89d introduce QueryRegionConstraints struct 2019-07-02 12:15:19 -04:00
Niko Matsakis
7e66a96d58 introduce QueryRegionConstraints struct (no-op) 2019-07-02 12:15:19 -04:00
Niko Matsakis
fd5f7673a7 rename QueryRegionConstraint to QueryOutlivesConstraint 2019-07-02 12:15:19 -04:00
Niko Matsakis
d6ec0ae777 enforce and report pick-constraint errors
The error message here is not great.
2019-07-02 12:15:19 -04:00
Niko Matsakis
f0eebcd02f integrate pick constraints into lexical solver more completely 2019-07-02 12:15:19 -04:00
Niko Matsakis
02609b85e3 rename from "in constraint" to "pick constraint" 2019-07-02 12:15:19 -04:00
Niko Matsakis
c36205b48e add some tests, currently ICE-ing 2019-07-02 12:15:19 -04:00
Niko Matsakis
dfcd1c6328 make dup_vec optional 2019-07-02 12:15:19 -04:00
Niko Matsakis
979f566603 lexical_region_resolve: rustfmt 2019-07-02 12:15:19 -04:00
Niko Matsakis
14e23a5835 introduce an "in" constraint instead of error 2019-07-02 12:15:19 -04:00
Niko Matsakis
2eb3fcc10d introduce constrain_regions helper 2019-07-02 12:15:19 -04:00
Niko Matsakis
aab48c963a opaque_types/mod.rs: rustfmt 2019-07-02 12:15:19 -04:00
John Kåre Alsaker
b9344e31f5 Derive which queries to save using the proc macro 2019-07-02 17:31:46 +02:00
John Kåre Alsaker
ec8c2e1ab9 Use a single CtxtInterners 2019-07-02 16:29:03 +02:00
Simon Sapin
7454b29efc HashMap is UnwindSafe
Fixes https://github.com/rust-lang/rust/issues/62301, a regression in 1.36.0 which was caused by hashbrown using `NonZero<T>` where the older hashmap used `Unique<T>`.
2019-07-02 16:01:06 +02:00
bors
848e0a23f3 Auto merge of #61922 - tmandry:moar-generator-optimization, r=matthewjasper
Don't store locals that have been moved from in generators

This avoids reserving storage in generators for locals that are moved
out of (and not re-initialized) prior to yield points. Fixes #59123.

This adds a new dataflow analysis, `RequiresStorage`, to determine whether the storage of a local can be destroyed without being observed by the program. The rules are:

1. StorageLive(x) => mark x live
2. StorageDead(x) => mark x dead
3. If a local is moved from, _and has never had its address taken_, mark it dead
4. If (any part of) a local is initialized, mark it live'

This is used to determine whether to save a local in the generator object at all, as well as which locals can be overlapped in the generator layout.

Here's the size in bytes of all testcases included in the change, before and after the change:

async fn test    |Size before |Size after
-----------------|------------|----------
single           | 1028       | 1028
single_with_noop | 2056       | 1032
joined           | 5132       | 3084
joined_with_noop | 8208       | 3084

generator test              |Size before |Size after
----------------------------|------------|----------
move_before_yield           | 1028       | 1028
move_before_yield_with_noop | 2056       | 1032
overlap_move_points         | 3080       | 2056

## Future work

Note that there is a possible extension to this optimization, which modifies rule 3 to read: "If a local is moved from, _**and either has never had its address taken, or is Freeze and has never been mutably borrowed**_, mark it dead." This was discussed at length in #59123 and then #61849. Because this would cause some behavior to be UB which was not UB before, it's a step that needs to be taken carefully.

A more immediate priority for me is inlining `std::mem::size_of_val(&x)` so it becomes apparent that the address of `x` is not taken. This way, using `size_of_val` to look at the size of your inner futures does not affect the size of your outer future.

cc @cramertj @eddyb @Matthias247 @nikomatsakis @RalfJung @Zoxc
2019-07-02 12:25:00 +00:00
Ralf Jung
45e7ba96cb test more possible overaligned requests 2019-07-02 13:07:51 +02:00
Ralf Jung
576369bfce improve and deduplicate comments 2019-07-02 12:51:00 +02:00
Aleksey Kladov
dc088b26ce refactor check_for_substitution
No behavior change, just flatter and simpler code
2019-07-02 11:16:33 +03:00