about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src
AgeCommit message (Collapse)AuthorLines
2025-07-28use let chains in hir, lint, mirKivooeo-40/+34
2025-07-11Remove support for SwitchInt edge effects in backward dataflow analysesTomasz Miąsko-9/+6
Those effects are untested and unused. Remove them along with the implementation of `BasicBlocks::switch_sources`.
2025-07-11Call `get_switch_int_data` on a block with SwitchInt terminatorTomasz Miąsko-1/+1
Fix a mix-up of a block with its predecessors in handling of SwitchInt edge effects for backward analysis. Note that this functionality is currently unused, so change has no practical impact.
2025-07-09Auto merge of #142707 - ashivaram23:drop_wildcard, r=dianqkbors-34/+94
Apply effects to `otherwise` edge in dataflow analysis This allows `ElaborateDrops` to remove drops when a `match` wildcard arm covers multiple no-Drop enum variants. It modifies dataflow analysis to update the `MaybeUninitializedPlaces` and `MaybeInitializedPlaces` data for a block reached through an `otherwise` edge. Fixes rust-lang/rust#142705.
2025-07-08Apply effects to otherwise edge in dataflow analysisAmogh Shivaram-34/+94
2025-06-29mir: Use the `new` method for `BasicBlockData`dianqk-5/+5
2025-06-29mir: Add a `new` method to `statement`dianqk-1/+1
Avoid introducing a large number of changes when adding optional initialization fields.
2025-05-12update cfg(bootstrap)Pietro Albini-1/+0
2025-05-07Rollup merge of #140234 - nnethercote:separate-Analysis-and-Results, r=davidtwcoGuillaume Gomez-167/+165
Separate dataflow analysis and results `Analysis` gets put into `Results` with `EntryStates`, by `iterate_to_fixpoint`. This has two problems: - `Results` is passed various places where only `Analysis` is needed. - `EntryStates` is passed around mutably everywhere even though it is immutable. This commit mostly separates `Analysis` from `Results` and fixes these two problems. r? `@davidtwco`
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-1/+11
async_drop_in_place::{closure}, scoped async drop added.
2025-04-25Rollup merge of #140202 - est31:let_chains_feature_compiler, r=lcnrMatthias Krüger-1/+1
Make #![feature(let_chains)] bootstrap conditional in compiler/ Let chains have been stabilized recently in #132833, so we can remove the gating from our uses in the compiler (as the compiler uses edition 2024).
2025-04-24Separate `Analysis` and `Results`.Nicholas Nethercote-139/+135
`Results` contains and `Analysis` and an `EntryStates`. The unfortunate thing about this is that the analysis needs to be mutable everywhere (`&mut Analysis`) which forces the `Results` to be mutable everywhere, even though `EntryStates` is immutable everywhere. To fix this, this commit renames `Results` as `AnalysisAndResults`, renames `EntryStates` as `Results`, and separates the analysis and results as much as possible. (`AnalysisAndResults` doesn't get much use, it's mostly there to facilitate method chaining of `iterate_to_fixpoint`.) `Results` is immutable everywhere, which: - is a bit clearer on how the data is used, - avoids an unnecessary clone of entry states in `locals_live_across_suspend_points`, and - moves the results outside the `RefCell` in Formatter. The commit also reformulates `ResultsHandle` as the generic `CowMut`, which is simpler than `ResultsHandle` because it doesn't need the `'tcx` lifetime and the trait bounds. It also which sits nicely alongside the new use of `Cow` in `ResultsCursor`.
2025-04-24Pass `Analysis` to `visit_*` instead of `Results`.Nicholas Nethercote-30/+32
Every `Results` contains an `Analysis`, but these methods only need the `Analysis`. No point passing them more data than they need.
2025-04-23Make #![feature(let_chains)] bootstrap conditional in compiler/est31-1/+1
2025-04-22Remove unnecessary lifetime on `ResultsVisitor`.Nicholas Nethercote-15/+15
2025-04-22Remove unused `ResultsCursor` methods.Nicholas Nethercote-15/+0
2025-04-22Move `StateDiffCollector`'s use point.Nicholas Nethercote-10/+11
Currently the graphviz code does a `results.visit_with` call while also holding a `ResultsCursor` on the `results`. That is both kinds of results traversals at the same time, which is awkward. This commit moves the `results.visit_with` part earlier so the two results traversals don't overlap.
2025-04-21Store `Results` in Formatter.Nicholas Nethercote-20/+20
Instead of `ResultsCursor`. This partly undoes the second commit from #132346; possible because `Results::as_result_cursor` (which doesn't consume the `Results`) is now available. Delaying the `ResultsCursor` construction will facilitate the next couple of commits.
2025-04-17Avoid an `unwrap` in `RustcMirAttrs::set_field`.Nicholas Nethercote-22/+23
2025-04-17Replace infallible `name_or_empty` methods with fallible `name` methods.Nicholas Nethercote-2/+3
I'm removing empty identifiers everywhere, because in practice they always mean "no identifier" rather than "empty identifier". (An empty identifier is impossible.) It's better to use `Option` to mean "no identifier" because you then can't forget about the "no identifier" possibility. Some specifics: - When testing an attribute for a single name, the commit uses the `has_name` method. - When testing an attribute for multiple names, the commit uses the new `has_any_name` method. - When using `match` on an attribute, the match arms now have `Some` on them. In the tests, we now avoid printing empty identifiers by not printing the identifier in the `error:` line at all, instead letting the carets point out the problem.
2025-04-16Remove support for `#[rustc_mir(borrowck_graphviz_format="gen_kill")]`.Nicholas Nethercote-1/+1
Because it's equivalent to `#[rustc_mir(borrowck_graphviz_format)]`. It used to be distinct, but the distinction was removed in https://github.com/rust-lang/rust/pull/76044/commits/3233fb18a891363a2da36ce69ca16fbb219c96be.
2025-04-02Remove `recursion_limit` increases.Nicholas Nethercote-1/+0
These are no longer needed now that `Nonterminal` is gone.
2025-03-12Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgrbors-1/+0
Rollup of 7 pull requests Successful merges: - #137314 (change definitely unproductive cycles to error) - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`) - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr) - #138331 (Use `RUSTC_LINT_FLAGS` more) - #138345 (Some autodiff cleanups) - #138387 (intrinsics: remove unnecessary leading underscore from argument names) - #138390 (fix incorrect tracing log) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-07Increase recursion_limit in numerous crates.Nicholas Nethercote-0/+1
This is temporarily needed for `x doc compiler` to work. They can be removed once the `Nonterminal` is removed (#124141).
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-7/+3
2025-02-22Fix binding mode problemsMichael Goulet-3/+3
2025-02-19Rollup merge of #137213 - nnethercote:rm-rustc_middle-mir-tcx, r=compiler-errorsMatthias Krüger-2/+0
Remove `rustc_middle::mir::tcx` module. This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much". The top-level module comment says: > Methods for the various MIR types. These are intended for use after > building is complete. Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then. This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics: - `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter. - `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`. - `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types. r? `@tmandry`
2025-02-19Remove `rustc_middle::mir::tcx` module.Nicholas Nethercote-2/+0
This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much". The top-level module comment says: > Methods for the various MIR types. These are intended for use after > building is complete. Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then. This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics: - `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter. - `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`. - `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types.
2025-02-17Remove `SwitchIntTarget`.Nicholas Nethercote-18/+10
It's only passed to `Analysis::apply_switch_int_edge_effect`, and the existing impls of that method only use the `value` field. So pass that instead.
2025-02-17Add `SwitchTargetValue`.Nicholas Nethercote-8/+15
This is much clearer than `Option<u128>`.
2025-02-17Refactor `apply_effects_in_block`.Nicholas Nethercote-13/+7
Very minor changes that will make the next few commits easier to follow.
2025-02-14Move drop elaboration infrastructure.Nicholas Nethercote-1046/+22
`rustc_mir_dataflow/src/elaborate_drops.rs` contains some infrastructure used by a few MIR passes: the `elaborate_drop` function, the `DropElaborator` trait, etc. `rustc_mir_transform/src/elaborate_drops.rs` (same file name, different crate) contains the `ElaborateDrops` pass. It relies on a lot of the infrastructure from `rustc_mir_dataflow/src/elaborate_drops.rs`. It turns out that the drop infrastructure is only used in `rustc_mir_transform`, so this commit moves it there. (The only exception is the small `DropFlagState` type, which is moved to the existing `rustc_mir_dataflow/src/drop_flag_effects.rs`.) The file is renamed from `rustc_mir_dataflow/src/elaborate_drops.rs` to `rustc_mir_transform/src/elaborate_drop.rs` (with no trailing `s`) because (a) the `elaborate_drop` function is the most important export, and (b) `rustc_mir_transform/src/elaborate_drops.rs` already exists. All the infrastructure pieces that used to be `pub` are now `pub(crate)`, because they are now only used within `rustc_mir_transform`.
2025-02-08Rustfmtbjorn3-38/+51
2025-02-03Contracts core intrinsics.Felix S. Klock II-1/+5
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-01-31Implement MIR, CTFE, and codegen for unsafe bindersMichael Goulet-3/+7
2025-01-28Represent the raw pointer for a array length check as a new kind of fake borrowMichael Goulet-2/+2
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-0/+2
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-65/+65
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2024-12-24Auto merge of #134625 - compiler-errors:unsafe-binders-ty, r=oli-obkbors-0/+2
Begin to implement type system layer of unsafe binders Mostly TODOs, but there's a lot of match arms that are basically just noops so I wanted to split these out before I put up the MIR lowering/projection part of this logic. r? oli-obk Tracking: - https://github.com/rust-lang/rust/issues/130516
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-0/+2
2024-12-22Delete `Rvalue::Len`Scott McMurray-2/+0
Everything's moved to `PtrMetadata` instead.
2024-12-22Auto merge of #134326 - scottmcm:slice-drop-shim-ptrmetadata, r=saethlinbors-9/+66
Use `PtrMetadata` instead of `Len` in slice drop shims I tried to do a bigger change in #134297 which didn't work, so here's the part I really wanted: Removing another use of `Len`, in favour of `PtrMetadata`. Split into two commits where the first just adds a test, so you can look at the second commit to see how the drop shim for an array changes with this PR. Reusing the same reviewer from the last one: r? BoxyUwU
2024-12-18Auto merge of #133328 - nnethercote:simplify-SwitchInt-handling, r=tmiaskobors-235/+177
Simplify `SwitchInt` handling Dataflow handling of `SwitchInt` is currently complicated. This PR simplifies it. r? `@cjgillot`
2024-12-18Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino许杰友 Jieyou Xu (Joe)-1/+0
Overhaul token cursors Some nice cleanups here. r? `````@davidtwco`````
2024-12-18Remove a comment that shouldn't have been committed.Nicholas Nethercote-1/+0
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-3/+2
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.