Commit Graph

70793 Commits

Author SHA1 Message Date
Felix S. Klock II
1334638144 Add some doc to struct Borrows. 2017-12-13 15:48:20 -06:00
Felix S. Klock II
658ed79700 Add some doc to each_borrow_involving_path iteration function. 2017-12-13 15:48:20 -06:00
Felix S. Klock II
ced5a701ff New ActiveBorrows dataflow for two-phase &mut; not yet borrowed-checked.
High-level picture: The old `Borrows` analysis is now called
`Reservations` (implemented as a newtype wrapper around `Borrows`);
this continues to compute whether a `Rvalue::Ref` can reach a
statement without an intervening `EndRegion`. In addition, we also
track what `Place` each such `Rvalue::Ref` was immediately assigned
to in a given borrow (yay for MIR-structural properties!).

The new `ActiveBorrows` analysis then tracks the initial use of any of
those assigned `Places` for a given borrow. I.e. a borrow becomes
"active" immediately after it starts being "used" in some way. (This
is conservative in the sense that we will treat a copy `x = y;` as a
use of `y`; in principle one might further delay activation in such
cases.)

The new `ActiveBorrows` analysis needs to take the `Reservations`
results as an initial input, because the reservation state influences
the gen/kill sets for `ActiveBorrows`. In particular, a use of `a`
activates a borrow `a = &b` if and only if there exists a path (in the
control flow graph) from the borrow to that use. So we need to know if
the borrow reaches a given use to know if it really gets a gen-bit or
not.

 * Incorporating the output from one dataflow analysis into the input
   of another required more changes to the infrastructure than I had
   expected, and even after those changes, the resulting code is still
   a bit subtle.

 * In particular, Since we need to know the intrablock reservation
   state, we need to dynamically update a bitvector for the
   reservations as we are also trying to compute the gen/kills
   bitvector for the active borrows.

 * The way I ended up deciding to do this (after also toying with at
   least two other designs) is to put both the reservation state and
   the active borrow state into a single bitvector. That is why we now
   have separate (but related) `BorrowIndex` and
   `ReserveOrActivateIndex`: each borrow index maps to a pair of
   neighboring reservation and activation indexes.

As noted above, these changes are solely adding the active borrows
dataflow analysis (and updating the existing code to cope with the
switch from `Borrows` to `Reservations`). The code to process the
bitvector in the borrow checker currently just skips over all of the
active borrow bits.

But atop this commit, one *can* observe the analysis results by
looking at the graphviz output, e.g. via

```rust
 #[rustc_mir(borrowck_graphviz_preflow="pre_two_phase.dot",
             borrowck_graphviz_postflow="post_two_phase.dot")]
```

Includes doc for `FindPlaceUses`, as well as `Reservations` and
`ActiveBorrows` structs, which are wrappers are the `Borrows` struct
that dictate which flow analysis should be performed.
2017-12-13 15:48:15 -06:00
Felix S. Klock II
ef64ace8aa Allow mir::Place to be used as a key in hashtables. 2017-12-13 13:50:40 -06:00
Felix S. Klock II
e437e499d1 Implement Borrow/BorrowMut/ToOwned relationships betweed IdxSetBuf and IdxSet. 2017-12-13 13:50:40 -06:00
Felix S. Klock II
39e126c001 Refactoring alpha-rename place (BorrowData field) to borrowed_place. 2017-12-13 13:50:40 -06:00
Felix S. Klock II
e123117cb7 Refactoring: Allow BlockSets.on_entry to denote locally accumulated intrablock state.
(Still musing about whether it could make sense to revise the design
here to make these constraints on usage explicit.)
2017-12-13 13:50:39 -06:00
Felix S. Klock II
d4add5d52a Refactoring: pull bitvector initialization out from other parts of dataflow.
This is meant to ease development of multi-stage dataflow analyses
where the output from one analysis is used to initialize the state
for the next; in such a context, you cannot start with `bottom_value`
for all the bits.
2017-12-13 13:50:39 -06:00
Felix S. Klock II
171c2aeb25 Expanded HIR --unpretty hir,identified to include HIR local id.
Having the HIR local id is useful for cases like understanding the
ReScope identifiers, which are now derived from the HIR local id, and
thus one can map an ReScope back to the HIR node, once one knows what
those local ids are.
2017-12-13 00:15:17 -06:00
Felix S. Klock II
93c4ffe72f Revised graphviz rendering API to avoid requiring borrowed state.
Made `do_dataflow` and related API `pub(crate)`.
2017-12-13 00:15:17 -06:00
bors
691f022767 Auto merge of #46613 - petrochenkov:absext, r=nikomatsakis
Resolve absolute paths as extern under a feature flag

cc https://github.com/rust-lang/rust/issues/44660
r? @nikomatsakis
2017-12-13 01:44:36 +00:00
bors
442b7bd10a Auto merge of #46570 - AgustinCB:issue-46553, r=oli-obk
Ignore `unsopported constant expr` error

Fixes #46553
2017-12-12 23:08:56 +00:00
Vadim Petrochenkov
b07e26e36e Resolve absolute paths as extern under a feature flag 2017-12-13 00:02:23 +03:00
Vadim Petrochenkov
9552b9cfd2 rustc_metadata: Refactor away ExternCrateInfo 2017-12-12 23:50:35 +03:00
bors
6a36019440 Auto merge of #46696 - kennytm:rollup, r=kennytm
Rollup of 4 pull requests

- Successful merges: #46668, #46672, #46691, #46694
- Failed merges:
2017-12-12 20:31:17 +00:00
kennytm
80d1de97ad Rollup merge of #46694 - kennytm:temporarily-use-old-travis-image, r=aidanhs
Temporarily use the old Travis image.

Use it until travis-ci/travis-ci#8891 is fixed.

(See also https://blog.travis-ci.com/2017-12-12-new-trusty-images-q4-launch)

r? @aidanhs
2017-12-13 04:28:09 +08:00
kennytm
37cc63ab13 Rollup merge of #46691 - varkor:contrib-3, r=rkruppe
Fix return value of `LLVMRustMetadataAsValue`

`LLVMRustMetadataAsValue` would previously return `void`, despite the
corresponding Rust function expecting to return a `ValueRef`.
2017-12-13 04:28:08 +08:00
kennytm
6a365417c0 Rollup merge of #46672 - GuillaumeGomez:fix-type-filter-search, r=QuietMisdreavus
Fix type filter in rustdoc js

Fixes #46612.

r? @QuietMisdreavus
2017-12-13 04:28:06 +08:00
kennytm
c6ce7dae23 Rollup merge of #46668 - GuillaumeGomez:mobile-sidebar, r=QuietMisdreavus
Fix mobile doc style and improve search bar

Fixes #46593.

r? @QuietMisdreavus
2017-12-13 04:28:05 +08:00
kennytm
c0c26a649e
Temporarily use the old Travis image.
Use it until travis-ci/travis-ci#8891 is fixed.
2017-12-13 04:23:12 +08:00
varkor
6487ee3444 Fix return value of LLVMRustMetadataAsValue
`LLVMRustMetadataAsValue` would previously return `void`, despite the
corresponding Rust function expecting to return a `ValueRef`.
2017-12-12 17:27:37 +00:00
bors
707d070815 Auto merge of #46647 - varkor:contrib-1, r=sfackler
Add `std::fmt::Pointer` implementation for `AtomicPtr`

Resolves #29212.
2017-12-12 15:54:13 +00:00
bors
4c2819d326 Auto merge of #46250 - canndrew:rename-never-type-impl-gate, r=petrochenkov
Rename never_type_impls gate

We no longer need a separately-named `never_type_impls` gate thanks to https://github.com/rust-lang/rust/issues/43089.
2017-12-12 13:16:30 +00:00
bors
3ece2d94d3 Auto merge of #46674 - malbarbo:undist-armv5te, r=alexcrichton
Remove armv5te target from dist-various-1

Reverts https://github.com/rust-lang/rust/pull/46498

I must have made some mistake when I tested that commit and thought armv5te target worked. but testing it now the produced binaries segfaults (https://github.com/rust-lang/rust/pull/46498#issuecomment-350599233).

I tried using crosstool-ng and buildroot toolchain (for armv5te) but the produced binaries also segfaults. Maybe there is a issue with the target, but I cannot investigate it any further.

I think the best for now is not to distribute the armv5te target.

I'm sorry for what happened.
2017-12-12 08:45:28 +00:00
bors
724500626b Auto merge of #46598 - davidtwco:issue-46471, r=arielb1
MIR borrowck: error message confuses locals and temporaries

Fixes #46471 and fixes #46472 (see [this Gitter comment](https://gitter.im/rust-impl-period/WG-compiler-nll?at=5a2d5cb53ae2aa6b3facf0c2)).

r? @arielb1
2017-12-12 06:11:33 +00:00
Andrew Cann
b9df045b79 Rename never_type_impls gate to never_type 2017-12-12 14:03:03 +08:00
bors
3a0b652846 Auto merge of #46411 - rillian:str_ascii, r=kennytm
Mark ascii methods on primitive types stable in 1.23.0 not 1.21.0.

The ascii_methods_on_intrinsics feature stabilization
didn't land in time for 1.21.0. Update the annotation
so the documentation is correct about when these
methods became available.
2017-12-12 03:30:43 +00:00
bors
5951f8d1ba Auto merge of #46657 - nikomatsakis:resolve-lifetimes-query, r=arielb1
move `resolve_lifetimes` into a proper query

Now that we made `resolve_lifetimes` into a query, elision errors no
longer abort compilation, which affects some tests.

Also, remove `dep_graph_crosscontaminate_tables` -- there is no a path in
the dep-graph, though red-green handles it. The same scenario
is (correctly) tested by issue-42602.rs in any case.

r? @michaelwoerister
2017-12-12 00:52:20 +00:00
Marco A L Barbosa
73e5334df3 Remove armv5te target from dist-various-1
Reverts https://github.com/rust-lang/rust/pull/46498

I must have made some mistake when I tested that commit and thought
armv5te target worked. but testing it now the produced binaries
segfaults
(https://github.com/rust-lang/rust/pull/46498#issuecomment-350599233).

I tried using crosstool-ng and buildroot toolchain (for armv5te) but
the produced binaries also segfaults. Maybe there is a issue with the
target, but I cannot investigate it any further.

I think the best for now is not to distribute the armv5te target.

I'm sorry for what happened.
2017-12-11 22:00:25 -02:00
Guillaume Gomez
557236c508 Fix type filter in rustdoc js 2017-12-12 00:19:36 +01:00
David Wood
3dbc11bc63
Updated existing tests with new error messages. 2017-12-11 22:20:15 +00:00
David Wood
00c7a3f4dc
Refactored and tidied up report function 2017-12-11 22:20:12 +00:00
Guillaume Gomez
a06c6bd63c Fix mobile doc style and improve search bar 2017-12-11 22:30:04 +01:00
bors
9fe7aa353f Auto merge of #46608 - estebank:resolve-return, r=nikomatsakis
Resolve type on return type suggestion

Partially address #45871.
2017-12-11 21:14:13 +00:00
Niko Matsakis
fdbd9b0dd5 make krate infallible 2017-12-11 15:52:46 -05:00
David Wood
baf68d3a37
Fixed case where borrowed value lives until after scope 2017-12-11 20:41:27 +00:00
David Wood
52442d4d8a
Fix error does not know about free/named lifetimes 2017-12-11 20:34:39 +00:00
David Wood
15b8fbdfb3
Added test for #46472 2017-12-11 20:26:06 +00:00
David Wood
d78e8a730a
Fix error message confuses locals and temporaries 2017-12-11 20:14:06 +00:00
David Wood
4651d1e3cf
Added test for #46471 2017-12-11 19:46:01 +00:00
bors
ddbb27a241 Auto merge of #46558 - arielb1:union-borrow-refactor, r=nikomatsakis
Clean up the MIR borrowck code

I want to avoid the new code to start with so much technical debt.

r? @nikomatsakis
2017-12-11 16:43:40 +00:00
Niko Matsakis
b7794c0d3f move resolve_lifetimes into a proper query
Now that we made `resolve_lifetimes` into a query, elision errors no
longer abort compilation, which affects some tests.

Also, remove `dep_graph_crosscontaminate_tables` -- there is no a path in
the dep-graph, though red-green handles it. The same scenario
is (correctly) tested by issue-42602.rs in any case.
2017-12-11 10:11:13 -05:00
Niko Matsakis
d737ea7902 resolve_lifetime: rustfmt 2017-12-11 09:00:05 -05:00
bors
33245fe682 Auto merge of #46640 - tommyip:ui_tests, r=estebank
Enforce successful ui tests to have must-compile-successfully flag.

r? @nikomatsakis
cc @oli-obk

Fixes #46587
2017-12-11 06:54:24 +00:00
bors
5f3bd73d81 Auto merge of #46625 - emilio:moar-nits, r=kennytm
infer: Fix typo in README.

Was just reading through it and found this, not a big deal but...
2017-12-11 04:27:58 +00:00
bors
830599b195 Auto merge of #46624 - emilio:nit, r=kennytm
rustc_trans: Fix indentation in trans_set_discr.

Just noticed this while reading through #46521, which introduced this weird
alignment.
2017-12-11 02:04:56 +00:00
bors
ea16814761 Auto merge of #46248 - zackmdavis:one_time_private_enum_variant_reexport_error, r=estebank
one-time diagnostics for private enum variants glob reëxport

![private_enum_reexport](https://user-images.githubusercontent.com/1076988/33224719-4e5805f0-d121-11e7-8bc0-a708a277a5db.png)

r? @estebank
2017-12-10 23:32:09 +00:00
varkor
e4dc11d98d Add std::fmt::Pointer implementation for AtomicPtr
Resolves #29212.
2017-12-10 23:21:26 +00:00
Tommy Ip
2ad5bf056c Update ui tests' line numbers. 2017-12-10 21:14:57 +00:00
Tommy Ip
76d9b309ae Add must-compile-successfully comment to appropriate ui tests. 2017-12-10 21:14:57 +00:00