about summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/move_paths
AgeCommit message (Collapse)AuthorLines
2018-11-03Unions reinitialized after assignment into field.David Wood-0/+14
This commit makes two changes: First, it updates the dataflow builder to add an init for the place containing a union if there is an assignment into the field of that union. Second, it stops a "use of uninitialized" error occuring when there is an assignment into the field of an uninitialized union that was previously initialized. Making this assignment would re-initialize the union, as tested in `src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr`. The check for previous initialization ensures that we do not start supporting partial initialization yet (cc #21232, #54499, #54986).
2018-11-02Auto merge of #55087 - levex:e0669-improve-span, r=nagisabors-1/+1
rustc: improve E0669 span E0669 refers to an operand that cannot be coerced into a single LLVM value, unfortunately right now this uses the Span for the entire inline assembly statement, which is less than ideal. This commit preserves the Span from HIR, which lets us emit the error using the Span for the operand itself in MIR. r? @nagisa cc/ @parched
2018-11-02Auto merge of #55316 - RalfJung:retagging, r=oli-obkbors-1/+1
Add Retagging statements This adds a `Retag` statement kind to MIR, used to perform the retagging operation from [Stacked Borrows](https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html). It also kills the old `Validate` statements that I added last year. NOTE: This includes https://github.com/rust-lang/rust/pull/55270. Only [these commits are new](https://github.com/RalfJung/rust/compare/stacked-borrows-ng...RalfJung:retagging).
2018-11-01Use `SmallVec` within `MoveData`.Nicholas Nethercote-9/+10
This reduces allocation counts significantly in a few benchmarks, reducing instruction counts by up to 2%.
2018-10-29Emit Retag statements, kill Validate statementsRalf Jung-1/+1
Also "rename" -Zmir-emit-validate to -Zmir-emit-retag, which is just a boolean (yes or no).
2018-10-19Prefer `Default::default` over `FxHash*::default` in struct constructorsOliver Scherer-2/+1
2018-10-19Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hackOliver Scherer-1/+1
2018-10-17rustc: improve E0669 spanLevente Kurusa-1/+1
E0669 refers to a constraint that cannot be coerced into a single LLVM value, unfortunately right now this uses the Span for the entire inline assembly statement, which is less than ideal. This commit preserves the Span from HIR, which lets us emit the error using the Span for the operand itself in MIR. Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-10-03Record whether a Call in MIR corresponds to a call in HIRMatthew Jasper-1/+7
2018-09-24Shrink StatementKind::InlineAsm.Nicholas Nethercote-1/+1
This shrinks StatementKind from 64 bytes to 48 bytes on 64-bit.
2018-09-22Auto merge of #54188 - lqd:fallout-53695, r=nikomatsakisbors-1/+1
NLL: disallow creation of immediately unusable variables Fix #53695 Original description follows ---- This WIP PR is for discussing the impact of fixing #53695 by injecting a fake read in let patterns. (Travis will fail, at least the `mir-opt` suite is failing in its current state)
2018-09-18Refactor 'ReadForMatch' into 'FakeRead' and add the cause of the fake readRemy Rakic-1/+1
2018-09-17Inspect parents paths when checking for movesSantiago Pastorino-0/+14
2018-09-10add the `AscribeUserType` statement kindNiko Matsakis-1/+1
Make it have the semantics of subtype.
2018-09-08Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakisbors-0/+10
Skip a shared borrow of a immutable local variables issue #53643 r? @nikomatsakis
2018-09-07Auto merge of #54021 - kennytm:rollup, r=kennytmbors-1/+1
Rollup of 17 pull requests Successful merges: - #53299 (Updated core/macros.rs to note it works in a no_std environment.) - #53376 (Cross reference io::copy and fs::copy in docs.) - #53455 (Individual docs for {from,to}_*_bytes) - #53550 (librustc_lint: In recursion warning, change 'recurring' to 'recursing') - #53860 (Migrate (some) of run-pass/ to ui) - #53874 (Implement Unpin for Box, Rc, and Arc) - #53895 (tidy: Cleanups and clippy warning fixes) - #53946 (Clarify `ManuallyDrop` docs) - #53948 (Minimized clippy test from when NLL disabled two-phase borrows) - #53959 (Add .git extension to submodule paths missing it) - #53966 (A few cleanups and minor improvements to mir/dataflow) - #53967 (propagate build.python into cmake) - #53979 (Remove `#[repr(transparent)]` from atomics) - #53991 (Add unchecked_shl/shr check for intrinsics to fix miri's test suit) - #53992 (migrate run-pass/borrowck to ui/run-pass) - #53994 (migrate run-pass/*/ to ui/run-pass) - #54023 (update clippy submodule)
2018-09-06Skip a shared borrow of a immutable local variablesMikhail Modin-0/+10
issue #53643
2018-09-05A few cleanups and minor improvements to mir/dataflowljedrz-1/+1
2018-08-30Added InitLocation to encode Location or Local depending on source of InitDavid Wood-7/+24
2018-08-22Remove Ty prefix from ↵varkor-5/+5
Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error}
2018-08-14Label definition of captured variables in errors.David Wood-7/+10
2018-07-23Promoteds are statics and statics have a place, not just a valueOliver Schneider-0/+2
2018-07-21Add specific message when moving from upvars in a non-FnOnce closureMatthew Jasper-5/+5
2018-06-27Group move errors before reporting, add suggestionsMatthew Jasper-11/+10
2018-06-06When NLL has illegal move due to borrowed content, provide feedback about ↵Felix S. Klock II-5/+20
why the move wasn't a copy. This should address #51190.
2018-05-29rust-lang/rust#27282: Add `StatementKind::ReadForMatch` to MIR.Felix S. Klock II-0/+3
(This is just the data structure changes and some boilerplate match code that followed from it; the actual emission of these statements comes in a follow-up commit.)
2018-05-24Use AllFacts from polonius-engineSantiago Pastorino-1/+1
2018-04-15remove `ReserveOrActivateIndex`Niko Matsakis-3/+0
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.