Skip to main content

rustc_mir_dataflow/framework/
mod.rs

1//! A framework that can express both [gen-kill] and generic dataflow problems.
2//!
3//! To use this framework, implement the [`Analysis`] trait. There used to be a `GenKillAnalysis`
4//! alternative trait for gen-kill analyses that would pre-compute the transfer function for each
5//! block. It was intended as an optimization, but it ended up not being any faster than
6//! `Analysis`.
7//!
8//! The `impls` module contains several examples of dataflow analyses.
9//!
10//! Then call `iterate_to_fixpoint` on your type that impls `Analysis` to get a `Results`. From
11//! there, you can use a `ResultsCursor` to inspect the fixpoint solution to your dataflow problem
12//! (good for inspecting a small number of locations), or implement the `ResultsVisitor` interface
13//! and use `visit_results` (good for inspecting many or all locations). The following example uses
14//! the `ResultsCursor` approach.
15//!
16//! ```ignore (cross-crate-imports)
17//! use rustc_const_eval::dataflow::Analysis; // Makes `iterate_to_fixpoint` available.
18//!
19//! fn do_my_analysis(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
20//!     let analysis = MyAnalysis::new()
21//!         .iterate_to_fixpoint(tcx, body, None)
22//!         .into_results_cursor(body);
23//!
24//!     // Print the dataflow state *after* each statement in the start block.
25//!     for (_, statement_index) in body.block_data[START_BLOCK].statements.iter_enumerated() {
26//!         cursor.seek_after(Location { block: START_BLOCK, statement_index });
27//!         let state = cursor.get();
28//!         println!("{:?}", state);
29//!     }
30//! }
31//! ```
32//!
33//! [gen-kill]: https://en.wikipedia.org/wiki/Data-flow_analysis#Bit_vector_problems
34
35use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
36use rustc_index::{Idx, IndexVec};
37use rustc_middle::bug;
38use rustc_middle::mir::{
39    self, BasicBlock, BasicBlockData, CallReturnPlaces, Location, TerminatorEdges,
40};
41use rustc_middle::ty::TyCtxt;
42use tracing::error;
43
44use self::graphviz::write_graphviz_results;
45use super::fmt::DebugWithContext;
46
47mod cursor;
48mod direction;
49pub mod fmt;
50pub mod graphviz;
51pub mod lattice;
52mod results;
53mod visitor;
54
55pub use self::cursor::ResultsCursor;
56pub use self::direction::{Backward, Direction, Forward};
57pub use self::lattice::{JoinSemiLattice, MaybeReachable};
58pub use self::results::{EntryStates, Results};
59pub use self::visitor::{ResultsVisitor, visit_results};
60
61/// Analysis domains are all bitsets of various kinds. This trait holds
62/// operations needed by all of them.
63pub trait BitSetExt<T> {
64    fn contains(&self, elem: T) -> bool;
65}
66
67impl<T: Idx> BitSetExt<T> for DenseBitSet<T> {
68    fn contains(&self, elem: T) -> bool {
69        self.contains(elem)
70    }
71}
72
73impl<T: Idx> BitSetExt<T> for MixedBitSet<T> {
74    fn contains(&self, elem: T) -> bool {
75        self.contains(elem)
76    }
77}
78
79/// A dataflow problem with an arbitrarily complex transfer function.
80///
81/// This trait specifies the lattice on which this analysis operates (the domain), its
82/// initial value at the entry point of each basic block, and various operations.
83///
84/// # Convergence
85///
86/// When implementing this trait it's possible to choose a transfer function such that the analysis
87/// does not reach fixpoint. To guarantee convergence, your transfer functions must maintain the
88/// following invariant:
89///
90/// > If the dataflow state **before** some point in the program changes to be greater
91/// than the prior state **before** that point, the dataflow state **after** that point must
92/// also change to be greater than the prior state **after** that point.
93///
94/// This invariant guarantees that the dataflow state at a given point in the program increases
95/// monotonically until fixpoint is reached. Note that this monotonicity requirement only applies
96/// to the same point in the program at different points in time. The dataflow state at a given
97/// point in the program may or may not be greater than the state at any preceding point.
98pub trait Analysis<'tcx> {
99    /// The type that holds the dataflow state at any given point in the program.
100    type Domain: Clone + JoinSemiLattice;
101
102    /// The direction of this analysis. Either `Forward` or `Backward`.
103    type Direction: Direction = Forward;
104
105    /// Auxiliary data used for analyzing `SwitchInt` terminators, if necessary.
106    type SwitchIntData = !;
107
108    /// A descriptive name for this analysis. Used only for debugging.
109    ///
110    /// This name should be brief and contain no spaces, periods or other characters that are not
111    /// suitable as part of a filename.
112    const NAME: &'static str;
113
114    /// Returns the initial value of the dataflow state upon entry to each basic block.
115    fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain;
116
117    /// Mutates the initial value of the dataflow state upon entry to the `START_BLOCK`.
118    ///
119    /// For backward analyses, initial state (besides the bottom value) is not yet supported. Trying
120    /// to mutate the initial state will result in a panic.
121    //
122    // FIXME: For backward dataflow analyses, the initial state should be applied to every basic
123    // block where control flow could exit the MIR body (e.g., those terminated with `return` or
124    // `resume`). It's not obvious how to handle `yield` points in coroutines, however.
125    fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain);
126
127    /// Given an `EffectIndex`, calls the appropriate `apply_*` method in the
128    /// {early,primary} x {statement,terminator} space.
129    ///
130    /// Do not override this; instead override one or more of the `apply_*` methods.
131    #[inline]
132    fn apply_effect<'mir>(
133        &self,
134        state: &mut Self::Domain,
135        block: BasicBlock,
136        block_data: &'mir BasicBlockData<'tcx>,
137        idx: EffectIndex,
138    ) {
139        let statement_index = idx.statement_index;
140        let terminator_index = block_data.statements.len();
141        let loc = Location { block, statement_index };
142        let is_terminator = statement_index == terminator_index;
143
144        if !is_terminator {
145            let statement = &block_data.statements[statement_index];
146            match idx.effect {
147                Effect::Early => self.apply_early_statement_effect(state, statement, loc),
148                Effect::Primary => self.apply_primary_statement_effect(state, statement, loc),
149            }
150        } else {
151            let terminator = block_data.terminator();
152            match idx.effect {
153                Effect::Early => self.apply_early_terminator_effect(state, terminator, loc),
154                Effect::Primary => {
155                    self.apply_primary_terminator_effect(state, terminator, loc);
156                }
157            }
158        }
159    }
160
161    /// Updates the current dataflow state with an "early" effect, i.e. one
162    /// that occurs immediately before the given statement.
163    ///
164    /// This method is useful if the consumer of the results of this analysis only needs to observe
165    /// *part* of the effect of a statement (e.g. for two-phase borrows). As a general rule,
166    /// analyses should not implement this without also implementing
167    /// `apply_primary_statement_effect`.
168    fn apply_early_statement_effect(
169        &self,
170        _state: &mut Self::Domain,
171        _statement: &mir::Statement<'tcx>,
172        _location: Location,
173    ) {
174    }
175
176    /// Updates the current dataflow state with the effect of evaluating a statement.
177    fn apply_primary_statement_effect(
178        &self,
179        state: &mut Self::Domain,
180        statement: &mir::Statement<'tcx>,
181        location: Location,
182    );
183
184    /// Updates the current dataflow state with an effect that occurs immediately *before* the
185    /// given terminator.
186    ///
187    /// This method is useful if the consumer of the results of this analysis needs only to observe
188    /// *part* of the effect of a terminator (e.g. for two-phase borrows). As a general rule,
189    /// analyses should not implement this without also implementing
190    /// `apply_primary_terminator_effect`.
191    fn apply_early_terminator_effect(
192        &self,
193        _state: &mut Self::Domain,
194        _terminator: &mir::Terminator<'tcx>,
195        _location: Location,
196    ) {
197    }
198
199    /// Gets the terminator edges. Used by forward analyses only. Called *before*
200    /// `apply_primary_terminator_effect` is applied; this might seem strange but in practice
201    /// `MaybeInitializedPlaces` needs that ordering and other analyses work with either ordering.
202    fn get_terminator_edges<'mir>(
203        &self,
204        _state: &Self::Domain,
205        terminator: &'mir mir::Terminator<'tcx>,
206        _location: Location,
207    ) -> TerminatorEdges<'mir, 'tcx> {
208        terminator.edges()
209    }
210
211    /// Updates the current dataflow state with the effect of evaluating a terminator.
212    ///
213    /// The effect of a successful return from a `Call` terminator should **not** be accounted for
214    /// in this function. That should go in `apply_call_return_effect`. For example, in the
215    /// `InitializedPlaces` analyses, the return place for a function call is not marked as
216    /// initialized here.
217    fn apply_primary_terminator_effect(
218        &self,
219        _state: &mut Self::Domain,
220        _terminator: &mir::Terminator<'tcx>,
221        _location: Location,
222    ) {
223    }
224
225    /* Edge-specific effects */
226
227    /// Updates the current dataflow state with the effect of a successful return from a `Call`
228    /// terminator.
229    ///
230    /// This is separate from `apply_primary_terminator_effect` to properly track state across
231    /// unwind edges.
232    fn apply_call_return_effect(
233        &self,
234        _state: &mut Self::Domain,
235        _block: BasicBlock,
236        _return_places: CallReturnPlaces<'_, 'tcx>,
237    ) {
238    }
239
240    /// Used to update the current dataflow state with the effect of taking a particular branch in
241    /// a `SwitchInt` terminator.
242    ///
243    /// Unlike the other edge-specific effects, which are allowed to mutate `Self::Domain`
244    /// directly, overriders of this method must return a `Self::SwitchIntData` value (wrapped in
245    /// `Some`). The `apply_switch_int_edge_effect` method will then be called once for each
246    /// outgoing edge and will have access to the dataflow state that will be propagated along that
247    /// edge, and also the `Self::SwitchIntData` value.
248    ///
249    /// This interface is somewhat more complex than the other visitor-like "effect" methods.
250    /// However, it is both more ergonomic—callers don't need to recompute or cache information
251    /// about a given `SwitchInt` terminator for each one of its edges—and more efficient—the
252    /// engine doesn't need to clone the exit state for a block unless
253    /// `get_switch_int_data` is actually called.
254    fn get_switch_int_data(
255        &self,
256        _block: mir::BasicBlock,
257        _targets: &mir::SwitchTargets,
258        _discr: &mir::Operand<'tcx>,
259    ) -> Option<Self::SwitchIntData> {
260        None
261    }
262
263    /// See comments on `get_switch_int_data`.
264    fn apply_switch_int_edge_effect(
265        &self,
266        _state: &mut Self::Domain,
267        _data: &mut Self::SwitchIntData,
268        _target_idx: SwitchTargetIndex,
269    ) {
270        ::core::panicking::panic("internal error: entered unreachable code");unreachable!();
271    }
272
273    /* Extension methods */
274
275    /// Finds the fixpoint for this dataflow problem.
276    ///
277    /// You shouldn't need to override this. Its purpose is to enable method chaining like so:
278    ///
279    /// ```ignore (cross-crate-imports)
280    /// let results = MyAnalysis::new(tcx, body)
281    ///     .iterate_to_fixpoint(tcx, body, None)
282    ///     .into_results_cursor(body);
283    /// ```
284    /// You can optionally add a `pass_name` to the graphviz output for this particular run of a
285    /// dataflow analysis. Some analyses are run multiple times in the compilation pipeline.
286    /// Without a `pass_name` to differentiates them, only the results for the latest run will be
287    /// saved.
288    fn iterate_to_fixpoint<'mir>(
289        self,
290        tcx: TyCtxt<'tcx>,
291        body: &'mir mir::Body<'tcx>,
292        pass_name: Option<&'static str>,
293    ) -> Results<'tcx, Self>
294    where
295        Self: Sized,
296        Self::Domain: DebugWithContext<Self>,
297    {
298        let mut entry_states =
299            IndexVec::from_fn_n(|_| self.bottom_value(body), body.basic_blocks.len());
300        self.initialize_start_block(body, &mut entry_states[mir::START_BLOCK]);
301
302        if Self::Direction::IS_BACKWARD && entry_states[mir::START_BLOCK] != self.bottom_value(body)
303        {
304            ::rustc_middle::util::bug::bug_fmt(format_args!("`initialize_start_block` is not yet supported for backward dataflow analyses"));bug!("`initialize_start_block` is not yet supported for backward dataflow analyses");
305        }
306
307        // Forward analyses use a reverse postorder (`rpo`). Every reachable basic block has a
308        // *rank*: its position within `rpo`. Rank order is dataflow order: for every edge A -> B
309        // that is not a back edge, rank(A) < rank(B). This is independent of basic block numbering
310        // (which depends on the vagaries of CFG construction).
311        //
312        // The CFG traversal uses a "min-rank" algorithm. First, all reachable basic blocks are
313        // marked as dirty. The loop-head invariant is that `curr_rank` always points to the
314        // minimum-rank dirty block in `rpo`. Before processing that block we mark it as clean. If
315        // the processing dirties a block with a rank lower than or equal to `curr_rank` (via a
316        // back edge, which could be an edge-to-self) then `curr_rank` is set to that
317        // lower-or-equal rank. After the block is processed, if `curr_rank` doesn't point to a
318        // dirty block it is moved to the next dirty block, and we iterate again.
319        //
320        // This algorithm ensures each basic block is processed only after all its dirty
321        // predecessors (ignoring back edges). When a back edge dirties an earlier block we return
322        // to that earlier block immediately, which avoids processing later blocks with possibly
323        // soon-to-be-stale information. Loop-free code is processed in a single pass.
324        //
325        // Backward analyses: we want a postorder instead of a reverse postorder, but we also want
326        // to avoid the cost of adding a `postorder` field to `mir::basic_blocks::Cache`. We can
327        // fake a postorder traversal cheaply by using a reverse postorder and flipping the rank
328        // mapping. There is also one wrinkle involving unreachable blocks; see below.
329
330        impl ::std::fmt::Debug for BasicBlockRank {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("bbr{0}", self.as_u32()))
    }
}rustc_index::newtype_index! {
331            #[orderable]
332            #[debug_format = "bbr{}"]
333            struct BasicBlockRank {}
334        }
335
336        let rpo: &[BasicBlock] = body.basic_blocks.reverse_postorder();
337        let last = rpo.len() - 1;
338
339        let mut ranks: IndexVec<BasicBlock, Option<BasicBlockRank>> =
340            IndexVec::from_elem_n(None, body.basic_blocks.len());
341        for (i, &bb) in rpo.iter().enumerate() {
342            let rank = if Self::Direction::IS_FORWARD { i } else { last - i };
343            ranks[bb] = Some(BasicBlockRank::new(rank));
344        }
345
346        let mut dirty: DenseBitSet<BasicBlockRank> = DenseBitSet::new_filled(rpo.len());
347        let mut curr_rank = BasicBlockRank::ZERO;
348
349        // `state` is not actually used between iterations; this is just an optimization to avoid
350        // reallocating every iteration.
351        let mut state = self.bottom_value(body);
352
353        loop {
354            let i = curr_rank.as_usize();
355            let bb = rpo[if Self::Direction::IS_FORWARD { i } else { last - i }];
356            if true {
    if !dirty.contains(curr_rank) {
        ::core::panicking::panic("assertion failed: dirty.contains(curr_rank)")
    };
};debug_assert!(dirty.contains(curr_rank)); // check invariant
357            dirty.remove(curr_rank); // invariant temporarily broken
358
359            state.clone_from(&entry_states[bb]);
360            let prop = |target: BasicBlock, state: &Self::Domain| {
361                // A backward analysis may encounter an unreachable block, because a predecessor
362                // of a reachable block may be unreachable. Ignore any such block. (In contrast, in
363                // a forward analysis any successor of a reachable block must be reachable.)
364                let target_rank = ranks[target];
365                if Self::Direction::IS_BACKWARD && target_rank.is_none() {
366                    return;
367                }
368                let target_rank = target_rank.unwrap();
369
370                let set_changed = entry_states[target].join(state);
371                if set_changed {
372                    dirty.insert(target_rank);
373                    curr_rank = curr_rank.min(target_rank);
374                }
375            };
376            Self::Direction::apply_effects_in_block(&self, body, &mut state, bb, &body[bb], prop);
377
378            match dirty.first_set_at_or_after(curr_rank) {
379                Some(rank) => curr_rank = rank, // broken invariant re-established
380                None => break,                  // no more dirty blocks; finish
381            }
382        }
383
384        let results = Results { analysis: self, entry_states };
385
386        if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
387            let res = write_graphviz_results(tcx, body, &results, pass_name);
388            if let Err(e) = res {
389                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_mir_dataflow/src/framework/mod.rs:389",
                        "rustc_mir_dataflow::framework", ::tracing::Level::ERROR,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/framework/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(389u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::framework"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::ERROR <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::ERROR <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("Failed to write graphviz dataflow results: {0}",
                                                    e) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};error!("Failed to write graphviz dataflow results: {}", e);
390            }
391        }
392
393        results
394    }
395}
396
397#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SwitchTargetIndex {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            SwitchTargetIndex::Normal(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Normal",
                    &__self_0),
            SwitchTargetIndex::Otherwise =>
                ::core::fmt::Formatter::write_str(f, "Otherwise"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for SwitchTargetIndex {
    #[inline]
    fn clone(&self) -> SwitchTargetIndex {
        let _: ::core::clone::AssertParamIsClone<usize>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SwitchTargetIndex { }Copy)]
398pub enum SwitchTargetIndex {
399    // Index of a normal switch target.
400    Normal(usize),
401    // The final "otherwise" fallback target.
402    Otherwise,
403}
404
405/// The legal operations for a transfer function in a gen/kill problem.
406pub trait GenKill<T> {
407    /// Inserts `elem` into the state vector.
408    fn gen_(&mut self, elem: T);
409
410    /// Removes `elem` from the state vector.
411    fn kill(&mut self, elem: T);
412
413    /// Calls `gen` for each element in `elems`.
414    fn gen_all(&mut self, elems: impl IntoIterator<Item = T>) {
415        for elem in elems {
416            self.gen_(elem);
417        }
418    }
419
420    /// Calls `kill` for each element in `elems`.
421    fn kill_all(&mut self, elems: impl IntoIterator<Item = T>) {
422        for elem in elems {
423            self.kill(elem);
424        }
425    }
426}
427
428impl<T: Idx> GenKill<T> for DenseBitSet<T> {
429    fn gen_(&mut self, elem: T) {
430        self.insert(elem);
431    }
432
433    fn kill(&mut self, elem: T) {
434        self.remove(elem);
435    }
436}
437
438impl<T: Idx> GenKill<T> for MixedBitSet<T> {
439    fn gen_(&mut self, elem: T) {
440        self.insert(elem);
441    }
442
443    fn kill(&mut self, elem: T) {
444        self.remove(elem);
445    }
446}
447
448impl<T, S: GenKill<T>> GenKill<T> for MaybeReachable<S> {
449    fn gen_(&mut self, elem: T) {
450        match self {
451            // If the state is not reachable, adding an element does nothing.
452            MaybeReachable::Unreachable => {}
453            MaybeReachable::Reachable(set) => set.gen_(elem),
454        }
455    }
456
457    fn kill(&mut self, elem: T) {
458        match self {
459            // If the state is not reachable, killing an element does nothing.
460            MaybeReachable::Unreachable => {}
461            MaybeReachable::Reachable(set) => set.kill(elem),
462        }
463    }
464}
465
466// NOTE: DO NOT CHANGE VARIANT ORDER. The derived `Ord` impls rely on the current order.
467#[derive(#[automatically_derived]
impl ::core::clone::Clone for Effect {
    #[inline]
    fn clone(&self) -> Effect { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Effect { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for Effect {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Effect::Early => "Early",
                Effect::Primary => "Primary",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Effect {
    #[inline]
    fn eq(&self, other: &Effect) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Effect {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Effect {
    #[inline]
    fn partial_cmp(&self, other: &Effect)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Effect {
    #[inline]
    fn cmp(&self, other: &Effect) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord)]
468enum Effect {
469    /// The "early" effect (e.g., `apply_early_statement_effect`) for a statement/terminator.
470    Early,
471
472    /// The "primary" effect (e.g., `apply_primary_statement_effect`) for a statement/terminator.
473    Primary,
474}
475
476impl Effect {
477    const fn at_index(self, statement_index: usize) -> EffectIndex {
478        EffectIndex { effect: self, statement_index }
479    }
480}
481
482#[derive(#[automatically_derived]
impl ::core::clone::Clone for EffectIndex {
    #[inline]
    fn clone(&self) -> EffectIndex {
        let _: ::core::clone::AssertParamIsClone<usize>;
        let _: ::core::clone::AssertParamIsClone<Effect>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for EffectIndex { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for EffectIndex {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "EffectIndex",
            "statement_index", &self.statement_index, "effect", &&self.effect)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for EffectIndex {
    #[inline]
    fn eq(&self, other: &EffectIndex) -> bool {
        self.statement_index == other.statement_index &&
            self.effect == other.effect
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for EffectIndex {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<usize>;
        let _: ::core::cmp::AssertParamIsEq<Effect>;
    }
}Eq)]
483pub struct EffectIndex {
484    statement_index: usize,
485    effect: Effect,
486}
487
488#[cfg(test)]
489mod tests;