diff options
| author | dianqk <dianqk@dianqk.net> | 2025-07-19 18:49:47 +0800 |
|---|---|---|
| committer | dianqk <dianqk@dianqk.net> | 2025-10-02 14:58:59 +0800 |
| commit | 8da04285cf6fe61587e16155a8b224dba64bf0be (patch) | |
| tree | 4d4c98956c6bd938cd5ffe9bbfb7928a2f229a12 /compiler/rustc_middle/src/mir/statement.rs | |
| parent | 1bd89bd42e0bb6f29b8af5d6bdf3f756196bb8ee (diff) | |
| download | rust-8da04285cf6fe61587e16155a8b224dba64bf0be.tar.gz rust-8da04285cf6fe61587e16155a8b224dba64bf0be.zip | |
mir-opt: Eliminate dead statements even if they are used by debuginfos
Diffstat (limited to 'compiler/rustc_middle/src/mir/statement.rs')
| -rw-r--r-- | compiler/rustc_middle/src/mir/statement.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 67b4448cfcd..f310e1e5762 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -527,6 +527,20 @@ impl<'tcx> PlaceRef<'tcx> { }) } + /// Return the place accessed locals that include the base local. + pub fn accessed_locals(self) -> impl Iterator<Item = Local> { + std::iter::once(self.local).chain(self.projection.iter().filter_map(|proj| match proj { + ProjectionElem::Index(local) => Some(*local), + ProjectionElem::Deref + | ProjectionElem::Field(_, _) + | ProjectionElem::ConstantIndex { .. } + | ProjectionElem::Subslice { .. } + | ProjectionElem::Downcast(_, _) + | ProjectionElem::OpaqueCast(_) + | ProjectionElem::UnwrapUnsafeBinder(_) => None, + })) + } + /// Generates a new place by appending `more_projections` to the existing ones /// and interning the result. pub fn project_deeper( @@ -1057,4 +1071,5 @@ impl<'tcx> ops::DerefMut for StmtDebugInfos<'tcx> { #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] pub enum StmtDebugInfo<'tcx> { AssignRef(Local, Place<'tcx>), + InvalidAssign(Local), } |
