pub(crate) trait MirPass<'tcx> {
// Required methods
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);
fn is_required(&self) -> bool;
// Provided methods
fn name(&self) -> &'static str { ... }
fn profiler_name(&self) -> &'static str { ... }
fn is_enabled(&self, _sess: &Session) -> bool { ... }
fn can_be_overridden(&self) -> bool { ... }
fn is_mir_dump_enabled(&self) -> bool { ... }
}Expand description
A streamlined trait that you can implement to create a pass; the
pass will be named after the type, and it will consist of a main
loop that goes over each available MIR and applies run_pass.
Required Methods§
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>)
Sourcefn is_required(&self) -> bool
fn is_required(&self) -> bool
Returns true if this pass must be run (i.e. it is required for soundness).
For passes which are strictly optimizations, this should return false.
If this is false, #[optimize(none)] will disable the pass.
Provided Methods§
fn name(&self) -> &'static str
fn profiler_name(&self) -> &'static str
Sourcefn is_enabled(&self, _sess: &Session) -> bool
fn is_enabled(&self, _sess: &Session) -> bool
Returns true if this pass is enabled with the current combination of compiler flags.
Sourcefn can_be_overridden(&self) -> bool
fn can_be_overridden(&self) -> bool
Returns true if this pass can be overridden by -Zenable-mir-passes. This should be
true for basically every pass other than those that are necessary for correctness.
fn is_mir_dump_enabled(&self) -> bool
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl MirPass<'_> for UnreachablePropagation
impl<'tcx, T> MirPass<'tcx> for Lint<T>where
T: MirLint<'tcx>,
impl<'tcx, T> MirPass<'tcx> for WithMinOptLevel<T>where
T: MirPass<'tcx>,
impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls
impl<'tcx> MirPass<'tcx> for AddCallGuards
impl<'tcx> MirPass<'tcx> for AddMovesForPackedDrops
impl<'tcx> MirPass<'tcx> for CheckAlignment
impl<'tcx> MirPass<'tcx> for CheckEnums
impl<'tcx> MirPass<'tcx> for CheckNull
impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck
impl<'tcx> MirPass<'tcx> for CopyProp
impl<'tcx> MirPass<'tcx> for CtfeLimit
impl<'tcx> MirPass<'tcx> for DataflowConstProp
impl<'tcx> MirPass<'tcx> for DeadStoreElimination
impl<'tcx> MirPass<'tcx> for Derefer
impl<'tcx> MirPass<'tcx> for DestinationPropagation
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch
impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs
impl<'tcx> MirPass<'tcx> for ElaborateDrops
impl<'tcx> MirPass<'tcx> for EnumSizeOpt
impl<'tcx> MirPass<'tcx> for EraseDerefTemps
impl<'tcx> MirPass<'tcx> for ForceInline
impl<'tcx> MirPass<'tcx> for GVN
impl<'tcx> MirPass<'tcx> for ImpossiblePredicates
impl<'tcx> MirPass<'tcx> for Inline
impl<'tcx> MirPass<'tcx> for InstSimplify
impl<'tcx> MirPass<'tcx> for InstrumentCoverage
impl<'tcx> MirPass<'tcx> for JumpThreading
impl<'tcx> MirPass<'tcx> for LowerIntrinsics
impl<'tcx> MirPass<'tcx> for LowerSliceLenCalls
impl<'tcx> MirPass<'tcx> for MatchBranchSimplification
impl<'tcx> MirPass<'tcx> for MentionedItems
impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators
impl<'tcx> MirPass<'tcx> for PostAnalysisNormalize
impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx>
impl<'tcx> MirPass<'tcx> for ReferencePropagation
impl<'tcx> MirPass<'tcx> for RemoveNoopLandingPads
impl<'tcx> MirPass<'tcx> for RemovePlaceMention
impl<'tcx> MirPass<'tcx> for RemoveStorageMarkers
impl<'tcx> MirPass<'tcx> for RemoveUninitDrops
impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops
impl<'tcx> MirPass<'tcx> for RemoveZsts
impl<'tcx> MirPass<'tcx> for ReorderBasicBlocks
impl<'tcx> MirPass<'tcx> for ReorderLocals
impl<'tcx> MirPass<'tcx> for ScalarReplacementOfAggregates
impl<'tcx> MirPass<'tcx> for SimplifyCfg
impl<'tcx> MirPass<'tcx> for SimplifyComparisonIntegral
impl<'tcx> MirPass<'tcx> for SimplifyConstCondition
A pass that replaces a branch with a goto when its condition is known.