summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/move_paths
AgeCommit message (Collapse)AuthorLines
2018-03-24Auto merge of #48482 - davidtwco:issue-47184, r=nikomatsakisbors-0/+1
NLL should identify and respect the lifetime annotations that the user wrote Part of #47184. r? @nikomatsakis
2018-03-22Added UserAssertTy statement.David Wood-0/+1
2018-03-17Use num::NonZero* instead of NonZero<_> in rustc and testsSimon Sapin-3/+3
2018-02-15mir: Gather move at SwitchInt, Assert terminatorsFederico Poli-3/+6
Previously, "_1" was not marked as "definitely uninitialized" after a "switchInt(move _1)" terminator. Related discussion: https://internals.rust-lang.org/t/why-is-2-definitely-initialized-after-switchint-move-2/6760
2018-02-05mir: Add TerminatorKind::FalseUnwindbobtwinkles-0/+1
Sometimes a simple goto misses the cleanup/unwind edges. Specifically, in the case of infinite loops such as those introduced by a loop statement without any other out edges. Analogous to TerminatorKind::FalseEdges; this new terminator kind is used when we want borrowck to consider an unwind path, but real control flow should never actually take it.
2018-01-29rustc: replace "lvalue" terminology with "place" in the code.Eduard-Mihai Burtescu-3/+3
2017-12-26Auto merge of #46975 - matthewjasper:mir-moveck-asm, r=arielb1bors-1/+10
[MIR Borrowck] Moveck inline asm statements Closes #45695 New behavior: * Input operands to `asm!` are moved, direct output operands are initialized. * Direct, non-read-write outputs match the assignment changes in #46752 (Shallow writes, end borrows).
2017-12-23Give MIR borrowck a better understanding of inline asmMatthew Jasper-1/+10
2017-12-21Mir: Add Terminatorkind::AbortDavid Henningsson-0/+1
The Abort Terminatorkind will cause an llvm.trap function call to be emitted. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2017-12-13New `ActiveBorrows` dataflow for two-phase `&mut`; not yet borrowed-checked.Felix S. Klock II-0/+3
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-04inform constraint generation using maybe-initPaul Daniel Faria-0/+4
In particular, if we see a variable is DROP-LIVE, but it is not MAYBE-INIT, then we can ignore the drop. This leavess attempt to use more complex refinements of the idea (e.g., for subpaths or subfields) to future work.
2017-12-01MIR: s/lv(al(ue)?)?/place in function/variable/module names.Eduard-Mihai Burtescu-43/+43
2017-12-01MIR: s/Lvalue/Place in type names.Eduard-Mihai Burtescu-21/+21
2017-11-28MIR: split Operand::Consume into Copy and Move.Eduard-Mihai Burtescu-32/+13
2017-11-27Add initialization info to `MoveData`Matthew Jasper-2/+96
* Used for new dataflow to track if a variable has every been initialized * Used for other dataflows that need to be updated for initializations
2017-11-15add `StorageDead` handlingMikhail Modin-7/+9
2017-11-13Use the correct type for cannot move errormatthewjasper-8/+7
2017-11-02add TerminatorKind::FalseEdges and use it in matchesMikhail Modin-0/+1
2017-10-31make the dataflow / mir-borrowck types carry a `'tcx` lifetimeNiko Matsakis-20/+20
Also, factor out `do_mir_borrowck`, which is the code that actually performs the MIR borrowck from within the scope of an inference context. This change should be a pure refactoring.
2017-10-31test "needs drop" on region-erased, lifted typesNiko Matsakis-1/+3
This will be important in next commit, since the input types will be tagged not with `'gcx` but rather `'tcx`. Also, using the region-erased, lifted types enables better caching.
2017-10-04Made `move_paths::MoveError` take span param in `cannot_move_out_of` ctor.Felix S. Klock II-48/+79
Implicitly threaded `Location` through MoveData construction via a `Gatherer` struct (so that we could look up the span corresponding to the location when we need to signal an error).
2017-10-04mir-borrowck: Gather move errors during MoveData construction and report them.Felix S. Klock II-32/+69
Currently is using DUMMY_SP as the associated span; a follow-up commit will pass in appropriate spans when constructing the errors.
2017-09-03rustc_mir: use Local in ProjectionElem::Index.Eduard-Mihai Burtescu-2/+5
2017-08-16Merge remote-tracking branch 'origin/master' into genAlex Crichton-318/+348
2017-08-16Merge remote-tracking branch 'origin/master' into genAlex Crichton-10/+10
2017-08-16MIR based borrow check (opt-in).Felix S. Klock II-0/+6
One can either use `-Z borrowck-mir` or add the `#[rustc_mir_borrowck]` attribute to opt into MIR based borrow checking. Note that regardless of whether one opts in or not, AST-based borrow check will still run as well. The errors emitted from AST-based borrow check will include a "(Ast)" suffix in their error message, while the errors emitted from MIR-based borrow check will include a "(Mir)" suffix. post-rebase: removed check for intra-statement mutual conflict; replaced with assertion checking that at most one borrow is generated per statement. post-rebase: removed dead code: `IdxSet::pairs` and supporting stuff.
2017-08-16Factored `MoveData` construction code into `builder` submodule.Felix S. Klock II-313/+334
2017-08-16Added dataflow analysis for `Borrows`.Felix S. Klock II-0/+3
post-rebase: addressed review comment: rename `loc_map`/`location_map` and `rgn_map`/`region_map`. post-rebase: remove now unnecessary `mut` decl. post-rebase: address comments: bind iterator expr, and alpha-rename `loc`/`location` and `idx`/`index`.
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-10/+10
Like #43008 (f668999), but _much more aggressive_.
2017-08-12Merge branch 'master' of https://github.com/rust-lang/rust into genJohn Kåre Alsaker-0/+7
# Conflicts: # src/librustc_mir/build/scope.rs
2017-08-10For box expressions, use NZ drop instead of a free blockAriel Ben-Yehuda-0/+7
This falls naturally out of making drop elaboration work with `box` expressions, which is probably required for sane MIR borrow-checking. This is a pure refactoring with no intentional functional effects.
2017-08-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-2/+10
2017-07-30add new instructions for asserting when values are valid, and to describe ↵Ralf Jung-0/+1
when we can rely on them being locked in memory
2017-07-28Remove support for `gen arg`Alex Crichton-1/+0
2017-07-28Rename suspend to yieldJohn Kåre Alsaker-1/+1
2017-07-28Generator literal supportJohn Kåre Alsaker-0/+6
2017-07-27erase types in the move-path abstract domainAriel Ben-Yehuda-2/+9
Leaving types unerased would lead to 2 types with a different "name" getting different move-paths, which would cause major brokenness (see e.g. #42903). This does not fix any *known* issue, but is required if we want to use abs_domain with non-erased regions (because the same can easily have different names). cc @RalfJung.
2017-07-26Rollup merge of #42959 - SimonSapin:nonzero-checked, r=sfacklerMark Simulacrum-1/+1
Make the "main" constructors of NonZero/Shared/Unique return Option Per discussion in https://github.com/rust-lang/rust/issues/27730#issuecomment-303939441. This is a breaking change to unstable APIs. The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts. In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
2017-07-23Fix some doc/comment typos.Bruce Mitchener-1/+1
2017-07-22Use checked NonZero constructor in MIR move path indicesSimon Sapin-1/+1
… to protect against UB in the unlikely case that `idx + 1` overflows.
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-1/+1
2017-06-28Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate.Felix S. Klock II-0/+593
Turn `elaborate_drops` and `rustc_peek` implementations into MIR passes that also live in `rustc_mir` crate. Rewire things so `rustc_driver` uses the `ElaborateDrops` from `rustc_mir` crate.