summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src/dataflow.rs
AgeCommit message (Collapse)AuthorLines
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_borrowck`.Nicholas Nethercote-0/+1
2024-08-16Add `warn(unreachable_pub)` to `rustc_borrowck`.Nicholas Nethercote-2/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-14Stop using the gen keyword in the compilerMichael Goulet-1/+1
2024-06-26Split lifetimes on mir borrowck dataflowOli Scherer-20/+20
2024-06-05Remove confusing `use_polonius` flag and do less cloningAmanda Stjerna-3/+3
The `use_polonius` flag is both redundant and confusing since every function it's propagated to also checks if `all_facts` is `Some`, the true test of whether to generate Polonius facts for Polonius or for external consumers. This PR makes that path clearer by simply doing away with the argument and handling the logic in precisely two places: where facts are populated (check for `Some`), and where `all_facts` are initialised. It also delays some statements until after that check to avoid the miniscule performance penalty of executing them when Polonius is disabled. This also addresses @lqd's concern in #125652 by reducing the size of what is cloned out of Polonius facts to just the facts being added, as opposed to the entire vector of potential inputs, and added descriptive comments. *Reviewer note*: the comments in [add_extra_drop_facts](https://github.com/rust-lang/rust/blob/85f90a461262f7ca37a6e629933d455fa9c3ee48/compiler/rustc_borrowck/src/type_check/liveness/trace.rs#L219) should be inspected by a reviewer, in particular the one on L#259 in this PR, which should be trivial for someone with the right background knowledge. I also included some minor lints I found on the way there that I couldn't help myself from addressing.
2024-04-14Make `depth_first_search` into a standalone functionMaybe Waffle-2/+2
Does not necessarily change much, but we never overwrite it, so I see no reason for it to be in the `Successors` trait. (+we already have a similar `is_cyclic`)
2024-04-14Merge `{With,Graph}{Successors,Predecessors}` into `{Successors,Predecessors}`Maybe Waffle-1/+1
Now with GAT!
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2023-12-10remove redundant importssurechen-1/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-08Tweak `GenKillAnalysis`.Nicholas Nethercote-2/+2
`GenKillAnalysis` has five methods that take a transfer function arg: - `statement_effect` - `before_statement_effect` - `terminator_effect` - `before_terminator_effect` - `call_return_effect` All the transfer function args have type `&mut impl GenKill<Self::Idx>`, except for `terminator_effect`, which takes the simpler `Self::Domain`. But only the first two need to be `impl GenKill`. The other three can all be `Self::Domain`, just like `Analysis`. So this commit changes the last two to take `Self::Domain`, making `GenKillAnalysis` and `Analysis` more similar. (Another idea would be to make all these methods `impl GenKill`. But that doesn't work: `MaybeInitializedPlaces::terminator_effect` requires the arg be `Self::Domain` so that `self_is_unwind_dead(place, state)` can be called on it.)
2023-12-08Remove `BorrowckAnalyses`.Nicholas Nethercote-28/+18
This results in two non-generic types being used: `BorrowckResults` and `BorrowckFlowState`. It's a net reduction in lines of code, and a little easier to read.
2023-12-08Remove `impl_visitable!`.Nicholas Nethercote-65/+62
It is used just once. With it removed, the relevant code is a little boilerplate-y but much easier to read, and is the same length. Overall I think it's an improvement.
2023-12-01improve NLL/polonius scope equality assertionRémy Rakic-1/+2
2023-11-25Auto merge of #118203 - nnethercote:rustc_mir_dataflow, r=cjgillotbors-17/+17
Minor `rustc_mir_dataflow` cleanups r? `@cjgillot`
2023-11-23Use `'mir` lifetime name more.Nicholas Nethercote-17/+17
Some types have a `body: &'mir Body<'tcx>` and some have `body: &'a Body<'tcx>`. The former is more readable, so this commit converts some fo the latter to the former.
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-04traverse region graph instead of SCCs to compute polonius loan scopesRémy Rakic-3/+3
By using SCC for better performance, we also have to take into account SCCs whose representative is an existential region but also contains a placeholder. By only checking the representative, we may miss that the loan escapes the function. This can be fixed by picking a better representative, or removing placeholders from the main path. This is the simplest fix: forgo efficiency and traverse the region graph instead of the SCCs.
2023-10-20consider a loan escapes the function via applied member constraintsRémy Rakic-7/+14
2023-10-05compute NLL loan scopes with liveness in `-Zpolonius=next`Rémy Rakic-1/+183
2023-10-05add note why a function is pubRémy Rakic-0/+1
2023-10-04document Borrows dataflow analysisRémy Rakic-0/+7
2023-10-04rename ancient regioncxRémy Rakic-2/+2
2023-08-16Make TerminatorEdge plural.Camille GILLOT-2/+2
2023-08-16Allow apply_terminator_effect to customize edges.Camille GILLOT-6/+9
2023-08-16Move domain_size to GenKillAnalysis.Camille GILLOT-0/+4
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-1/+1
r? @WaffleLapkin
2023-06-28Rollup merge of #112236 - cjgillot:interval-kill, r=davidtwcoDylan DPC-51/+43
Simplify computation of killed borrows Follow-up to https://github.com/rust-lang/rust/pull/111759 Processing the first block manually once makes the pre-order walk simpler.
2023-06-08Auto merge of #108293 - Jarcho:mut_analyses, r=eholkbors-9/+9
Take MIR dataflow analyses by mutable reference The main motivation here is any analysis requiring dynamically sized scratch memory to work. One concrete example would be pointer target tracking, where tracking the results of a dereference can result in multiple possible targets. This leads to processing multi-level dereferences requiring the ability to handle a changing number of potential targets per step. A (simplified) function for this would be `fn apply_deref(potential_targets: &mut Vec<Target>)` which would use the scratch space contained in the analysis to send arguments and receive the results. The alternative to this would be to wrap everything in a `RefCell`, which is what `MaybeRequiresStorage` currently does. This comes with a small perf cost and loses the compiler's guarantee that we don't try to take multiple borrows at the same time. For the implementation: * `AnalysisResults` is an unfortunate requirement to avoid an unconstrained type parameter error. * `CloneAnalysis` could just be `Clone` instead, but that would result in more work than is required to have multiple cursors over the same result set. * `ResultsVisitor` now takes the results type on in each function as there's no other way to have access to the analysis without cloning it. This could use an associated type rather than a type parameter, but the current approach makes it easier to not care about the type when it's not necessary. * `MaybeRequiresStorage` now no longer uses a `RefCell`, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.
2023-06-02Simplify pre-order algorithm.Camille GILLOT-51/+43
2023-05-25Auto merge of #111925 - Manishearth:rollup-z6z6l2v, r=Manishearthbors-15/+20
Rollup of 5 pull requests Successful merges: - #111741 (Use `ObligationCtxt` in custom type ops) - #111840 (Expose more information in `get_body_with_borrowck_facts`) - #111876 (Roll compiler_builtins to 0.1.92) - #111912 (Use `Option::is_some_and` and `Result::is_ok_and` in the compiler ) - #111915 (libtest: Improve error when missing `-Zunstable-options`) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-23Allow consumers to retrieve borrowck outputJonáš Fiala-15/+20
2023-05-19Leverage the interval property to precompute borrow kill points.Camille GILLOT-49/+46
2023-05-18Take MIR dataflow analyses by mutable reference.Jason Newcomb-9/+9
2023-05-09Reduce BitSet size used in `Borrows` dataflow analysisvlad20012-1/+1
2023-04-13Remove `impl ToRegionVid for RegionVid`.Nicholas Nethercote-4/+2
It's weird and unnecessary.
2023-03-15unequal → not equalgimbles-1/+1
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+1
2023-03-05Remove `allow(potential_query_instability)` from `borrowck`clubby789-4/+4
2023-01-23Create stable metric to measure long computation in Const EvalBryan Garza-0/+1
This patch adds a `MirPass` that tracks the number of back-edges and function calls in the CFG, adds a new MIR instruction to increment a counter every time they are encountered during Const Eval, and emit a warning if a configured limit is breached.
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-2/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Make `#[debug_format]` an attribute in `newtype_index`Nilstrieb-1/+1
This removes the `custom` format functionality as its only user was trivially migrated to using a normal format. If a new use case for a custom formatting impl pops up, you can add it back.
2022-12-06`rustc_borrowck`: remove `ref` patternsMaybe Waffle-5/+5
2022-11-09lint auto passAndyJado-0/+2
Revert "lint auto pass" This reverts commit e58e4466384924c491a932d3f18ef50ffa5a5065.
2022-09-06Generalize the Assume intrinsic statement to a general Intrinsic statementOli Scherer-2/+1
2022-09-06Lower the assume intrinsic to a MIR statementOli Scherer-0/+1
2022-08-26Replace `Body::basic_blocks()` with field accessTomasz Miąsko-1/+1
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+1
2022-05-17Change `Successors` to `impl Iterator<Item = BasicBlock>`SparrowLii-1/+1
2022-04-11Add new `Deinit` statement kindJakob Degen-0/+1