about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/borrow_check/mod.rs
AgeCommit message (Collapse)AuthorLines
2021-09-07Move rustc_mir::borrow_check to new crate rustc_borrowck.Camille GILLOT-2368/+0
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-22Fix typos “a”→“an”Frank Steffahn-3/+3
2021-08-18Remove box syntax from rustc_mirest31-2/+2
2021-08-17Auto merge of #86977 - vakaras:body_with_borrowck_facts, r=nikomatsakisbors-7/+51
Enable compiler consumers to obtain mir::Body with Polonius facts. This PR adds a function (``get_body_with_borrowck_facts``) that can be used by compiler consumers to obtain ``mir::Body`` with accompanying borrow checker information. The most important borrow checker information that [our verifier called Prusti](https://github.com/viperproject/prusti-dev) needs is lifetime constraints. I have not found a reasonable way to compute the lifetime constraints on the Prusti side. In the compiler, the constraints are computed during the borrow checking phase and then dropped. This PR adds an additional parameter to the `do_mir_borrowck` function that tells it to return the computed information instead of dropping it. The additionally returned information by `do_mir_borrowck` contains a ``mir::Body`` with non-erased lifetime regions and Polonius facts. I have decided to reuse the Polonius facts because this way I needed fewer changes to the compiler and Polonius facts contains other useful information that we otherwise would need to recompute. Just FYI: up to now, Prusti was obtaining this information by [parsing the compiler logs](https://github.com/viperproject/prusti-dev/blob/b58ced8dfd14ef30582b503d517167ccd771eaff/prusti-interface/src/environment/borrowck/regions.rs#L25-L39). This is not only a hacky approach, but we also reached its limits. r? `@nikomatsakis`
2021-08-06Store the `DefId` of the currently typechecked item in `InferCtxt`Oli Scherer-1/+1
This allows opaque type inference to check for defining uses without having to pass down that def id via function arguments to every method that could possibly cause an opaque type to be compared with a concrete type
2021-07-22Enable compiler consumers to obtain Body with Polonius facts.Vytautas Astrauskas-7/+51
2021-06-02Add `Ty::is_union` predicate and use itTomasz Miąsko-7/+5
2021-05-01Closure capture borrow diagnostics for disjoint capturesChris Pardy-5/+1
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-3/+3
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See #83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes #83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-3/+3
2021-04-02Reduce size of statementsRoxane-1/+1
2021-03-26Use iter::zip in compiler/Josh Stone-1/+2
2021-03-09Clean up todoskadmin-11/+4
Also add some span_bugs where it is unreachable
2021-03-09Switch to changing cp_non_overlap in tformkadmin-0/+6
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09Replace todos with implskadmin-1/+9
Changed to various implementations, copying the style of prior function calls in places I was unsure of. Also one minor style nit.
2021-03-09Update match brancheskadmin-0/+2
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
2021-03-05Shrink the size of Rvalue by 16 bytesOli Scherer-2/+2
2021-02-10Only initialize what is usedDániel Buga-3/+2
2021-02-09Auto merge of #81132 - bugadani:map-prealloc, r=matthewjasperbors-4/+4
Borrowck: refactor visited map to a bitset This PR refactors `Borrows` and the `precompute_borrows_out_of_scope` function so that this initial phase has a much reduced memory pressure. This is achieved by reducing what is stored on the heap, and also reusing heap memory as much as possible.
2021-02-08Remove RCs from BorrowsDániel Buga-4/+4
2021-02-07Optimize BorrowsDániel Buga-1/+1
Reuse as much memory as possible, reduce number of allocations. Use BitSet instead of a HashMap, since only a single bit of information was used as the map's value.
2021-01-29Fix typosAman Arora-2/+2
2021-01-29Add fixme for precise path diagnosticsAman Arora-5/+5
2021-01-29Fix incorrect use mut diagnosticsAman Arora-20/+10
2021-01-29Fix unused 'mut' warning for capture's root variableAman Arora-4/+29
2021-01-29Compute mutability of closure capturesAman Arora-7/+2
When `capture_disjoint_fields` is not enabled, checking if the root variable binding is mutable would suffice. However with the feature enabled, the captured place might be mutable because it dereferences a mutable reference. This PR computes the mutability of each capture after capture analysis in rustc_typeck. We store this in `ty::CapturedPlace` and then use `ty::CapturedPlace::mutability` in mir_build and borrow_check.
2021-01-16PlaceRef::ty: use method call syntaxRalf Jung-4/+4
2021-01-03use PlaceRef more consistently instead of loosely coupled local+projectionRalf Jung-50/+24
2020-12-15Auto merge of #73210 - wesleywiser:consts_in_debuginfo, r=oli-obkbors-12/+14
[mir-opt] Allow debuginfo to be generated for a constant or a Place Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
2020-12-09Use closure_min_captures in borrow checkerAman Arora-7/+9
- Use closure_min_captures to generate the Upvar structure that stores information for diagnostics and information about mutability of captures.
2020-12-06[mir-opt] Allow debuginfo to be generated for a constant or a PlaceWesley Wiser-12/+14
Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
2020-10-21reviewBastian Kauschke-17/+4
2020-10-21Lift: take self by valueBastian Kauschke-1/+1
2020-10-10Refactor how SwitchInt stores jump targetsJonas Schievink-1/+1
2020-10-04Remove `DefId` from `MirBorrowckCtxt`Dylan MacKenzie-3/+0
2020-10-04Replace `(Body, WithOptConstParam)` with `Body` where possibleDylan MacKenzie-3/+4
2020-10-04Replace `(Body, DefId)` with `Body` where possibleDylan MacKenzie-6/+4
A `Body` now contains its `MirSource`, which in turn contains the `DefId` of the item associated with the `Body`.
2020-10-04Remember the `MirSource` for each `Body`Dylan MacKenzie-9/+2
2020-09-25Rollup merge of #76724 - ecstatic-morse:dataflow-pass-names, r=lcnrJonas Schievink-0/+4
Allow a unique name to be assigned to dataflow graphviz output Previously, if the same analysis were invoked multiple times in a single compilation session, the graphviz output for later runs would overwrite that of previous runs. Allow callers to add a unique identifier to each run so this can be avoided.
2020-09-14Add pass names to some common dataflow analysesDylan MacKenzie-0/+4
2020-09-10Note when a a move/borrow error is caused by a deref coercionAaron Hill-1/+4
Fixes #73268 When a deref coercion occurs, we may end up with a move error if the base value has been partially moved out of. However, we do not indicate anywhere that a deref coercion is occuring, resulting in an error message with a confusing span. This PR adds an explicit note to move errors when a deref coercion is involved. We mention the name of the type that the deref-coercion resolved to, as well as the `Deref::Target` associated type being used.
2020-09-04Change ty.kind to a methodLeSeulArtichaut-4/+4
2020-08-30mv compiler to compiler/mark-0/+2350