Skip to main content

rustc_infer/infer/region_constraints/
leak_check.rs

1use rustc_data_structures::fx::FxIndexMap;
2use rustc_data_structures::graph::scc::Sccs;
3use rustc_data_structures::graph::vec_graph::VecGraph;
4use rustc_index::Idx;
5use rustc_middle::ty::error::TypeError;
6use rustc_span::span_bug;
7use rustc_type_ir::region_constraint::LeafRegionConstraint;
8use tracing::{debug, instrument};
9
10use super::*;
11use crate::infer::relate::RelateResult;
12use crate::infer::snapshot::CombinedSnapshot;
13
14impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
15    /// Searches new universes created during `snapshot`, looking for
16    /// placeholders that may "leak" out from the universes they are contained
17    /// in. If any leaking placeholders are found, then an `Err` is returned
18    /// (typically leading to the snapshot being reversed). This algorithm
19    /// only looks at placeholders which cannot be named by `outer_universe`,
20    /// as this is the universe we're currently checking for a leak.
21    ///
22    /// The leak check *used* to be the only way we had to handle higher-ranked
23    /// obligations. Now that we have integrated universes into the region
24    /// solvers, this is no longer the case, but we retain the leak check for
25    /// backwards compatibility purposes. In particular, it lets us make "early"
26    /// decisions about whether a region error will be reported that are used in
27    /// coherence and elsewhere -- see #56105 and #59490 for more details. The
28    /// eventual fate of the leak checker is not yet settled.
29    ///
30    /// The leak checker works by searching for the following error patterns:
31    ///
32    /// * P1: P2, where P1 != P2
33    /// * P1: R, where R is in some universe that cannot name P1
34    ///
35    /// The idea here is that each of these patterns represents something that
36    /// the region solver would eventually report as an error, so we can detect
37    /// the error early. There is a fly in the ointment, though, in that this is
38    /// not entirely true. In particular, in the future, we may extend the
39    /// environment with implied bounds or other info about how placeholders
40    /// relate to regions in outer universes. In that case, `P1: R` for example
41    /// might become solvable.
42    ///
43    /// # Summary of the implementation
44    ///
45    /// The leak checks as follows. First, we construct a graph where `R2: R1`
46    /// implies `R2 -> R1`, and we compute the SCCs.
47    ///
48    /// For each SCC S, we compute:
49    ///
50    /// * what placeholder P it must be equal to, if any
51    ///   * if there are multiple placeholders that must be equal, report an error because `P1: P2`
52    /// * the minimum universe of its constituents
53    ///
54    /// Then we walk the SCCs in dependency order and compute
55    ///
56    /// * what placeholder they must outlive transitively
57    ///   * if they must also be equal to a placeholder, report an error because `P1: P2`
58    /// * minimum universe U of all SCCs they must outlive
59    ///   * if they must also be equal to a placeholder P, and U cannot name P, report an error, as
60    ///     that indicates `P: R` and `R` is in an incompatible universe
61    ///
62    /// To improve performance and for the old trait solver caching to be sound, this takes
63    /// an optional snapshot in which case we only look at region constraints added in that
64    /// snapshot. If we were to not do that the `leak_check` during evaluation can rely on
65    /// region constraints added outside of that evaluation. As that is not reflected in the
66    /// cache key this would be unsound.
67    ///
68    /// # Historical note
69    ///
70    /// Older variants of the leak check used to report errors for these
71    /// patterns, but we no longer do:
72    ///
73    /// * R: P1, even if R cannot name P1, because R = 'static is a valid sol'n
74    /// * R: P1, R: P2, as above
75    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("leak_check",
                                "rustc_infer::infer::region_constraints::leak_check",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs"),
                                ::tracing_core::__macro_support::Option::Some(75u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints::leak_check"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("outer_universe")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("outer_universe");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("max_universe")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("max_universe");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&outer_universe)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&max_universe)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RelateResult<'tcx, ()> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if outer_universe == max_universe { return Ok(()); }
                        let mini_graph =
                            MiniGraph::new(&self, only_consider_snapshot,
                                tcx.assumptions_on_binders());
                        let mut leak_check =
                            LeakCheck::new(tcx, outer_universe, max_universe,
                                mini_graph, self);
                        leak_check.assign_placeholder_values()?;
                        leak_check.propagate_scc_value()?;
                        Ok(())
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:75",
                        "rustc_infer::infer::region_constraints::leak_check",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs"),
                        ::tracing_core::__macro_support::Option::Some(75u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints::leak_check"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::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(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, tcx, only_consider_snapshot), ret)]
76    pub fn leak_check(
77        self,
78        tcx: TyCtxt<'tcx>,
79        outer_universe: ty::UniverseIndex,
80        max_universe: ty::UniverseIndex,
81        only_consider_snapshot: Option<&CombinedSnapshot<'tcx>>,
82    ) -> RelateResult<'tcx, ()> {
83        if outer_universe == max_universe {
84            return Ok(());
85        }
86
87        let mini_graph =
88            MiniGraph::new(&self, only_consider_snapshot, tcx.assumptions_on_binders());
89
90        let mut leak_check = LeakCheck::new(tcx, outer_universe, max_universe, mini_graph, self);
91        leak_check.assign_placeholder_values()?;
92        leak_check.propagate_scc_value()?;
93        Ok(())
94    }
95}
96
97struct LeakCheck<'a, 'tcx> {
98    tcx: TyCtxt<'tcx>,
99    outer_universe: ty::UniverseIndex,
100    mini_graph: MiniGraph<'tcx>,
101    rcc: RegionConstraintCollector<'a, 'tcx>,
102
103    // Initially, for each SCC S, stores a placeholder `P` such that `S = P`
104    // must hold.
105    //
106    // Later, during the [`LeakCheck::propagate_scc_value`] function, this array
107    // is repurposed to store some placeholder `P` such that the weaker
108    // condition `S: P` must hold. (This is true if `S: S1` transitively and `S1
109    // = P`.)
110    scc_placeholders: IndexVec<LeakCheckScc, Option<ty::PlaceholderRegion<'tcx>>>,
111
112    // For each SCC S, track the minimum universe that flows into it. Note that
113    // this is both the minimum of the universes for every region that is a
114    // member of the SCC, but also if you have `R1: R2`, then the universe of
115    // `R2` must be less than the universe of `R1` (i.e., `R1` flows `R2`). To
116    // see that, imagine that you have `P1: R` -- in that case, `R` must be
117    // either the placeholder `P1` or the empty region in that same universe.
118    //
119    // To detect errors, we look for an SCC S where the values in
120    // `scc_placeholders[S]` (if any) cannot be stored into `scc_universes[S]`.
121    scc_universes: IndexVec<LeakCheckScc, SccUniverse<'tcx>>,
122}
123
124impl<'a, 'tcx> LeakCheck<'a, 'tcx> {
125    fn new(
126        tcx: TyCtxt<'tcx>,
127        outer_universe: ty::UniverseIndex,
128        max_universe: ty::UniverseIndex,
129        mini_graph: MiniGraph<'tcx>,
130        rcc: RegionConstraintCollector<'a, 'tcx>,
131    ) -> Self {
132        let dummy_scc_universe = SccUniverse { universe: max_universe, region: None };
133        let num_sccs = mini_graph.sccs.num_sccs();
134        Self {
135            tcx,
136            outer_universe,
137            mini_graph,
138            rcc,
139            scc_placeholders: IndexVec::from_elem_n(None, num_sccs),
140            scc_universes: IndexVec::from_elem_n(dummy_scc_universe, num_sccs),
141        }
142    }
143
144    /// Compute what placeholders (if any) each SCC must be equal to.
145    /// Also compute the minimum universe of all the regions in each SCC.
146    fn assign_placeholder_values(&mut self) -> RelateResult<'tcx, ()> {
147        // First walk: find each placeholder that is from a newly created universe.
148        for (region, leak_check_node) in &self.mini_graph.nodes {
149            let scc = self.mini_graph.sccs.scc(*leak_check_node);
150
151            // Set the universe of each SCC to be the minimum of its constituent universes
152            let universe = self.rcc.universe(*region);
153            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:153",
                        "rustc_infer::infer::region_constraints::leak_check",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs"),
                        ::tracing_core::__macro_support::Option::Some(153u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints::leak_check"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::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!("assign_placeholder_values: scc={0:?} universe={1:?} region={2:?}",
                                                    scc, universe, region) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
154                "assign_placeholder_values: scc={:?} universe={:?} region={:?}",
155                scc, universe, region
156            );
157            self.scc_universes[scc].take_min(universe, *region);
158
159            // Detect those SCCs that directly contain a placeholder
160            if let ty::RePlaceholder(placeholder) = region.kind() {
161                if self.outer_universe.cannot_name(placeholder.universe) {
162                    // Update `scc_placeholders` to account for the fact that `P: S` must hold.
163                    match self.scc_placeholders[scc] {
164                        Some(p) => {
165                            {
    match (&p, &placeholder) {
        (left_val, right_val) => {
            if *left_val == *right_val {
                let kind = ::core::panicking::AssertKind::Ne;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    }
};assert_ne!(p, placeholder);
166                            return Err(self.placeholder_error(p, placeholder));
167                        }
168                        None => {
169                            self.scc_placeholders[scc] = Some(placeholder);
170                        }
171                    }
172                }
173            }
174        }
175
176        Ok(())
177    }
178
179    /// For each SCC S, iterate over each successor S1 where `S: S1`:
180    ///
181    /// * Compute
182    /// Iterate over each SCC `S` and ensure that, for each `S1` where `S1: S`,
183    /// `universe(S) <= universe(S1)`. This executes after
184    /// `assign_placeholder_values`, so `universe(S)` is already the minimum
185    /// universe of any of its direct constituents.
186    fn propagate_scc_value(&mut self) -> RelateResult<'tcx, ()> {
187        // Loop invariants:
188        //
189        // On start of the loop iteration for `scc1`:
190        //
191        // * `scc_universes[scc1]` contains the minimum universe of the
192        //   constituents of `scc1`
193        // * `scc_placeholder[scc1]` stores the placeholder that `scc1` must
194        //   be equal to (if any)
195        //
196        // For each successor `scc2` where `scc1: scc2`:
197        //
198        // * `scc_placeholder[scc2]` stores some placeholder `P` where
199        //   `scc2: P` (if any)
200        // * `scc_universes[scc2]` contains the minimum universe of the
201        //   constituents of `scc2` and any of its successors
202        for scc1 in self.mini_graph.sccs.all_sccs() {
203            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:203",
                        "rustc_infer::infer::region_constraints::leak_check",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs"),
                        ::tracing_core::__macro_support::Option::Some(203u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints::leak_check"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::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!("propagate_scc_value: scc={0:?} with universe {1:?}",
                                                    scc1, self.scc_universes[scc1]) as
                                            &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
204                "propagate_scc_value: scc={:?} with universe {:?}",
205                scc1, self.scc_universes[scc1]
206            );
207
208            // Walk over each `scc2` such that `scc1: scc2` and compute:
209            //
210            // * `scc1_universe`: the minimum universe of `scc2` and the constituents of `scc1`
211            // * `succ_bound`: placeholder `P` that the successors must outlive, if any (if there
212            //   are multiple, we pick one arbitrarily)
213            let mut scc1_universe = self.scc_universes[scc1];
214            let mut succ_bound = None;
215            for &scc2 in self.mini_graph.sccs.successors(scc1) {
216                let SccUniverse { universe: scc2_universe, region: scc2_region } =
217                    self.scc_universes[scc2];
218
219                scc1_universe.take_min(scc2_universe, scc2_region.unwrap());
220
221                if let Some(b) = self.scc_placeholders[scc2] {
222                    succ_bound = Some(b);
223                }
224            }
225
226            // Update minimum universe of scc1.
227            self.scc_universes[scc1] = scc1_universe;
228
229            // At this point, `scc_placeholders[scc1]` stores the placeholder that
230            // `scc1` must be equal to, if any.
231            if let Some(scc1_placeholder) = self.scc_placeholders[scc1] {
232                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:232",
                        "rustc_infer::infer::region_constraints::leak_check",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs"),
                        ::tracing_core::__macro_support::Option::Some(232u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints::leak_check"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::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!("propagate_scc_value: scc1={0:?} placeholder={1:?} scc1_universe={2:?}",
                                                    scc1, scc1_placeholder, scc1_universe) as
                                            &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
233                    "propagate_scc_value: scc1={:?} placeholder={:?} scc1_universe={:?}",
234                    scc1, scc1_placeholder, scc1_universe
235                );
236
237                // Check if `P1: R` for some `R` in a universe that cannot name
238                // P1. That's an error.
239                if scc1_universe.universe.cannot_name(scc1_placeholder.universe) {
240                    return Err(self.error(scc1_placeholder, scc1_universe.region.unwrap()));
241                }
242
243                // Check if we have some placeholder where `S: P2`
244                // (transitively). In that case, since `S = P1`, that implies
245                // `P1: P2`, which is an error condition.
246                if let Some(scc2_placeholder) = succ_bound {
247                    {
    match (&scc1_placeholder, &scc2_placeholder) {
        (left_val, right_val) => {
            if *left_val == *right_val {
                let kind = ::core::panicking::AssertKind::Ne;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    }
};assert_ne!(scc1_placeholder, scc2_placeholder);
248                    return Err(self.placeholder_error(scc1_placeholder, scc2_placeholder));
249                }
250            } else {
251                // Otherwise, we can reach a placeholder if some successor can.
252                self.scc_placeholders[scc1] = succ_bound;
253            }
254
255            // At this point, `scc_placeholder[scc1]` stores some placeholder that `scc1` must
256            // outlive (if any).
257        }
258        Ok(())
259    }
260
261    fn placeholder_error(
262        &self,
263        placeholder1: ty::PlaceholderRegion<'tcx>,
264        placeholder2: ty::PlaceholderRegion<'tcx>,
265    ) -> TypeError<'tcx> {
266        self.error(placeholder1, ty::Region::new_placeholder(self.tcx, placeholder2))
267    }
268
269    fn error(
270        &self,
271        placeholder: ty::PlaceholderRegion<'tcx>,
272        other_region: ty::Region<'tcx>,
273    ) -> TypeError<'tcx> {
274        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:274",
                        "rustc_infer::infer::region_constraints::leak_check",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/522d96a5707c154b15960db186c03b84a52b4efb/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs"),
                        ::tracing_core::__macro_support::Option::Some(274u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::region_constraints::leak_check"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::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!("error: placeholder={0:?}, other_region={1:?}",
                                                    placeholder, other_region) as
                                            &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
275        TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound, other_region)
276    }
277}
278
279// States we need to distinguish:
280//
281// * must be equal to a placeholder (i.e., a placeholder is in the SCC)
282//     * it could conflict with some other regions in the SCC in different universes
283//     * or a different placeholder
284// * `P1: S` and `S` must be equal to a placeholder
285// * `P1: S` and `S` is in an incompatible universe
286//
287// So if we
288//
289// (a) compute which placeholder (if any) each SCC must be equal to
290// (b) compute its minimum universe
291// (c) compute *some* placeholder where `S: P1` (any one will do)
292//
293// then we get an error if:
294//
295// - it must be equal to a placeholder `P1` and minimum universe cannot name `P1`
296// - `S: P1` and minimum universe cannot name `P1`
297// - `S: P1` and we must be equal to `P2`
298//
299// So we want to track:
300//
301// * Equal placeholder (if any)
302// * Some bounding placeholder (if any)
303// * Minimum universe
304//
305// * We compute equal placeholder + minimum universe of constituents in first pass
306// * Then we walk in order and compute from our dependencies `S1` where `S: S1` (`S -> S1`)
307//   * bounding placeholder (if any)
308//   * minimum universe
309// * And if we must be equal to a placeholder then we check it against
310//   * minimum universe
311//   * no bounding placeholder
312
313/// Tracks the "minimum universe" for each SCC, along with some region that
314/// caused it to change.
315#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for SccUniverse<'tcx>
    {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for SccUniverse<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for SccUniverse<'tcx>
    {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<ty::UniverseIndex>;
        let _: ::core::clone::AssertParamIsClone<Option<ty::Region<'tcx>>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for SccUniverse<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "SccUniverse universe region", &self.universe, &&self.region)
    }
}Debug)]
316struct SccUniverse<'tcx> {
317    /// For some SCC S, the minimum universe of:
318    ///
319    /// * each region R in S
320    /// * each SCC S1 such that S: S1
321    universe: ty::UniverseIndex,
322
323    /// Some region that caused `universe` to be what it is.
324    region: Option<ty::Region<'tcx>>,
325}
326
327impl<'tcx> SccUniverse<'tcx> {
328    /// If `universe` is less than our current universe, then update
329    /// `self.universe` and `self.region`.
330    fn take_min(&mut self, universe: ty::UniverseIndex, region: ty::Region<'tcx>) {
331        if universe < self.universe || self.region.is_none() {
332            self.universe = universe;
333            self.region = Some(region);
334        }
335    }
336}
337
338#[automatically_derived]impl ::core::marker::Copy for LeakCheckNode { }
impl LeakCheckNode {
    #[doc = r" Maximum value the index can take, as a `u32`."]
    const MAX_AS_U32: u32 = 0xFFFF_FF00;
    #[doc = r" Maximum value the index can take."]
    const MAX: Self = Self::from_u32(0xFFFF_FF00);
    #[doc = r" Zero value of the index."]
    const ZERO: Self = Self::from_u32(0);
    #[doc = r" Creates a new index from a given `usize`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    const fn from_usize(value: usize) -> Self {
        if !(value <= (0xFFFF_FF00 as usize)) {
            ::core::panicking::panic("assertion failed: value <= (0xFFFF_FF00 as usize)")
        };
        unsafe { Self::from_u32_unchecked(value as u32) }
    }
    #[doc = r" Creates a new index from a given `u32`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    const fn from_u32(value: u32) -> Self {
        if !(value <= 0xFFFF_FF00) {
            ::core::panicking::panic("assertion failed: value <= 0xFFFF_FF00")
        };
        unsafe { Self::from_u32_unchecked(value) }
    }
    #[doc = r" Creates a new index from a given `u16`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    const fn from_u16(value: u16) -> Self {
        let value = value as u32;
        if !(value <= 0xFFFF_FF00) {
            ::core::panicking::panic("assertion failed: value <= 0xFFFF_FF00")
        };
        unsafe { Self::from_u32_unchecked(value) }
    }
    #[doc = r" Creates a new index from a given `u32`."]
    #[doc = r""]
    #[doc = r" # Safety"]
    #[doc = r""]
    #[doc =
    r" The provided value must be less than or equal to the maximum value for the newtype."]
    #[doc =
    r" Providing a value outside this range is undefined due to layout restrictions."]
    #[doc = r""]
    #[doc = r" Prefer using `from_u32`."]
    #[inline]
    const unsafe fn from_u32_unchecked(value: u32) -> Self {
        Self {
            private_use_as_methods_instead: unsafe {
                std::mem::transmute(value)
            },
        }
    }
    #[doc = r" Extracts the value of this index as a `usize`."]
    #[inline]
    const fn index(self) -> usize { self.as_usize() }
    #[doc = r" Extracts the value of this index as a `u32`."]
    #[inline]
    const fn as_u32(self) -> u32 {
        unsafe { std::mem::transmute(self.private_use_as_methods_instead) }
    }
    #[doc = r" Extracts the value of this index as a `usize`."]
    #[inline]
    const fn as_usize(self) -> usize { self.as_u32() as usize }
}
impl std::ops::Add<usize> for LeakCheckNode {
    type Output = Self;
    #[inline]
    fn add(self, other: usize) -> Self {
        Self::from_usize(self.index() + other)
    }
}
impl std::ops::AddAssign<usize> for LeakCheckNode {
    #[inline]
    fn add_assign(&mut self, other: usize) { *self = *self + other; }
}
impl rustc_index::Idx for LeakCheckNode {
    #[inline]
    fn new(value: usize) -> Self { Self::from_usize(value) }
    #[inline]
    fn index(self) -> usize { self.as_usize() }
}
impl ::std::iter::Step for LeakCheckNode {
    #[inline]
    fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
        <usize as
                ::std::iter::Step>::steps_between(&Self::index(*start),
            &Self::index(*end))
    }
    #[inline]
    fn forward_checked(start: Self, u: usize) -> Option<Self> {
        Self::index(start).checked_add(u).map(Self::from_usize)
    }
    #[inline]
    fn backward_checked(start: Self, u: usize) -> Option<Self> {
        Self::index(start).checked_sub(u).map(Self::from_usize)
    }
    #[inline]
    fn forward_overflowing(start: Self, u: usize) -> (Self, bool) {
        let (s, o) = Self::index(start).overflowing_add(u);
        (Self::from_usize(s), o)
    }
    #[inline]
    fn backward_overflowing(start: Self, u: usize) -> (Self, bool) {
        let (s, o) = Self::index(start).overflowing_sub(u);
        (Self::from_usize(s), o)
    }
}
impl ::std::cmp::Ord for LeakCheckNode {
    #[inline]
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.as_u32().cmp(&other.as_u32())
    }
}
impl ::std::cmp::PartialOrd for LeakCheckNode {
    #[inline]
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl From<LeakCheckNode> for u32 {
    #[inline]
    fn from(v: LeakCheckNode) -> u32 { v.as_u32() }
}
impl From<LeakCheckNode> for usize {
    #[inline]
    fn from(v: LeakCheckNode) -> usize { v.as_usize() }
}
impl From<usize> for LeakCheckNode {
    #[inline]
    fn from(value: usize) -> Self { Self::from_usize(value) }
}
impl From<u32> for LeakCheckNode {
    #[inline]
    fn from(value: u32) -> Self { Self::from_u32(value) }
}
impl ::std::cmp::Eq for LeakCheckNode {}
impl ::std::cmp::PartialEq for LeakCheckNode {
    fn eq(&self, other: &Self) -> bool { self.as_u32().eq(&other.as_u32()) }
}
impl ::std::marker::StructuralPartialEq for LeakCheckNode {}
impl ::std::hash::Hash for LeakCheckNode {
    fn hash<H: ::std::hash::Hasher>(&self, state: &mut H) {
        self.as_u32().hash(state)
    }
}
impl ::std::fmt::Debug for LeakCheckNode {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("LeakCheckNode({0})", self.as_u32()))
    }
}rustc_index::newtype_index! {
339    #[orderable]
340    #[debug_format = "LeakCheckNode({})"]
341    struct LeakCheckNode {}
342}
343
344#[automatically_derived]impl ::core::marker::Copy for LeakCheckScc { }
impl LeakCheckScc {
    #[doc = r" Maximum value the index can take, as a `u32`."]
    const MAX_AS_U32: u32 = 0xFFFF_FF00;
    #[doc = r" Maximum value the index can take."]
    const MAX: Self = Self::from_u32(0xFFFF_FF00);
    #[doc = r" Zero value of the index."]
    const ZERO: Self = Self::from_u32(0);
    #[doc = r" Creates a new index from a given `usize`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    const fn from_usize(value: usize) -> Self {
        if !(value <= (0xFFFF_FF00 as usize)) {
            ::core::panicking::panic("assertion failed: value <= (0xFFFF_FF00 as usize)")
        };
        unsafe { Self::from_u32_unchecked(value as u32) }
    }
    #[doc = r" Creates a new index from a given `u32`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    const fn from_u32(value: u32) -> Self {
        if !(value <= 0xFFFF_FF00) {
            ::core::panicking::panic("assertion failed: value <= 0xFFFF_FF00")
        };
        unsafe { Self::from_u32_unchecked(value) }
    }
    #[doc = r" Creates a new index from a given `u16`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    const fn from_u16(value: u16) -> Self {
        let value = value as u32;
        if !(value <= 0xFFFF_FF00) {
            ::core::panicking::panic("assertion failed: value <= 0xFFFF_FF00")
        };
        unsafe { Self::from_u32_unchecked(value) }
    }
    #[doc = r" Creates a new index from a given `u32`."]
    #[doc = r""]
    #[doc = r" # Safety"]
    #[doc = r""]
    #[doc =
    r" The provided value must be less than or equal to the maximum value for the newtype."]
    #[doc =
    r" Providing a value outside this range is undefined due to layout restrictions."]
    #[doc = r""]
    #[doc = r" Prefer using `from_u32`."]
    #[inline]
    const unsafe fn from_u32_unchecked(value: u32) -> Self {
        Self {
            private_use_as_methods_instead: unsafe {
                std::mem::transmute(value)
            },
        }
    }
    #[doc = r" Extracts the value of this index as a `usize`."]
    #[inline]
    const fn index(self) -> usize { self.as_usize() }
    #[doc = r" Extracts the value of this index as a `u32`."]
    #[inline]
    const fn as_u32(self) -> u32 {
        unsafe { std::mem::transmute(self.private_use_as_methods_instead) }
    }
    #[doc = r" Extracts the value of this index as a `usize`."]
    #[inline]
    const fn as_usize(self) -> usize { self.as_u32() as usize }
}
impl std::ops::Add<usize> for LeakCheckScc {
    type Output = Self;
    #[inline]
    fn add(self, other: usize) -> Self {
        Self::from_usize(self.index() + other)
    }
}
impl std::ops::AddAssign<usize> for LeakCheckScc {
    #[inline]
    fn add_assign(&mut self, other: usize) { *self = *self + other; }
}
impl rustc_index::Idx for LeakCheckScc {
    #[inline]
    fn new(value: usize) -> Self { Self::from_usize(value) }
    #[inline]
    fn index(self) -> usize { self.as_usize() }
}
impl ::std::iter::Step for LeakCheckScc {
    #[inline]
    fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
        <usize as
                ::std::iter::Step>::steps_between(&Self::index(*start),
            &Self::index(*end))
    }
    #[inline]
    fn forward_checked(start: Self, u: usize) -> Option<Self> {
        Self::index(start).checked_add(u).map(Self::from_usize)
    }
    #[inline]
    fn backward_checked(start: Self, u: usize) -> Option<Self> {
        Self::index(start).checked_sub(u).map(Self::from_usize)
    }
    #[inline]
    fn forward_overflowing(start: Self, u: usize) -> (Self, bool) {
        let (s, o) = Self::index(start).overflowing_add(u);
        (Self::from_usize(s), o)
    }
    #[inline]
    fn backward_overflowing(start: Self, u: usize) -> (Self, bool) {
        let (s, o) = Self::index(start).overflowing_sub(u);
        (Self::from_usize(s), o)
    }
}
impl ::std::cmp::Ord for LeakCheckScc {
    #[inline]
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.as_u32().cmp(&other.as_u32())
    }
}
impl ::std::cmp::PartialOrd for LeakCheckScc {
    #[inline]
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl From<LeakCheckScc> for u32 {
    #[inline]
    fn from(v: LeakCheckScc) -> u32 { v.as_u32() }
}
impl From<LeakCheckScc> for usize {
    #[inline]
    fn from(v: LeakCheckScc) -> usize { v.as_usize() }
}
impl From<usize> for LeakCheckScc {
    #[inline]
    fn from(value: usize) -> Self { Self::from_usize(value) }
}
impl From<u32> for LeakCheckScc {
    #[inline]
    fn from(value: u32) -> Self { Self::from_u32(value) }
}
impl ::std::cmp::Eq for LeakCheckScc {}
impl ::std::cmp::PartialEq for LeakCheckScc {
    fn eq(&self, other: &Self) -> bool { self.as_u32().eq(&other.as_u32()) }
}
impl ::std::marker::StructuralPartialEq for LeakCheckScc {}
impl ::std::hash::Hash for LeakCheckScc {
    fn hash<H: ::std::hash::Hasher>(&self, state: &mut H) {
        self.as_u32().hash(state)
    }
}
impl ::std::fmt::Debug for LeakCheckScc {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("LeakCheckScc({0})", self.as_u32()))
    }
}rustc_index::newtype_index! {
345    #[orderable]
346    #[debug_format = "LeakCheckScc({})"]
347    struct LeakCheckScc {}
348}
349
350/// Represents the graph of constraints. For each `R1: R2` constraint we create
351/// an edge `R1 -> R2` in the graph.
352struct MiniGraph<'tcx> {
353    /// Map from a region to the index of the node in the graph.
354    nodes: FxIndexMap<ty::Region<'tcx>, LeakCheckNode>,
355
356    /// Map from node index to SCC, and stores the successors of each SCC. All
357    /// the regions in the same SCC are equal to one another, and if `S1 -> S2`,
358    /// then `S1: S2`.
359    sccs: Sccs<LeakCheckNode, LeakCheckScc>,
360}
361
362impl<'tcx> MiniGraph<'tcx> {
363    fn new(
364        region_constraints: &RegionConstraintCollector<'_, 'tcx>,
365        only_consider_snapshot: Option<&CombinedSnapshot<'tcx>>,
366        assumptions_on_binders: bool,
367    ) -> Self {
368        let mut nodes = FxIndexMap::default();
369        let mut edges = Vec::new();
370
371        // Note that if `R2: R1`, we get a callback `r1, r2`, so `target` is first parameter.
372        let each_edge = |target, source| {
373            let source_node = Self::add_node(&mut nodes, source);
374            let target_node = Self::add_node(&mut nodes, target);
375            edges.push((source_node, target_node));
376        };
377
378        if assumptions_on_binders {
379            Self::iterate_solver_region_constraints(
380                region_constraints,
381                only_consider_snapshot,
382                each_edge,
383            );
384        } else {
385            Self::iterate_region_constraints(region_constraints, only_consider_snapshot, each_edge);
386        }
387        let graph = VecGraph::<_, false>::new(nodes.len(), edges);
388        let sccs = Sccs::new(&graph);
389        Self { nodes, sccs }
390    }
391
392    /// Invokes `each_edge(R1, R2)` for each edge where `R2: R1`
393    fn iterate_region_constraints(
394        region_constraints: &RegionConstraintCollector<'_, 'tcx>,
395        only_consider_snapshot: Option<&CombinedSnapshot<'tcx>>,
396        mut each_edge: impl FnMut(ty::Region<'tcx>, ty::Region<'tcx>),
397    ) {
398        if let Some(snapshot) = only_consider_snapshot {
399            for undo_entry in
400                region_constraints.undo_log.region_constraints_in_snapshot(&snapshot.undo_snapshot)
401            {
402                match undo_entry {
403                    &AddConstraint(i) => {
404                        // FIXME(-Zassumptions-on-binders): Handle solver_data here and elsewhere in this fn
405                        region_constraints.legacy_data().constraints[i].0.iter_outlives().for_each(
406                            |Constraint { kind: _, sub, sup, visible_for_leak_check }| {
407                                match visible_for_leak_check {
408                                    ty::VisibleForLeakCheck::Yes => each_edge(sub, sup),
409                                    ty::VisibleForLeakCheck::No => {}
410                                    ty::VisibleForLeakCheck::Unreachable => ::core::panicking::unreachable_default_msg()unreachable!(),
411                                }
412                            },
413                        );
414                    }
415                    &AddVerify(i) => ::rustc_span::macros::bug_impl(Some(region_constraints.legacy_data().verifys[i].origin.span()),
    format_args!("we never add verifications while doing higher-ranked things"),
    Location::caller())span_bug!(
416                        region_constraints.legacy_data().verifys[i].origin.span(),
417                        "we never add verifications while doing higher-ranked things",
418                    ),
419                    &AddCombination(..) | &AddVar(..) => {}
420                    &OverwriteSolverRegionConstraint { .. }
421                    | &AddSolverLeafRegionConstraint(..) => {
422                        ::core::panicking::unreachable_default_msg()unreachable!()
423                    }
424                }
425            }
426        } else {
427            region_constraints
428                .legacy_data()
429                .constraints
430                .iter()
431                .flat_map(|(c, _)| c.iter_outlives())
432                .for_each(|Constraint { kind: _, sub, sup, visible_for_leak_check }| {
433                    match visible_for_leak_check {
434                        ty::VisibleForLeakCheck::Yes => each_edge(sub, sup),
435                        ty::VisibleForLeakCheck::No => {}
436                        ty::VisibleForLeakCheck::Unreachable => ::core::panicking::unreachable_default_msg()unreachable!(),
437                    }
438                })
439        }
440    }
441
442    /// Same as the [`Self::iterate_region_constraints`] but use the new-style constraint.
443    fn iterate_solver_region_constraints(
444        region_constraints: &RegionConstraintCollector<'_, 'tcx>,
445        only_consider_snapshot: Option<&CombinedSnapshot<'tcx>>,
446        mut each_edge: impl FnMut(ty::Region<'tcx>, ty::Region<'tcx>),
447    ) {
448        let mut handle_leaf = |leaf: SolverLeafRegionConstraint<'tcx>| {
449            if let LeafRegionConstraint::RegionOutlives(sup, sub) = leaf.leaf {
450                match leaf.visible_for_leak_check {
451                    ty::VisibleForLeakCheck::Yes => each_edge(sub, sup),
452                    ty::VisibleForLeakCheck::No => {}
453                    ty::VisibleForLeakCheck::Unreachable => ::core::panicking::unreachable_default_msg()unreachable!(),
454                }
455            }
456        };
457        if let Some(snapshot) = only_consider_snapshot {
458            for undo_entry in
459                region_constraints.undo_log.region_constraints_in_snapshot(&snapshot.undo_snapshot)
460            {
461                match undo_entry {
462                    &AddConstraint(_) | &AddVerify(_) => {
463                        ::rustc_span::macros::bug_impl(None,
    format_args!("We use the old region constraint when assumptions_on_binders is on"),
    Location::caller())bug!("We use the old region constraint when assumptions_on_binders is on")
464                    }
465
466                    &AddCombination(..) | &AddVar(..) => {}
467                    &OverwriteSolverRegionConstraint { .. } => {}
468                    &AddSolverLeafRegionConstraint(index) => {
469                        handle_leaf(region_constraints.solver_data().get_leaf(index).unwrap());
470                    }
471                }
472            }
473        } else {
474            for leaf in region_constraints.solver_data().iter_leafs() {
475                handle_leaf(leaf);
476            }
477        }
478    }
479
480    fn add_node(
481        nodes: &mut FxIndexMap<ty::Region<'tcx>, LeakCheckNode>,
482        r: ty::Region<'tcx>,
483    ) -> LeakCheckNode {
484        let l = nodes.len();
485        *nodes.entry(r).or_insert(LeakCheckNode::new(l))
486    }
487}