Skip to main content

rustc_borrowck/region_infer/
mod.rs

1use std::collections::VecDeque;
2use std::fmt;
3use std::rc::Rc;
4
5use rustc_data_structures::frozen::Frozen;
6use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
7use rustc_data_structures::graph::scc::Sccs;
8use rustc_errors::Diag;
9use rustc_hir::def_id::CRATE_DEF_ID;
10use rustc_index::IndexVec;
11use rustc_infer::infer::outlives::test_type_match;
12use rustc_infer::infer::region_constraints::{GenericKind, VerifyBound, VerifyIfEq};
13use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
14use rustc_middle::bug;
15use rustc_middle::mir::{
16    AnnotationSource, BasicBlock, Body, ConstraintCategory, Local, Location, ReturnConstraint,
17    TerminatorKind,
18};
19use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
20use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex, fold_regions};
21use rustc_mir_dataflow::points::DenseLocationMap;
22use rustc_span::hygiene::DesugaringKind;
23use rustc_span::{DUMMY_SP, Span};
24use tracing::{Level, debug, enabled, instrument, trace};
25
26use crate::constraints::graph::NormalConstraintGraph;
27use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet};
28use crate::dataflow::BorrowIndex;
29use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo};
30use crate::handle_placeholders::{LoweredConstraints, RegionTracker};
31use crate::polonius::LiveLoans;
32use crate::polonius::legacy::PoloniusOutput;
33use crate::region_infer::values::{LivenessValues, RegionElement, RegionValues, ToElementIndex};
34use crate::type_check::Locations;
35use crate::type_check::free_region_relations::UniversalRegionRelations;
36use crate::universal_regions::UniversalRegions;
37use crate::{
38    BorrowckInferCtxt, ClosureOutlivesRequirement, ClosureOutlivesSubject,
39    ClosureOutlivesSubjectTy, ClosureRegionRequirements,
40};
41
42mod dump_mir;
43mod graphviz;
44pub(crate) mod opaque_types;
45mod reverse_sccs;
46
47pub(crate) mod values;
48
49/// The representative region variable for an SCC, tagged by its origin.
50/// We prefer placeholders over existentially quantified variables, otherwise
51/// it's the one with the smallest Region Variable ID. In other words,
52/// the order of this enumeration really matters!
53#[derive(#[automatically_derived]
impl ::core::marker::Copy for Representative { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for Representative {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Representative::FreeRegion(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "FreeRegion", &__self_0),
            Representative::Placeholder(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Placeholder", &__self_0),
            Representative::Existential(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Existential", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Representative {
    #[inline]
    fn clone(&self) -> Representative {
        let _: ::core::clone::AssertParamIsClone<RegionVid>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Representative {
    #[inline]
    fn eq(&self, other: &Representative) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (Representative::FreeRegion(__self_0),
                    Representative::FreeRegion(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Representative::Placeholder(__self_0),
                    Representative::Placeholder(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Representative::Existential(__self_0),
                    Representative::Existential(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Representative {
    #[inline]
    fn partial_cmp(&self, other: &Representative)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match (self, other) {
            (Representative::FreeRegion(__self_0),
                Representative::FreeRegion(__arg1_0)) =>
                ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
            (Representative::Placeholder(__self_0),
                Representative::Placeholder(__arg1_0)) =>
                ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
            (Representative::Existential(__self_0),
                Representative::Existential(__arg1_0)) =>
                ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
            _ =>
                ::core::cmp::PartialOrd::partial_cmp(&__self_discr,
                    &__arg1_discr),
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for Representative {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<RegionVid>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for Representative {
    #[inline]
    fn cmp(&self, other: &Representative) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
            ::core::cmp::Ordering::Equal =>
                match (self, other) {
                    (Representative::FreeRegion(__self_0),
                        Representative::FreeRegion(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (Representative::Placeholder(__self_0),
                        Representative::Placeholder(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (Representative::Existential(__self_0),
                        Representative::Existential(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    _ => unsafe { ::core::intrinsics::unreachable() }
                },
            cmp => cmp,
        }
    }
}Ord)]
54pub(crate) enum Representative {
55    FreeRegion(RegionVid),
56    Placeholder(RegionVid),
57    Existential(RegionVid),
58}
59
60impl Representative {
61    pub(crate) fn rvid(self) -> RegionVid {
62        match self {
63            Representative::FreeRegion(region_vid)
64            | Representative::Placeholder(region_vid)
65            | Representative::Existential(region_vid) => region_vid,
66        }
67    }
68
69    pub(crate) fn new(r: RegionVid, definition: &RegionDefinition<'_>) -> Self {
70        match definition.origin {
71            NllRegionVariableOrigin::FreeRegion => Representative::FreeRegion(r),
72            NllRegionVariableOrigin::Placeholder(_) => Representative::Placeholder(r),
73            NllRegionVariableOrigin::Existential { .. } => Representative::Existential(r),
74        }
75    }
76}
77
78pub(crate) type ConstraintSccs = Sccs<RegionVid, ConstraintSccIndex>;
79
80pub struct RegionInferenceContext<'tcx> {
81    /// Contains the definition for every region variable. Region
82    /// variables are identified by their index (`RegionVid`). The
83    /// definition contains information about where the region came
84    /// from as well as its final inferred value.
85    pub(crate) definitions: Frozen<IndexVec<RegionVid, RegionDefinition<'tcx>>>,
86
87    /// The liveness constraints added to each region. For most
88    /// regions, these start out empty and steadily grow, though for
89    /// each universally quantified region R they start out containing
90    /// the entire CFG and `end(R)`.
91    liveness_constraints: LivenessValues,
92
93    /// The outlives constraints computed by the type-check.
94    constraints: Frozen<OutlivesConstraintSet<'tcx>>,
95
96    /// The constraint-set, but in graph form, making it easy to traverse
97    /// the constraints adjacent to a particular region. Used to construct
98    /// the SCC (see `constraint_sccs`) and for error reporting.
99    constraint_graph: Frozen<NormalConstraintGraph>,
100
101    /// The SCC computed from `constraints` and the constraint
102    /// graph. We have an edge from SCC A to SCC B if `A: B`. Used to
103    /// compute the values of each region.
104    constraint_sccs: ConstraintSccs,
105
106    scc_annotations: IndexVec<ConstraintSccIndex, RegionTracker>,
107
108    /// Map universe indexes to information on why we created it.
109    universe_causes: FxIndexMap<ty::UniverseIndex, UniverseInfo<'tcx>>,
110
111    /// The final inferred values of the region variables; we compute
112    /// one value per SCC. To get the value for any given *region*,
113    /// you first find which scc it is a part of.
114    scc_values: RegionValues<'tcx, ConstraintSccIndex>,
115
116    /// Type constraints that we check after solving.
117    type_tests: Vec<TypeTest<'tcx>>,
118
119    /// Information about how the universally quantified regions in
120    /// scope on this function relate to one another.
121    universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
122}
123
124#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for RegionDefinition<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "RegionDefinition", "origin", &self.origin, "universe",
            &self.universe, "external_name", &&self.external_name)
    }
}Debug)]
125pub(crate) struct RegionDefinition<'tcx> {
126    /// What kind of variable is this -- a free region? existential
127    /// variable? etc. (See the `NllRegionVariableOrigin` for more
128    /// info.)
129    pub(crate) origin: NllRegionVariableOrigin<'tcx>,
130
131    /// Which universe is this region variable defined in? This is
132    /// most often `ty::UniverseIndex::ROOT`, but when we encounter
133    /// forall-quantifiers like `for<'a> { 'a = 'b }`, we would create
134    /// the variable for `'a` in a fresh universe that extends ROOT.
135    pub(crate) universe: ty::UniverseIndex,
136
137    /// If this is 'static or an early-bound region, then this is
138    /// `Some(X)` where `X` is the name of the region.
139    pub(crate) external_name: Option<ty::Region<'tcx>>,
140}
141
142/// N.B., the variants in `Cause` are intentionally ordered. Lower
143/// values are preferred when it comes to error messages. Do not
144/// reorder willy nilly.
145#[derive(#[automatically_derived]
impl ::core::marker::Copy for Cause { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Cause {
    #[inline]
    fn clone(&self) -> Cause {
        let _: ::core::clone::AssertParamIsClone<Local>;
        let _: ::core::clone::AssertParamIsClone<Location>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Cause {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Cause::LiveVar(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "LiveVar", __self_0, &__self_1),
            Cause::DropVar(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "DropVar", __self_0, &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialOrd for Cause {
    #[inline]
    fn partial_cmp(&self, other: &Cause)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match (self, other) {
            (Cause::LiveVar(__self_0, __self_1),
                Cause::LiveVar(__arg1_0, __arg1_1)) =>
                match ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0)
                    {
                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                        => ::core::cmp::PartialOrd::partial_cmp(__self_1, __arg1_1),
                    cmp => cmp,
                },
            (Cause::DropVar(__self_0, __self_1),
                Cause::DropVar(__arg1_0, __arg1_1)) =>
                match ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0)
                    {
                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                        => ::core::cmp::PartialOrd::partial_cmp(__self_1, __arg1_1),
                    cmp => cmp,
                },
            _ =>
                ::core::cmp::PartialOrd::partial_cmp(&__self_discr,
                    &__arg1_discr),
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Cause {
    #[inline]
    fn cmp(&self, other: &Cause) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
            ::core::cmp::Ordering::Equal =>
                match (self, other) {
                    (Cause::LiveVar(__self_0, __self_1),
                        Cause::LiveVar(__arg1_0, __arg1_1)) =>
                        match ::core::cmp::Ord::cmp(__self_0, __arg1_0) {
                            ::core::cmp::Ordering::Equal =>
                                ::core::cmp::Ord::cmp(__self_1, __arg1_1),
                            cmp => cmp,
                        },
                    (Cause::DropVar(__self_0, __self_1),
                        Cause::DropVar(__arg1_0, __arg1_1)) =>
                        match ::core::cmp::Ord::cmp(__self_0, __arg1_0) {
                            ::core::cmp::Ordering::Equal =>
                                ::core::cmp::Ord::cmp(__self_1, __arg1_1),
                            cmp => cmp,
                        },
                    _ => unsafe { ::core::intrinsics::unreachable() }
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::cmp::PartialEq for Cause {
    #[inline]
    fn eq(&self, other: &Cause) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (Cause::LiveVar(__self_0, __self_1),
                    Cause::LiveVar(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Cause::DropVar(__self_0, __self_1),
                    Cause::DropVar(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Cause {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Local>;
        let _: ::core::cmp::AssertParamIsEq<Location>;
    }
}Eq)]
146pub(crate) enum Cause {
147    /// point inserted because Local was live at the given Location
148    LiveVar(Local, Location),
149
150    /// point inserted because Local was dropped at the given Location
151    DropVar(Local, Location),
152}
153
154/// A "type test" corresponds to an outlives constraint between a type
155/// and a lifetime, like `T: 'x` or `<T as Foo>::Bar: 'x`. They are
156/// translated from the `Verify` region constraints in the ordinary
157/// inference context.
158///
159/// These sorts of constraints are handled differently than ordinary
160/// constraints, at least at present. During type checking, the
161/// `InferCtxt::process_registered_region_obligations` method will
162/// attempt to convert a type test like `T: 'x` into an ordinary
163/// outlives constraint when possible (for example, `&'a T: 'b` will
164/// be converted into `'a: 'b` and registered as a `Constraint`).
165///
166/// In some cases, however, there are outlives relationships that are
167/// not converted into a region constraint, but rather into one of
168/// these "type tests". The distinction is that a type test does not
169/// influence the inference result, but instead just examines the
170/// values that we ultimately inferred for each region variable and
171/// checks that they meet certain extra criteria. If not, an error
172/// can be issued.
173///
174/// One reason for this is that these type tests typically boil down
175/// to a check like `'a: 'x` where `'a` is a universally quantified
176/// region -- and therefore not one whose value is really meant to be
177/// *inferred*, precisely (this is not always the case: one can have a
178/// type test like `<Foo as Trait<'?0>>::Bar: 'x`, where `'?0` is an
179/// inference variable). Another reason is that these type tests can
180/// involve *disjunction* -- that is, they can be satisfied in more
181/// than one way.
182///
183/// For more information about this translation, see
184/// `InferCtxt::process_registered_region_obligations` and
185/// `InferCtxt::type_must_outlive` in `rustc_infer::infer::InferCtxt`.
186#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for TypeTest<'tcx> {
    #[inline]
    fn clone(&self) -> TypeTest<'tcx> {
        TypeTest {
            generic_kind: ::core::clone::Clone::clone(&self.generic_kind),
            lower_bound: ::core::clone::Clone::clone(&self.lower_bound),
            span: ::core::clone::Clone::clone(&self.span),
            verify_bound: ::core::clone::Clone::clone(&self.verify_bound),
        }
    }
}Clone)]
187pub(crate) struct TypeTest<'tcx> {
188    /// The type `T` that must outlive the region.
189    pub generic_kind: GenericKind<'tcx>,
190
191    /// The region `'x` that the type must outlive.
192    pub lower_bound: RegionVid,
193
194    /// The span to blame.
195    pub span: Span,
196
197    /// A test which, if met by the region `'x`, proves that this type
198    /// constraint is satisfied.
199    pub verify_bound: VerifyBound<'tcx>,
200}
201
202impl fmt::Debug for TypeTest<'_> {
203    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
204        fn fmt_bound(
205            f: &mut fmt::Formatter<'_>,
206            generic_kind: GenericKind<'_>,
207            lower: RegionVid,
208            bound: &VerifyBound<'_>,
209        ) -> fmt::Result {
210            let fmt_bounds =
211                |f: &mut fmt::Formatter<'_>, bounds: &[VerifyBound<'_>]| -> fmt::Result {
212                    let mut it = bounds.iter().peekable();
213                    while let Some(bound) = it.next() {
214                        fmt_bound(f, generic_kind, lower, bound)?;
215                        if it.peek().is_some() {
216                            f.write_fmt(format_args!(", "))write!(f, ", ")?
217                        }
218                    }
219                    Ok(())
220                };
221            match bound {
222                VerifyBound::IfEq(binder) => f.write_fmt(format_args!("{0:?} == {1:?}", generic_kind, binder))write!(f, "{:?} == {:?}", generic_kind, binder),
223                VerifyBound::OutlivedBy(region) => f.write_fmt(format_args!("{0:?}: {1:?}", region, lower))write!(f, "{region:?}: {lower:?}"),
224                VerifyBound::AnyBound(verify_bounds) => {
225                    f.write_fmt(format_args!("Any["))write!(f, "Any[")?;
226                    fmt_bounds(f, verify_bounds)?;
227                    f.write_fmt(format_args!("]"))write!(f, "]")
228                }
229                VerifyBound::AllBounds(verify_bounds) => {
230                    f.write_fmt(format_args!("All["))write!(f, "All[")?;
231                    fmt_bounds(f, verify_bounds)?;
232                    f.write_fmt(format_args!("]"))write!(f, "]")
233                }
234                VerifyBound::IsEmpty => f.write_fmt(format_args!("Empty({0:?})", lower))write!(f, "Empty({lower:?})"),
235            }
236        }
237        f.write_fmt(format_args!("TypeTest from {0:?}[", self.span))write!(f, "TypeTest from {:?}[", self.span)?;
238        fmt_bound(f, self.generic_kind, self.lower_bound, &self.verify_bound)?;
239        f.write_fmt(format_args!("] ⊢ {0:?}: {1:?}", self.generic_kind,
        self.lower_bound))write!(f, "] ⊢ {:?}: {:?}", self.generic_kind, self.lower_bound)
240    }
241}
242
243/// When we have an unmet lifetime constraint, we try to propagate it outward (e.g. to a closure
244/// environment). If we can't, it is an error.
245#[derive(#[automatically_derived]
impl ::core::clone::Clone for RegionRelationCheckResult {
    #[inline]
    fn clone(&self) -> RegionRelationCheckResult { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for RegionRelationCheckResult { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for RegionRelationCheckResult {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RegionRelationCheckResult::Ok => "Ok",
                RegionRelationCheckResult::Propagated => "Propagated",
                RegionRelationCheckResult::Error => "Error",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for RegionRelationCheckResult {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for RegionRelationCheckResult {
    #[inline]
    fn eq(&self, other: &RegionRelationCheckResult) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq)]
246enum RegionRelationCheckResult {
247    Ok,
248    Propagated,
249    Error,
250}
251
252#[derive(#[automatically_derived]
impl<'a, 'tcx> ::core::clone::Clone for Trace<'a, 'tcx> {
    #[inline]
    fn clone(&self) -> Trace<'a, 'tcx> {
        match self {
            Trace::StartRegion => Trace::StartRegion,
            Trace::FromGraph(__self_0) =>
                Trace::FromGraph(::core::clone::Clone::clone(__self_0)),
            Trace::FromStatic(__self_0) =>
                Trace::FromStatic(::core::clone::Clone::clone(__self_0)),
            Trace::NotVisited => Trace::NotVisited,
        }
    }
}Clone, #[automatically_derived]
impl<'a, 'tcx> ::core::cmp::PartialEq for Trace<'a, 'tcx> {
    #[inline]
    fn eq(&self, other: &Trace<'a, 'tcx>) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (Trace::FromGraph(__self_0), Trace::FromGraph(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Trace::FromStatic(__self_0), Trace::FromStatic(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl<'a, 'tcx> ::core::cmp::Eq for Trace<'a, 'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<&'a OutlivesConstraint<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<RegionVid>;
    }
}Eq, #[automatically_derived]
impl<'a, 'tcx> ::core::fmt::Debug for Trace<'a, 'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Trace::StartRegion =>
                ::core::fmt::Formatter::write_str(f, "StartRegion"),
            Trace::FromGraph(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "FromGraph", &__self_0),
            Trace::FromStatic(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "FromStatic", &__self_0),
            Trace::NotVisited =>
                ::core::fmt::Formatter::write_str(f, "NotVisited"),
        }
    }
}Debug)]
253enum Trace<'a, 'tcx> {
254    StartRegion,
255    FromGraph(&'a OutlivesConstraint<'tcx>),
256    FromStatic(RegionVid),
257    NotVisited,
258}
259
260#[allow(clippy :: suspicious_else_formatting)]
{
    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("sccs_info",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(260u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            use crate::renumber::RegionCtxt;
            let var_to_origin = infcx.reg_var_to_origin.borrow();
            let mut var_to_origin_sorted =
                var_to_origin.clone().into_iter().collect::<Vec<_>>();
            var_to_origin_sorted.sort_by_key(|vto| vto.0);
            if {
                    if Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("enabled compiler/rustc_borrowck/src/region_infer/mod.rs:269",
                                            "rustc_borrowck::region_infer", Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(269u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                            ::tracing_core::field::FieldSet::new(&[],
                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                            ::tracing::metadata::Kind::HINT.hint())
                                    };
                                ::tracing::callsite::DefaultCallsite::new(&META)
                            };
                        let interest = __CALLSITE.interest();
                        if !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest) {
                            let meta = __CALLSITE.metadata();
                            ::tracing::dispatcher::get_default(|current|
                                    current.enabled(meta))
                        } else { false }
                    } else { false }
                } {
                let mut reg_vars_to_origins_str =
                    "region variables to origins:\n".to_string();
                for (reg_var, origin) in var_to_origin_sorted.into_iter() {
                    reg_vars_to_origins_str.push_str(&::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0:?}: {1:?}\n", reg_var,
                                            origin))
                                }));
                }
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:274",
                                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(274u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                        ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&format_args!("{0}",
                                                                    reg_vars_to_origins_str) as &dyn Value))])
                            });
                    } else { ; }
                };
            }
            let num_components = sccs.num_sccs();
            let mut components =
                ::alloc::vec::from_elem(FxIndexSet::default(),
                    num_components);
            for (reg_var, scc_idx) in sccs.scc_indices().iter_enumerated() {
                let origin =
                    var_to_origin.get(&reg_var).unwrap_or(&RegionCtxt::Unknown);
                components[scc_idx.as_usize()].insert((reg_var, *origin));
            }
            if {
                    if Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("enabled compiler/rustc_borrowck/src/region_infer/mod.rs:285",
                                            "rustc_borrowck::region_infer", Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(285u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                            ::tracing_core::field::FieldSet::new(&[],
                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                            ::tracing::metadata::Kind::HINT.hint())
                                    };
                                ::tracing::callsite::DefaultCallsite::new(&META)
                            };
                        let interest = __CALLSITE.interest();
                        if !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest) {
                            let meta = __CALLSITE.metadata();
                            ::tracing::dispatcher::get_default(|current|
                                    current.enabled(meta))
                        } else { false }
                    } else { false }
                } {
                let mut components_str =
                    "strongly connected components:".to_string();
                for (scc_idx, reg_vars_origins) in
                    components.iter().enumerate() {
                    let regions_info =
                        reg_vars_origins.clone().into_iter().collect::<Vec<_>>();
                    components_str.push_str(&::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0:?}: {1:?},\n)",
                                            ConstraintSccIndex::from_usize(scc_idx), regions_info))
                                }))
                }
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:295",
                                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(295u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                        ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&format_args!("{0}",
                                                                    components_str) as &dyn Value))])
                            });
                    } else { ; }
                };
            }
            let components_representatives =
                components.into_iter().enumerate().map(|(scc_idx,
                                region_ctxts)|
                            {
                                let repr =
                                    region_ctxts.into_iter().map(|reg_var_origin|
                                                    reg_var_origin.1).max_by(|x, y|
                                                x.preference_value().cmp(&y.preference_value())).unwrap();
                                (ConstraintSccIndex::from_usize(scc_idx), repr)
                            }).collect::<FxIndexMap<_, _>>();
            let mut scc_node_to_edges = FxIndexMap::default();
            for (scc_idx, repr) in components_representatives.iter() {
                let edge_representatives =
                    sccs.successors(*scc_idx).iter().map(|scc_idx|
                                components_representatives[scc_idx]).collect::<Vec<_>>();
                scc_node_to_edges.insert((scc_idx, repr),
                    edge_representatives);
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:323",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(323u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&format_args!("SCC edges {0:#?}",
                                                                scc_node_to_edges) as &dyn Value))])
                        });
                } else { ; }
            };
        }
    }
}#[instrument(skip(infcx, sccs), level = "debug")]
261fn sccs_info<'tcx>(infcx: &BorrowckInferCtxt<'tcx>, sccs: &ConstraintSccs) {
262    use crate::renumber::RegionCtxt;
263
264    let var_to_origin = infcx.reg_var_to_origin.borrow();
265
266    let mut var_to_origin_sorted = var_to_origin.clone().into_iter().collect::<Vec<_>>();
267    var_to_origin_sorted.sort_by_key(|vto| vto.0);
268
269    if enabled!(Level::DEBUG) {
270        let mut reg_vars_to_origins_str = "region variables to origins:\n".to_string();
271        for (reg_var, origin) in var_to_origin_sorted.into_iter() {
272            reg_vars_to_origins_str.push_str(&format!("{reg_var:?}: {origin:?}\n"));
273        }
274        debug!("{}", reg_vars_to_origins_str);
275    }
276
277    let num_components = sccs.num_sccs();
278    let mut components = vec![FxIndexSet::default(); num_components];
279
280    for (reg_var, scc_idx) in sccs.scc_indices().iter_enumerated() {
281        let origin = var_to_origin.get(&reg_var).unwrap_or(&RegionCtxt::Unknown);
282        components[scc_idx.as_usize()].insert((reg_var, *origin));
283    }
284
285    if enabled!(Level::DEBUG) {
286        let mut components_str = "strongly connected components:".to_string();
287        for (scc_idx, reg_vars_origins) in components.iter().enumerate() {
288            let regions_info = reg_vars_origins.clone().into_iter().collect::<Vec<_>>();
289            components_str.push_str(&format!(
290                "{:?}: {:?},\n)",
291                ConstraintSccIndex::from_usize(scc_idx),
292                regions_info,
293            ))
294        }
295        debug!("{}", components_str);
296    }
297
298    // calculate the best representative for each component
299    let components_representatives = components
300        .into_iter()
301        .enumerate()
302        .map(|(scc_idx, region_ctxts)| {
303            let repr = region_ctxts
304                .into_iter()
305                .map(|reg_var_origin| reg_var_origin.1)
306                .max_by(|x, y| x.preference_value().cmp(&y.preference_value()))
307                .unwrap();
308
309            (ConstraintSccIndex::from_usize(scc_idx), repr)
310        })
311        .collect::<FxIndexMap<_, _>>();
312
313    let mut scc_node_to_edges = FxIndexMap::default();
314    for (scc_idx, repr) in components_representatives.iter() {
315        let edge_representatives = sccs
316            .successors(*scc_idx)
317            .iter()
318            .map(|scc_idx| components_representatives[scc_idx])
319            .collect::<Vec<_>>();
320        scc_node_to_edges.insert((scc_idx, repr), edge_representatives);
321    }
322
323    debug!("SCC edges {:#?}", scc_node_to_edges);
324}
325
326impl<'tcx> RegionInferenceContext<'tcx> {
327    /// Creates a new region inference context with a total of
328    /// `num_region_variables` valid inference variables; the first N
329    /// of those will be constant regions representing the free
330    /// regions defined in `universal_regions`.
331    ///
332    /// The `outlives_constraints` and `type_tests` are an initial set
333    /// of constraints produced by the MIR type check.
334    pub(crate) fn new(
335        infcx: &BorrowckInferCtxt<'tcx>,
336        lowered_constraints: LoweredConstraints<'tcx>,
337        universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
338        location_map: Rc<DenseLocationMap>,
339    ) -> Self {
340        let universal_regions = &universal_region_relations.universal_regions;
341
342        let LoweredConstraints {
343            constraint_sccs,
344            definitions,
345            outlives_constraints,
346            scc_annotations,
347            type_tests,
348            liveness_constraints,
349            universe_causes,
350            placeholder_indices,
351        } = lowered_constraints;
352
353        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:353",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(353u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("universal_regions: {0:#?}",
                                                    universal_region_relations.universal_regions) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!("universal_regions: {:#?}", universal_region_relations.universal_regions);
354        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:354",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(354u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("outlives constraints: {0:#?}",
                                                    outlives_constraints) as &dyn Value))])
            });
    } else { ; }
};debug!("outlives constraints: {:#?}", outlives_constraints);
355        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:355",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(355u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("placeholder_indices: {0:#?}",
                                                    placeholder_indices) as &dyn Value))])
            });
    } else { ; }
};debug!("placeholder_indices: {:#?}", placeholder_indices);
356        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:356",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(356u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("type tests: {0:#?}",
                                                    type_tests) as &dyn Value))])
            });
    } else { ; }
};debug!("type tests: {:#?}", type_tests);
357
358        let constraint_graph = Frozen::freeze(outlives_constraints.graph(definitions.len()));
359
360        if truecfg!(debug_assertions) {
361            sccs_info(infcx, &constraint_sccs);
362        }
363
364        let mut scc_values =
365            RegionValues::new(location_map, universal_regions.len(), placeholder_indices);
366
367        for region in liveness_constraints.regions() {
368            let scc = constraint_sccs.scc(region);
369            scc_values.merge_liveness(scc, region, &liveness_constraints);
370        }
371
372        let mut result = Self {
373            definitions,
374            liveness_constraints,
375            constraints: outlives_constraints,
376            constraint_graph,
377            constraint_sccs,
378            scc_annotations,
379            universe_causes,
380            scc_values,
381            type_tests,
382            universal_region_relations,
383        };
384
385        result.init_free_and_bound_regions();
386
387        result
388    }
389
390    /// Initializes the region variables for each universally
391    /// quantified region (lifetime parameter). The first N variables
392    /// always correspond to the regions appearing in the function
393    /// signature (both named and anonymous) and where-clauses. This
394    /// function iterates over those regions and initializes them with
395    /// minimum values.
396    ///
397    /// For example:
398    /// ```ignore (illustrative)
399    /// fn foo<'a, 'b>( /* ... */ ) where 'a: 'b { /* ... */ }
400    /// ```
401    /// would initialize two variables like so:
402    /// ```ignore (illustrative)
403    /// R0 = { CFG, R0 } // 'a
404    /// R1 = { CFG, R0, R1 } // 'b
405    /// ```
406    /// Here, R0 represents `'a`, and it contains (a) the entire CFG
407    /// and (b) any universally quantified regions that it outlives,
408    /// which in this case is just itself. R1 (`'b`) in contrast also
409    /// outlives `'a` and hence contains R0 and R1.
410    ///
411    /// This bit of logic also handles invalid universe relations
412    /// for higher-kinded types.
413    ///
414    /// We Walk each SCC `A` and `B` such that `A: B`
415    /// and ensure that universe(A) can see universe(B).
416    ///
417    /// This serves to enforce the 'empty/placeholder' hierarchy
418    /// (described in more detail on `RegionKind`):
419    ///
420    /// ```ignore (illustrative)
421    /// static -----+
422    ///   |         |
423    /// empty(U0) placeholder(U1)
424    ///   |      /
425    /// empty(U1)
426    /// ```
427    ///
428    /// In particular, imagine we have variables R0 in U0 and R1
429    /// created in U1, and constraints like this;
430    ///
431    /// ```ignore (illustrative)
432    /// R1: !1 // R1 outlives the placeholder in U1
433    /// R1: R0 // R1 outlives R0
434    /// ```
435    ///
436    /// Here, we wish for R1 to be `'static`, because it
437    /// cannot outlive `placeholder(U1)` and `empty(U0)` any other way.
438    ///
439    /// Thanks to this loop, what happens is that the `R1: R0`
440    /// constraint has lowered the universe of `R1` to `U0`, which in turn
441    /// means that the `R1: !1` constraint here will cause
442    /// `R1` to become `'static`.
443    fn init_free_and_bound_regions(&mut self) {
444        for variable in self.definitions.indices() {
445            let scc = self.constraint_sccs.scc(variable);
446
447            match self.definitions[variable].origin {
448                NllRegionVariableOrigin::FreeRegion => {
449                    // For each free, universally quantified region X:
450
451                    // Add all nodes in the CFG to liveness constraints
452                    self.liveness_constraints.add_all_points(variable);
453                    self.scc_values.add_all_points(scc);
454
455                    // Add `end(X)` into the set for X.
456                    self.scc_values.add_element(scc, variable);
457                }
458
459                NllRegionVariableOrigin::Placeholder(placeholder) => {
460                    self.scc_values.add_element(scc, placeholder);
461                }
462
463                NllRegionVariableOrigin::Existential { .. } => {
464                    // For existential, regions, nothing to do.
465                }
466            }
467        }
468    }
469
470    /// Returns an iterator over all the region indices.
471    pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx {
472        self.definitions.indices()
473    }
474
475    /// Given a universal region in scope on the MIR, returns the
476    /// corresponding index.
477    ///
478    /// Panics if `r` is not a registered universal region, most notably
479    /// if it is a placeholder. Handling placeholders requires access to the
480    /// `MirTypeckRegionConstraints`.
481    pub(crate) fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
482        self.universal_regions().to_region_vid(r)
483    }
484
485    /// Returns an iterator over all the outlives constraints.
486    pub(crate) fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> {
487        self.constraints.outlives().iter().copied()
488    }
489
490    /// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`.
491    pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) {
492        self.universal_regions().annotate(tcx, err)
493    }
494
495    /// Returns `true` if the region `r` contains the point `p`.
496    ///
497    /// Panics if called before `solve()` executes,
498    pub(crate) fn region_contains(&self, r: RegionVid, p: impl ToElementIndex<'tcx>) -> bool {
499        let scc = self.constraint_sccs.scc(r);
500        self.scc_values.contains(scc, p)
501    }
502
503    /// Returns the lowest statement index in `start..=end` which is not contained by `r`.
504    ///
505    /// Panics if called before `solve()` executes.
506    pub(crate) fn first_non_contained_inclusive(
507        &self,
508        r: RegionVid,
509        block: BasicBlock,
510        start: usize,
511        end: usize,
512    ) -> Option<usize> {
513        let scc = self.constraint_sccs.scc(r);
514        self.scc_values.first_non_contained_inclusive(scc, block, start, end)
515    }
516
517    /// Returns access to the value of `r` for debugging purposes.
518    pub(crate) fn region_value_str(&self, r: RegionVid) -> String {
519        let scc = self.constraint_sccs.scc(r);
520        self.scc_values.region_value_str(scc)
521    }
522
523    pub(crate) fn placeholders_contained_in(
524        &self,
525        r: RegionVid,
526    ) -> impl Iterator<Item = ty::PlaceholderRegion<'tcx>> {
527        let scc = self.constraint_sccs.scc(r);
528        self.scc_values.placeholders_contained_in(scc)
529    }
530
531    /// Performs region inference and report errors if we see any
532    /// unsatisfiable constraints. If this is a closure, returns the
533    /// region requirements to propagate to our creator, if any.
534    #[allow(clippy :: suspicious_else_formatting)]
{
    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("solve",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(534u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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:
                    (Option<ClosureRegionRequirements<'tcx>>,
                    RegionErrors<'tcx>) = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let mir_def_id = body.source.def_id();
            self.propagate_constraints();
            let mut errors_buffer = RegionErrors::new(infcx.tcx);
            let mut propagated_outlives_requirements =
                infcx.tcx.is_typeck_child(mir_def_id).then(Vec::new);
            self.check_type_tests(infcx,
                propagated_outlives_requirements.as_mut(),
                &mut errors_buffer);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:554",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(554u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["errors_buffer"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&errors_buffer)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:555",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(555u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["propagated_outlives_requirements"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&propagated_outlives_requirements)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            if infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled()
                {
                self.check_polonius_subset_errors(propagated_outlives_requirements.as_mut(),
                    &mut errors_buffer,
                    polonius_output.as_ref().expect("Polonius output is unavailable despite `-Z polonius`"));
            } else {
                self.check_universal_regions(propagated_outlives_requirements.as_mut(),
                    &mut errors_buffer);
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:575",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(575u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["errors_buffer"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&errors_buffer)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            let propagated_outlives_requirements =
                propagated_outlives_requirements.unwrap_or_default();
            if propagated_outlives_requirements.is_empty() {
                (None, errors_buffer)
            } else {
                let num_external_vids =
                    self.universal_regions().num_global_and_external_regions();
                (Some(ClosureRegionRequirements {
                            num_external_vids,
                            outlives_requirements: propagated_outlives_requirements,
                        }), errors_buffer)
            }
        }
    }
}#[instrument(skip(self, infcx, body, polonius_output), level = "debug")]
535    pub(super) fn solve(
536        &mut self,
537        infcx: &InferCtxt<'tcx>,
538        body: &Body<'tcx>,
539        polonius_output: Option<Box<PoloniusOutput>>,
540    ) -> (Option<ClosureRegionRequirements<'tcx>>, RegionErrors<'tcx>) {
541        let mir_def_id = body.source.def_id();
542        self.propagate_constraints();
543
544        let mut errors_buffer = RegionErrors::new(infcx.tcx);
545
546        // If this is a nested body, we propagate unsatisfied
547        // outlives constraints to the parent body instead of
548        // eagerly erroing.
549        let mut propagated_outlives_requirements =
550            infcx.tcx.is_typeck_child(mir_def_id).then(Vec::new);
551
552        self.check_type_tests(infcx, propagated_outlives_requirements.as_mut(), &mut errors_buffer);
553
554        debug!(?errors_buffer);
555        debug!(?propagated_outlives_requirements);
556
557        // In Polonius mode, the errors about missing universal region relations are in the output
558        // and need to be emitted or propagated. Otherwise, we need to check whether the
559        // constraints were too strong, and if so, emit or propagate those errors.
560        if infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled() {
561            self.check_polonius_subset_errors(
562                propagated_outlives_requirements.as_mut(),
563                &mut errors_buffer,
564                polonius_output
565                    .as_ref()
566                    .expect("Polonius output is unavailable despite `-Z polonius`"),
567            );
568        } else {
569            self.check_universal_regions(
570                propagated_outlives_requirements.as_mut(),
571                &mut errors_buffer,
572            );
573        }
574
575        debug!(?errors_buffer);
576
577        let propagated_outlives_requirements = propagated_outlives_requirements.unwrap_or_default();
578
579        if propagated_outlives_requirements.is_empty() {
580            (None, errors_buffer)
581        } else {
582            let num_external_vids = self.universal_regions().num_global_and_external_regions();
583            (
584                Some(ClosureRegionRequirements {
585                    num_external_vids,
586                    outlives_requirements: propagated_outlives_requirements,
587                }),
588                errors_buffer,
589            )
590        }
591    }
592
593    /// Propagate the region constraints: this will grow the values
594    /// for each region variable until all the constraints are
595    /// satisfied. Note that some values may grow **too** large to be
596    /// feasible, but we check this later.
597    #[allow(clippy :: suspicious_else_formatting)]
{
    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("propagate_constraints",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(597u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:599",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(599u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&format_args!("constraints={0:#?}",
                                                                {
                                                                    let mut constraints: Vec<_> =
                                                                        self.outlives_constraints().collect();
                                                                    constraints.sort_by_key(|c| (c.sup, c.sub));
                                                                    constraints.into_iter().map(|c|
                                                                                (c, self.constraint_sccs.scc(c.sup),
                                                                                    self.constraint_sccs.scc(c.sub))).collect::<Vec<_>>()
                                                                }) as &dyn Value))])
                        });
                } else { ; }
            };
            for scc_a in self.constraint_sccs.all_sccs() {
                for &scc_b in self.constraint_sccs.successors(scc_a) {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:615",
                                            "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(615u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                            ::tracing_core::field::FieldSet::new(&["scc_b"],
                                                ::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};
                                    let mut iter = __CALLSITE.metadata().fields().iter();
                                    __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&debug(&scc_b) as
                                                                &dyn Value))])
                                });
                        } else { ; }
                    };
                    self.scc_values.add_region(scc_a, scc_b);
                }
            }
        }
    }
}#[instrument(skip(self), level = "debug")]
598    fn propagate_constraints(&mut self) {
599        debug!("constraints={:#?}", {
600            let mut constraints: Vec<_> = self.outlives_constraints().collect();
601            constraints.sort_by_key(|c| (c.sup, c.sub));
602            constraints
603                .into_iter()
604                .map(|c| (c, self.constraint_sccs.scc(c.sup), self.constraint_sccs.scc(c.sub)))
605                .collect::<Vec<_>>()
606        });
607
608        // To propagate constraints, we walk the DAG induced by the
609        // SCC. For each SCC `A`, we visit its successors and compute
610        // their values, then we union all those values to get our
611        // own.
612        for scc_a in self.constraint_sccs.all_sccs() {
613            // Walk each SCC `B` such that `A: B`...
614            for &scc_b in self.constraint_sccs.successors(scc_a) {
615                debug!(?scc_b);
616                self.scc_values.add_region(scc_a, scc_b);
617            }
618        }
619    }
620
621    /// Returns `true` if all the placeholders in the value of `scc_b` are nameable
622    /// in `scc_a`. Used during constraint propagation, and only once
623    /// the value of `scc_b` has been computed.
624    fn can_name_all_placeholders(
625        &self,
626        scc_a: ConstraintSccIndex,
627        scc_b: ConstraintSccIndex,
628    ) -> bool {
629        self.scc_annotations[scc_a].can_name_all_placeholders(self.scc_annotations[scc_b])
630    }
631
632    /// Once regions have been propagated, this method is used to see
633    /// whether the "type tests" produced by typeck were satisfied;
634    /// type tests encode type-outlives relationships like `T:
635    /// 'a`. See `TypeTest` for more details.
636    fn check_type_tests(
637        &self,
638        infcx: &InferCtxt<'tcx>,
639        mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
640        errors_buffer: &mut RegionErrors<'tcx>,
641    ) {
642        let tcx = infcx.tcx;
643
644        // Sometimes we register equivalent type-tests that would
645        // result in basically the exact same error being reported to
646        // the user. Avoid that.
647        let mut deduplicate_errors = FxIndexSet::default();
648
649        for type_test in &self.type_tests {
650            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:650",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(650u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_type_test: {0:?}",
                                                    type_test) as &dyn Value))])
            });
    } else { ; }
};debug!("check_type_test: {:?}", type_test);
651
652            let generic_ty = type_test.generic_kind.to_ty(tcx);
653            if self.eval_verify_bound(
654                infcx,
655                generic_ty,
656                type_test.lower_bound,
657                &type_test.verify_bound,
658            ) {
659                continue;
660            }
661
662            if let Some(propagated_outlives_requirements) = &mut propagated_outlives_requirements
663                && self.try_promote_type_test(infcx, type_test, propagated_outlives_requirements)
664            {
665                continue;
666            }
667
668            // Type-test failed. Report the error.
669            let erased_generic_kind = infcx.tcx.erase_and_anonymize_regions(type_test.generic_kind);
670
671            // Skip duplicate-ish errors.
672            if deduplicate_errors.insert((
673                erased_generic_kind,
674                type_test.lower_bound,
675                type_test.span,
676            )) {
677                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:677",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(677u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_type_test: reporting error for erased_generic_kind={0:?}, lower_bound_region={1:?}, type_test.span={2:?}",
                                                    erased_generic_kind, type_test.lower_bound, type_test.span)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(
678                    "check_type_test: reporting error for erased_generic_kind={:?}, \
679                     lower_bound_region={:?}, \
680                     type_test.span={:?}",
681                    erased_generic_kind, type_test.lower_bound, type_test.span,
682                );
683
684                errors_buffer.push(RegionErrorKind::TypeTestError { type_test: type_test.clone() });
685            }
686        }
687    }
688
689    /// Invoked when we have some type-test (e.g., `T: 'X`) that we cannot
690    /// prove to be satisfied. If this is a closure, we will attempt to
691    /// "promote" this type-test into our `ClosureRegionRequirements` and
692    /// hence pass it up the creator. To do this, we have to phrase the
693    /// type-test in terms of external free regions, as local free
694    /// regions are not nameable by the closure's creator.
695    ///
696    /// Promotion works as follows: we first check that the type `T`
697    /// contains only regions that the creator knows about. If this is
698    /// true, then -- as a consequence -- we know that all regions in
699    /// the type `T` are free regions that outlive the closure body. If
700    /// false, then promotion fails.
701    ///
702    /// Once we've promoted T, we have to "promote" `'X` to some region
703    /// that is "external" to the closure. Generally speaking, a region
704    /// may be the union of some points in the closure body as well as
705    /// various free lifetimes. We can ignore the points in the closure
706    /// body: if the type T can be expressed in terms of external regions,
707    /// we know it outlives the points in the closure body. That
708    /// just leaves the free regions.
709    ///
710    /// The idea then is to lower the `T: 'X` constraint into multiple
711    /// bounds -- e.g., if `'X` is the union of two free lifetimes,
712    /// `'1` and `'2`, then we would create `T: '1` and `T: '2`.
713    #[allow(clippy :: suspicious_else_formatting)]
{
    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("try_promote_type_test",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(713u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["type_test"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&type_test)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: bool = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = infcx.tcx;
            let TypeTest {
                    generic_kind, lower_bound, span: blame_span, verify_bound: _
                    } = *type_test;
            let generic_ty = generic_kind.to_ty(tcx);
            let Some(subject) =
                self.try_promote_type_test_subject(infcx,
                    generic_ty) else { return false; };
            let r_scc = self.constraint_sccs.scc(lower_bound);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:729",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(729u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&format_args!("lower_bound = {0:?} r_scc={1:?} universe={2:?}",
                                                                lower_bound, r_scc, self.max_nameable_universe(r_scc)) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            if let Some(p) =
                    self.scc_values.placeholders_contained_in(r_scc).next() {
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:742",
                                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(742u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                        ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&format_args!("encountered placeholder in higher universe: {0:?}, requiring \'static",
                                                                    p) as &dyn Value))])
                            });
                    } else { ; }
                };
                let static_r = self.universal_regions().fr_static;
                propagated_outlives_requirements.push(ClosureOutlivesRequirement {
                        subject,
                        outlived_free_region: static_r,
                        blame_span,
                        category: ConstraintCategory::Boring,
                    });
                return true;
            }
            let mut found_outlived_universal_region = false;
            for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
                found_outlived_universal_region = true;
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:762",
                                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(762u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                        ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&format_args!("universal_region_outlived_by ur={0:?}",
                                                                    ur) as &dyn Value))])
                            });
                    } else { ; }
                };
                let non_local_ub =
                    self.universal_region_relations.non_local_upper_bounds(ur);
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:764",
                                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(764u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                        ::tracing_core::field::FieldSet::new(&["non_local_ub"],
                                            ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&debug(&non_local_ub)
                                                            as &dyn Value))])
                            });
                    } else { ; }
                };
                for upper_bound in non_local_ub {
                    if true {
                        if !self.universal_regions().is_universal_region(upper_bound)
                            {
                            ::core::panicking::panic("assertion failed: self.universal_regions().is_universal_region(upper_bound)")
                        };
                    };
                    if true {
                        if !!self.universal_regions().is_local_free_region(upper_bound)
                            {
                            ::core::panicking::panic("assertion failed: !self.universal_regions().is_local_free_region(upper_bound)")
                        };
                    };
                    let requirement =
                        ClosureOutlivesRequirement {
                            subject,
                            outlived_free_region: upper_bound,
                            blame_span,
                            category: ConstraintCategory::Boring,
                        };
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:780",
                                            "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(780u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                            ::tracing_core::field::FieldSet::new(&["message",
                                                            "requirement"],
                                                ::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};
                                    let mut iter = __CALLSITE.metadata().fields().iter();
                                    __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&format_args!("adding closure requirement")
                                                                as &dyn Value)),
                                                    (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&debug(&requirement)
                                                                as &dyn Value))])
                                });
                        } else { ; }
                    };
                    propagated_outlives_requirements.push(requirement);
                }
            }
            if !found_outlived_universal_region {
                ::core::panicking::panic("assertion failed: found_outlived_universal_region")
            };
            true
        }
    }
}#[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))]
714    fn try_promote_type_test(
715        &self,
716        infcx: &InferCtxt<'tcx>,
717        type_test: &TypeTest<'tcx>,
718        propagated_outlives_requirements: &mut Vec<ClosureOutlivesRequirement<'tcx>>,
719    ) -> bool {
720        let tcx = infcx.tcx;
721        let TypeTest { generic_kind, lower_bound, span: blame_span, verify_bound: _ } = *type_test;
722
723        let generic_ty = generic_kind.to_ty(tcx);
724        let Some(subject) = self.try_promote_type_test_subject(infcx, generic_ty) else {
725            return false;
726        };
727
728        let r_scc = self.constraint_sccs.scc(lower_bound);
729        debug!(
730            "lower_bound = {:?} r_scc={:?} universe={:?}",
731            lower_bound,
732            r_scc,
733            self.max_nameable_universe(r_scc)
734        );
735        // If the type test requires that `T: 'a` where `'a` is a
736        // placeholder from another universe, that effectively requires
737        // `T: 'static`, so we have to propagate that requirement.
738        //
739        // It doesn't matter *what* universe because the promoted `T` will
740        // always be in the root universe.
741        if let Some(p) = self.scc_values.placeholders_contained_in(r_scc).next() {
742            debug!("encountered placeholder in higher universe: {:?}, requiring 'static", p);
743            let static_r = self.universal_regions().fr_static;
744            propagated_outlives_requirements.push(ClosureOutlivesRequirement {
745                subject,
746                outlived_free_region: static_r,
747                blame_span,
748                category: ConstraintCategory::Boring,
749            });
750
751            // we can return here -- the code below might push add'l constraints
752            // but they would all be weaker than this one.
753            return true;
754        }
755
756        // For each region outlived by lower_bound find a non-local,
757        // universal region (it may be the same region) and add it to
758        // `ClosureOutlivesRequirement`.
759        let mut found_outlived_universal_region = false;
760        for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
761            found_outlived_universal_region = true;
762            debug!("universal_region_outlived_by ur={:?}", ur);
763            let non_local_ub = self.universal_region_relations.non_local_upper_bounds(ur);
764            debug!(?non_local_ub);
765
766            // This is slightly too conservative. To show T: '1, given `'2: '1`
767            // and `'3: '1` we only need to prove that T: '2 *or* T: '3, but to
768            // avoid potential non-determinism we approximate this by requiring
769            // T: '1 and T: '2.
770            for upper_bound in non_local_ub {
771                debug_assert!(self.universal_regions().is_universal_region(upper_bound));
772                debug_assert!(!self.universal_regions().is_local_free_region(upper_bound));
773
774                let requirement = ClosureOutlivesRequirement {
775                    subject,
776                    outlived_free_region: upper_bound,
777                    blame_span,
778                    category: ConstraintCategory::Boring,
779                };
780                debug!(?requirement, "adding closure requirement");
781                propagated_outlives_requirements.push(requirement);
782            }
783        }
784        // If we succeed to promote the subject, i.e. it only contains non-local regions,
785        // and fail to prove the type test inside of the closure, the `lower_bound` has to
786        // also be at least as large as some universal region, as the type test is otherwise
787        // trivial.
788        assert!(found_outlived_universal_region);
789        true
790    }
791
792    /// When we promote a type test `T: 'r`, we have to replace all region
793    /// variables in the type `T` with an equal universal region from the
794    /// closure signature.
795    /// This is not always possible, so this is a fallible process.
796    x;#[instrument(level = "debug", skip(self, infcx), ret)]
797    fn try_promote_type_test_subject(
798        &self,
799        infcx: &InferCtxt<'tcx>,
800        ty: Ty<'tcx>,
801    ) -> Option<ClosureOutlivesSubject<'tcx>> {
802        let tcx = infcx.tcx;
803        let mut failed = false;
804        let ty = fold_regions(tcx, ty, |r, _depth| {
805            let r_vid = self.to_region_vid(r);
806            let r_scc = self.constraint_sccs.scc(r_vid);
807
808            // The challenge is this. We have some region variable `r`
809            // whose value is a set of CFG points and universal
810            // regions. We want to find if that set is *equivalent* to
811            // any of the named regions found in the closure.
812            // To do so, we simply check every candidate `u_r` for equality.
813            self.scc_values
814                .universal_regions_outlived_by(r_scc)
815                .filter(|&u_r| !self.universal_regions().is_local_free_region(u_r))
816                .find(|&u_r| self.eval_equal(u_r, r_vid))
817                .map(|u_r| ty::Region::new_var(tcx, u_r))
818                // In case we could not find a named region to map to,
819                // we will return `None` below.
820                .unwrap_or_else(|| {
821                    failed = true;
822                    r
823                })
824        });
825
826        debug!("try_promote_type_test_subject: folded ty = {:?}", ty);
827
828        // This will be true if we failed to promote some region.
829        if failed {
830            return None;
831        }
832
833        Some(ClosureOutlivesSubject::Ty(ClosureOutlivesSubjectTy::bind(tcx, ty)))
834    }
835
836    /// Like `universal_upper_bound`, but returns an approximation more suitable
837    /// for diagnostics. If `r` contains multiple disjoint universal regions
838    /// (e.g. 'a and 'b in `fn foo<'a, 'b> { ... }`, we pick the lower-numbered region.
839    /// This corresponds to picking named regions over unnamed regions
840    /// (e.g. picking early-bound regions over a closure late-bound region).
841    ///
842    /// This means that the returned value may not be a true upper bound, since
843    /// only 'static is known to outlive disjoint universal regions.
844    /// Therefore, this method should only be used in diagnostic code,
845    /// where displaying *some* named universal region is better than
846    /// falling back to 'static.
847    #[allow(clippy :: suspicious_else_formatting)]
{
    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("approx_universal_upper_bound",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(847u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["r"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&r)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: RegionVid = loop {};
            return __tracing_attr_fake_return;
        }
        {
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:849",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(849u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&format_args!("{0}",
                                                                self.region_value_str(r)) as &dyn Value))])
                        });
                } else { ; }
            };
            let mut lub = self.universal_regions().fr_fn_body;
            let r_scc = self.constraint_sccs.scc(r);
            let static_r = self.universal_regions().fr_static;
            for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
                let new_lub =
                    self.universal_region_relations.postdom_upper_bound(lub,
                        ur);
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:858",
                                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(858u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                        ::tracing_core::field::FieldSet::new(&["ur", "lub",
                                                        "new_lub"],
                                            ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&debug(&ur) as
                                                            &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&debug(&lub) as
                                                            &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&debug(&new_lub) as
                                                            &dyn Value))])
                            });
                    } else { ; }
                };
                if ur != static_r && lub != static_r && new_lub == static_r {
                    if self.region_definition(ur).external_name.is_some() {
                        lub = ur;
                    } else if self.region_definition(lub).external_name.is_some()
                        {} else { lub = std::cmp::min(ur, lub); }
                } else { lub = new_lub; }
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:882",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(882u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["r", "lub"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&r) as
                                                        &dyn Value)),
                                            (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&lub) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            lub
        }
    }
}#[instrument(level = "debug", skip(self))]
848    pub(crate) fn approx_universal_upper_bound(&self, r: RegionVid) -> RegionVid {
849        debug!("{}", self.region_value_str(r));
850
851        // Find the smallest universal region that contains all other
852        // universal regions within `region`.
853        let mut lub = self.universal_regions().fr_fn_body;
854        let r_scc = self.constraint_sccs.scc(r);
855        let static_r = self.universal_regions().fr_static;
856        for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
857            let new_lub = self.universal_region_relations.postdom_upper_bound(lub, ur);
858            debug!(?ur, ?lub, ?new_lub);
859            // The upper bound of two non-static regions is static: this
860            // means we know nothing about the relationship between these
861            // two regions. Pick a 'better' one to use when constructing
862            // a diagnostic
863            if ur != static_r && lub != static_r && new_lub == static_r {
864                // Prefer the region with an `external_name` - this
865                // indicates that the region is early-bound, so working with
866                // it can produce a nicer error.
867                if self.region_definition(ur).external_name.is_some() {
868                    lub = ur;
869                } else if self.region_definition(lub).external_name.is_some() {
870                    // Leave lub unchanged
871                } else {
872                    // If we get here, we don't have any reason to prefer
873                    // one region over the other. Just pick the
874                    // one with the lower index for now.
875                    lub = std::cmp::min(ur, lub);
876                }
877            } else {
878                lub = new_lub;
879            }
880        }
881
882        debug!(?r, ?lub);
883
884        lub
885    }
886
887    /// Tests if `test` is true when applied to `lower_bound` at
888    /// `point`.
889    fn eval_verify_bound(
890        &self,
891        infcx: &InferCtxt<'tcx>,
892        generic_ty: Ty<'tcx>,
893        lower_bound: RegionVid,
894        verify_bound: &VerifyBound<'tcx>,
895    ) -> bool {
896        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:896",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(896u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("eval_verify_bound(lower_bound={0:?}, verify_bound={1:?})",
                                                    lower_bound, verify_bound) as &dyn Value))])
            });
    } else { ; }
};debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound);
897
898        match verify_bound {
899            VerifyBound::IfEq(verify_if_eq_b) => {
900                self.eval_if_eq(infcx, generic_ty, lower_bound, *verify_if_eq_b)
901            }
902
903            VerifyBound::IsEmpty => {
904                let lower_bound_scc = self.constraint_sccs.scc(lower_bound);
905                self.scc_values.elements_contained_in(lower_bound_scc).next().is_none()
906            }
907
908            VerifyBound::OutlivedBy(r) => {
909                let r_vid = self.to_region_vid(*r);
910                self.eval_outlives(r_vid, lower_bound)
911            }
912
913            VerifyBound::AnyBound(verify_bounds) => verify_bounds.iter().any(|verify_bound| {
914                self.eval_verify_bound(infcx, generic_ty, lower_bound, verify_bound)
915            }),
916
917            VerifyBound::AllBounds(verify_bounds) => verify_bounds.iter().all(|verify_bound| {
918                self.eval_verify_bound(infcx, generic_ty, lower_bound, verify_bound)
919            }),
920        }
921    }
922
923    fn eval_if_eq(
924        &self,
925        infcx: &InferCtxt<'tcx>,
926        generic_ty: Ty<'tcx>,
927        lower_bound: RegionVid,
928        verify_if_eq_b: ty::Binder<'tcx, VerifyIfEq<'tcx>>,
929    ) -> bool {
930        let generic_ty = self.normalize_to_scc_representatives(infcx.tcx, generic_ty);
931        let verify_if_eq_b = self.normalize_to_scc_representatives(infcx.tcx, verify_if_eq_b);
932        match test_type_match::extract_verify_if_eq(infcx.tcx, &verify_if_eq_b, generic_ty) {
933            Some(r) => {
934                let r_vid = self.to_region_vid(r);
935                self.eval_outlives(r_vid, lower_bound)
936            }
937            None => false,
938        }
939    }
940
941    /// This is a conservative normalization procedure. It takes every
942    /// free region in `value` and replaces it with the
943    /// "representative" of its SCC (see `scc_representatives` field).
944    /// We are guaranteed that if two values normalize to the same
945    /// thing, then they are equal; this is a conservative check in
946    /// that they could still be equal even if they normalize to
947    /// different results. (For example, there might be two regions
948    /// with the same value that are not in the same SCC).
949    ///
950    /// N.B., this is not an ideal approach and I would like to revisit
951    /// it. However, it works pretty well in practice. In particular,
952    /// this is needed to deal with projection outlives bounds like
953    ///
954    /// ```text
955    /// <T as Foo<'0>>::Item: '1
956    /// ```
957    ///
958    /// In particular, this routine winds up being important when
959    /// there are bounds like `where <T as Foo<'a>>::Item: 'b` in the
960    /// environment. In this case, if we can show that `'0 == 'a`,
961    /// and that `'b: '1`, then we know that the clause is
962    /// satisfied. In such cases, particularly due to limitations of
963    /// the trait solver =), we usually wind up with a where-clause like
964    /// `T: Foo<'a>` in scope, which thus forces `'0 == 'a` to be added as
965    /// a constraint, and thus ensures that they are in the same SCC.
966    ///
967    /// So why can't we do a more correct routine? Well, we could
968    /// *almost* use the `relate_tys` code, but the way it is
969    /// currently setup it creates inference variables to deal with
970    /// higher-ranked things and so forth, and right now the inference
971    /// context is not permitted to make more inference variables. So
972    /// we use this kind of hacky solution.
973    fn normalize_to_scc_representatives<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
974    where
975        T: TypeFoldable<TyCtxt<'tcx>>,
976    {
977        fold_regions(tcx, value, |r, _db| {
978            let vid = self.to_region_vid(r);
979            let scc = self.constraint_sccs.scc(vid);
980            let repr = self.scc_representative(scc);
981            ty::Region::new_var(tcx, repr)
982        })
983    }
984
985    /// Evaluate whether `sup_region == sub_region`.
986    ///
987    /// Panics if called before `solve()` executes,
988    // This is `pub` because it's used by unstable external borrowck data users, see `consumers.rs`.
989    pub fn eval_equal(&self, r1: RegionVid, r2: RegionVid) -> bool {
990        self.eval_outlives(r1, r2) && self.eval_outlives(r2, r1)
991    }
992
993    /// Evaluate whether `sup_region: sub_region`.
994    ///
995    /// Panics if called before `solve()` executes,
996    // This is `pub` because it's used by unstable external borrowck data users, see `consumers.rs`.
997    x;#[instrument(skip(self), level = "debug", ret)]
998    pub fn eval_outlives(&self, sup_region: RegionVid, sub_region: RegionVid) -> bool {
999        debug!(
1000            "sup_region's value = {:?} universal={:?}",
1001            self.region_value_str(sup_region),
1002            self.universal_regions().is_universal_region(sup_region),
1003        );
1004        debug!(
1005            "sub_region's value = {:?} universal={:?}",
1006            self.region_value_str(sub_region),
1007            self.universal_regions().is_universal_region(sub_region),
1008        );
1009
1010        let sub_region_scc = self.constraint_sccs.scc(sub_region);
1011        let sup_region_scc = self.constraint_sccs.scc(sup_region);
1012
1013        if sub_region_scc == sup_region_scc {
1014            debug!("{sup_region:?}: {sub_region:?} holds trivially; they are in the same SCC");
1015            return true;
1016        }
1017
1018        let fr_static = self.universal_regions().fr_static;
1019
1020        // If we are checking that `'sup: 'sub`, and `'sub` contains
1021        // some placeholder that `'sup` cannot name, then this is only
1022        // true if `'sup` outlives static.
1023        //
1024        // Avoid infinite recursion if `sub_region` is already `'static`
1025        if sub_region != fr_static
1026            && !self.can_name_all_placeholders(sup_region_scc, sub_region_scc)
1027        {
1028            debug!(
1029                "sub universe `{sub_region_scc:?}` is not nameable \
1030                by super `{sup_region_scc:?}`, promoting to static",
1031            );
1032
1033            return self.eval_outlives(sup_region, fr_static);
1034        }
1035
1036        // Both the `sub_region` and `sup_region` consist of the union
1037        // of some number of universal regions (along with the union
1038        // of various points in the CFG; ignore those points for
1039        // now). Therefore, the sup-region outlives the sub-region if,
1040        // for each universal region R1 in the sub-region, there
1041        // exists some region R2 in the sup-region that outlives R1.
1042        let universal_outlives =
1043            self.scc_values.universal_regions_outlived_by(sub_region_scc).all(|r1| {
1044                self.scc_values
1045                    .universal_regions_outlived_by(sup_region_scc)
1046                    .any(|r2| self.universal_region_relations.outlives(r2, r1))
1047            });
1048
1049        if !universal_outlives {
1050            debug!("sub region contains a universal region not present in super");
1051            return false;
1052        }
1053
1054        // Now we have to compare all the points in the sub region and make
1055        // sure they exist in the sup region.
1056
1057        if self.universal_regions().is_universal_region(sup_region) {
1058            // Micro-opt: universal regions contain all points.
1059            debug!("super is universal and hence contains all points");
1060            return true;
1061        }
1062
1063        debug!("comparison between points in sup/sub");
1064
1065        self.scc_values.contains_points(sup_region_scc, sub_region_scc)
1066    }
1067
1068    /// Once regions have been propagated, this method is used to see
1069    /// whether any of the constraints were too strong. In particular,
1070    /// we want to check for a case where a universally quantified
1071    /// region exceeded its bounds. Consider:
1072    /// ```compile_fail
1073    /// fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
1074    /// ```
1075    /// In this case, returning `x` requires `&'a u32 <: &'b u32`
1076    /// and hence we establish (transitively) a constraint that
1077    /// `'a: 'b`. The `propagate_constraints` code above will
1078    /// therefore add `end('a)` into the region for `'b` -- but we
1079    /// have no evidence that `'b` outlives `'a`, so we want to report
1080    /// an error.
1081    ///
1082    /// If `propagated_outlives_requirements` is `Some`, then we will
1083    /// push unsatisfied obligations into there. Otherwise, we'll
1084    /// report them as errors.
1085    fn check_universal_regions(
1086        &self,
1087        mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
1088        errors_buffer: &mut RegionErrors<'tcx>,
1089    ) {
1090        for (fr, fr_definition) in self.definitions.iter_enumerated() {
1091            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1091",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1091u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::tracing_core::field::FieldSet::new(&["fr",
                                        "fr_definition"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&fr) as
                                            &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&fr_definition)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?fr, ?fr_definition);
1092            match fr_definition.origin {
1093                NllRegionVariableOrigin::FreeRegion => {
1094                    // Go through each of the universal regions `fr` and check that
1095                    // they did not grow too large, accumulating any requirements
1096                    // for our caller into the `outlives_requirements` vector.
1097                    self.check_universal_region(
1098                        fr,
1099                        &mut propagated_outlives_requirements,
1100                        errors_buffer,
1101                    );
1102                }
1103
1104                NllRegionVariableOrigin::Placeholder(placeholder) => {
1105                    self.check_bound_universal_region(fr, placeholder, errors_buffer);
1106                }
1107
1108                NllRegionVariableOrigin::Existential { .. } => {
1109                    // nothing to check here
1110                }
1111            }
1112        }
1113    }
1114
1115    /// Checks if Polonius has found any unexpected free region relations.
1116    ///
1117    /// In Polonius terms, a "subset error" (or "illegal subset relation error") is the equivalent
1118    /// of NLL's "checking if any region constraints were too strong": a placeholder origin `'a`
1119    /// was unexpectedly found to be a subset of another placeholder origin `'b`, and means in NLL
1120    /// terms that the "longer free region" `'a` outlived the "shorter free region" `'b`.
1121    ///
1122    /// More details can be found in this blog post by Niko:
1123    /// <https://smallcultfollowing.com/babysteps/blog/2019/01/17/polonius-and-region-errors/>
1124    ///
1125    /// In the canonical example
1126    /// ```compile_fail
1127    /// fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
1128    /// ```
1129    /// returning `x` requires `&'a u32 <: &'b u32` and hence we establish (transitively) a
1130    /// constraint that `'a: 'b`. It is an error that we have no evidence that this
1131    /// constraint holds.
1132    ///
1133    /// If `propagated_outlives_requirements` is `Some`, then we will
1134    /// push unsatisfied obligations into there. Otherwise, we'll
1135    /// report them as errors.
1136    fn check_polonius_subset_errors(
1137        &self,
1138        mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
1139        errors_buffer: &mut RegionErrors<'tcx>,
1140        polonius_output: &PoloniusOutput,
1141    ) {
1142        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1142",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1142u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_polonius_subset_errors: {0} subset_errors",
                                                    polonius_output.subset_errors.len()) as &dyn Value))])
            });
    } else { ; }
};debug!(
1143            "check_polonius_subset_errors: {} subset_errors",
1144            polonius_output.subset_errors.len()
1145        );
1146
1147        // Similarly to `check_universal_regions`: a free region relation, which was not explicitly
1148        // declared ("known") was found by Polonius, so emit an error, or propagate the
1149        // requirements for our caller into the `propagated_outlives_requirements` vector.
1150        //
1151        // Polonius doesn't model regions ("origins") as CFG-subsets or durations, but the
1152        // `longer_fr` and `shorter_fr` terminology will still be used here, for consistency with
1153        // the rest of the NLL infrastructure. The "subset origin" is the "longer free region",
1154        // and the "superset origin" is the outlived "shorter free region".
1155        //
1156        // Note: Polonius will produce a subset error at every point where the unexpected
1157        // `longer_fr`'s "placeholder loan" is contained in the `shorter_fr`. This can be helpful
1158        // for diagnostics in the future, e.g. to point more precisely at the key locations
1159        // requiring this constraint to hold. However, the error and diagnostics code downstream
1160        // expects that these errors are not duplicated (and that they are in a certain order).
1161        // Otherwise, diagnostics messages such as the ones giving names like `'1` to elided or
1162        // anonymous lifetimes for example, could give these names differently, while others like
1163        // the outlives suggestions or the debug output from `#[rustc_regions]` would be
1164        // duplicated. The polonius subset errors are deduplicated here, while keeping the
1165        // CFG-location ordering.
1166        // We can iterate the HashMap here because the result is sorted afterwards.
1167        #[allow(rustc::potential_query_instability)]
1168        let mut subset_errors: Vec<_> = polonius_output
1169            .subset_errors
1170            .iter()
1171            .flat_map(|(_location, subset_errors)| subset_errors.iter())
1172            .collect();
1173        subset_errors.sort();
1174        subset_errors.dedup();
1175
1176        for &(longer_fr, shorter_fr) in subset_errors.into_iter() {
1177            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1177",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1177u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_polonius_subset_errors: subset_error longer_fr={0:?},shorter_fr={1:?}",
                                                    longer_fr, shorter_fr) as &dyn Value))])
            });
    } else { ; }
};debug!(
1178                "check_polonius_subset_errors: subset_error longer_fr={:?},\
1179                 shorter_fr={:?}",
1180                longer_fr, shorter_fr
1181            );
1182
1183            let propagated = self.try_propagate_universal_region_error(
1184                longer_fr.into(),
1185                shorter_fr.into(),
1186                &mut propagated_outlives_requirements,
1187            );
1188            if propagated == RegionRelationCheckResult::Error {
1189                errors_buffer.push(RegionErrorKind::RegionError {
1190                    longer_fr: longer_fr.into(),
1191                    shorter_fr: shorter_fr.into(),
1192                    fr_origin: NllRegionVariableOrigin::FreeRegion,
1193                    is_reported: true,
1194                });
1195            }
1196        }
1197
1198        // Handle the placeholder errors as usual, until the chalk-rustc-polonius triumvirate has
1199        // a more complete picture on how to separate this responsibility.
1200        for (fr, fr_definition) in self.definitions.iter_enumerated() {
1201            match fr_definition.origin {
1202                NllRegionVariableOrigin::FreeRegion => {
1203                    // handled by polonius above
1204                }
1205
1206                NllRegionVariableOrigin::Placeholder(placeholder) => {
1207                    self.check_bound_universal_region(fr, placeholder, errors_buffer);
1208                }
1209
1210                NllRegionVariableOrigin::Existential { .. } => {
1211                    // nothing to check here
1212                }
1213            }
1214        }
1215    }
1216
1217    /// The largest universe of any region nameable from this SCC.
1218    fn max_nameable_universe(&self, scc: ConstraintSccIndex) -> UniverseIndex {
1219        self.scc_annotations[scc].max_nameable_universe()
1220    }
1221
1222    /// Checks the final value for the free region `fr` to see if it
1223    /// grew too large. In particular, examine what `end(X)` points
1224    /// wound up in `fr`'s final value; for each `end(X)` where `X !=
1225    /// fr`, we want to check that `fr: X`. If not, that's either an
1226    /// error, or something we have to propagate to our creator.
1227    ///
1228    /// Things that are to be propagated are accumulated into the
1229    /// `outlives_requirements` vector.
1230    #[allow(clippy :: suspicious_else_formatting)]
{
    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("check_universal_region",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1230u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["longer_fr"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&longer_fr)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let longer_fr_scc = self.constraint_sccs.scc(longer_fr);
            if !self.max_nameable_universe(longer_fr_scc).is_root() {
                ::core::panicking::panic("assertion failed: self.max_nameable_universe(longer_fr_scc).is_root()")
            };
            let representative = self.scc_representative(longer_fr_scc);
            if representative != longer_fr {
                if let RegionRelationCheckResult::Error =
                        self.check_universal_region_relation(longer_fr,
                            representative, propagated_outlives_requirements) {
                    errors_buffer.push(RegionErrorKind::RegionError {
                            longer_fr,
                            shorter_fr: representative,
                            fr_origin: NllRegionVariableOrigin::FreeRegion,
                            is_reported: true,
                        });
                }
                return;
            }
            let mut error_reported = false;
            for shorter_fr in
                self.scc_values.universal_regions_outlived_by(longer_fr_scc) {
                if let RegionRelationCheckResult::Error =
                        self.check_universal_region_relation(longer_fr, shorter_fr,
                            propagated_outlives_requirements) {
                    errors_buffer.push(RegionErrorKind::RegionError {
                            longer_fr,
                            shorter_fr,
                            fr_origin: NllRegionVariableOrigin::FreeRegion,
                            is_reported: !error_reported,
                        });
                    error_reported = true;
                }
            }
        }
    }
}#[instrument(skip(self, propagated_outlives_requirements, errors_buffer), level = "debug")]
1231    fn check_universal_region(
1232        &self,
1233        longer_fr: RegionVid,
1234        propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
1235        errors_buffer: &mut RegionErrors<'tcx>,
1236    ) {
1237        let longer_fr_scc = self.constraint_sccs.scc(longer_fr);
1238
1239        // Because this free region must be in the ROOT universe, we
1240        // know it cannot contain any bound universes.
1241        assert!(self.max_nameable_universe(longer_fr_scc).is_root());
1242
1243        // Only check all of the relations for the main representative of each
1244        // SCC, otherwise just check that we outlive said representative. This
1245        // reduces the number of redundant relations propagated out of
1246        // closures.
1247        // Note that the representative will be a universal region if there is
1248        // one in this SCC, so we will always check the representative here.
1249        let representative = self.scc_representative(longer_fr_scc);
1250        if representative != longer_fr {
1251            if let RegionRelationCheckResult::Error = self.check_universal_region_relation(
1252                longer_fr,
1253                representative,
1254                propagated_outlives_requirements,
1255            ) {
1256                errors_buffer.push(RegionErrorKind::RegionError {
1257                    longer_fr,
1258                    shorter_fr: representative,
1259                    fr_origin: NllRegionVariableOrigin::FreeRegion,
1260                    is_reported: true,
1261                });
1262            }
1263            return;
1264        }
1265
1266        // Find every region `o` such that `fr: o`
1267        // (because `fr` includes `end(o)`).
1268        let mut error_reported = false;
1269        for shorter_fr in self.scc_values.universal_regions_outlived_by(longer_fr_scc) {
1270            if let RegionRelationCheckResult::Error = self.check_universal_region_relation(
1271                longer_fr,
1272                shorter_fr,
1273                propagated_outlives_requirements,
1274            ) {
1275                // We only report the first region error. Subsequent errors are hidden so as
1276                // not to overwhelm the user, but we do record them so as to potentially print
1277                // better diagnostics elsewhere...
1278                errors_buffer.push(RegionErrorKind::RegionError {
1279                    longer_fr,
1280                    shorter_fr,
1281                    fr_origin: NllRegionVariableOrigin::FreeRegion,
1282                    is_reported: !error_reported,
1283                });
1284
1285                error_reported = true;
1286            }
1287        }
1288    }
1289
1290    /// Checks that we can prove that `longer_fr: shorter_fr`. If we can't we attempt to propagate
1291    /// the constraint outward (e.g. to a closure environment), but if that fails, there is an
1292    /// error.
1293    fn check_universal_region_relation(
1294        &self,
1295        longer_fr: RegionVid,
1296        shorter_fr: RegionVid,
1297        propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
1298    ) -> RegionRelationCheckResult {
1299        // If it is known that `fr: o`, carry on.
1300        if self.universal_region_relations.outlives(longer_fr, shorter_fr) {
1301            RegionRelationCheckResult::Ok
1302        } else {
1303            // If we are not in a context where we can't propagate errors, or we
1304            // could not shrink `fr` to something smaller, then just report an
1305            // error.
1306            //
1307            // Note: in this case, we use the unapproximated regions to report the
1308            // error. This gives better error messages in some cases.
1309            self.try_propagate_universal_region_error(
1310                longer_fr,
1311                shorter_fr,
1312                propagated_outlives_requirements,
1313            )
1314        }
1315    }
1316
1317    /// Attempt to propagate a region error (e.g. `'a: 'b`) that is not met to a closure's
1318    /// creator. If we cannot, then the caller should report an error to the user.
1319    fn try_propagate_universal_region_error(
1320        &self,
1321        longer_fr: RegionVid,
1322        shorter_fr: RegionVid,
1323        propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
1324    ) -> RegionRelationCheckResult {
1325        if let Some(propagated_outlives_requirements) = propagated_outlives_requirements {
1326            // Shrink `longer_fr` until we find some non-local regions.
1327            // We'll call them `longer_fr-` -- they are ever so slightly smaller than
1328            // `longer_fr`.
1329            let longer_fr_minus = self.universal_region_relations.non_local_lower_bounds(longer_fr);
1330
1331            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1331",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1331u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("try_propagate_universal_region_error: fr_minus={0:?}",
                                                    longer_fr_minus) as &dyn Value))])
            });
    } else { ; }
};debug!("try_propagate_universal_region_error: fr_minus={:?}", longer_fr_minus);
1332
1333            // If we don't find a any non-local regions, we should error out as there is nothing
1334            // to propagate.
1335            if longer_fr_minus.is_empty() {
1336                return RegionRelationCheckResult::Error;
1337            }
1338
1339            let blame_constraint = self
1340                .best_blame_constraint(longer_fr, NllRegionVariableOrigin::FreeRegion, shorter_fr)
1341                .0;
1342
1343            // Grow `shorter_fr` until we find some non-local regions.
1344            // We will always find at least one: `'static`. We'll call
1345            // them `shorter_fr+` -- they're ever so slightly larger
1346            // than `shorter_fr`.
1347            let shorter_fr_plus =
1348                self.universal_region_relations.non_local_upper_bounds(shorter_fr);
1349            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1349",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1349u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("try_propagate_universal_region_error: shorter_fr_plus={0:?}",
                                                    shorter_fr_plus) as &dyn Value))])
            });
    } else { ; }
};debug!("try_propagate_universal_region_error: shorter_fr_plus={:?}", shorter_fr_plus);
1350
1351            // We then create constraints `longer_fr-: shorter_fr+` that may or may not
1352            // be propagated (see below).
1353            let mut constraints = ::alloc::vec::Vec::new()vec![];
1354            for fr_minus in longer_fr_minus {
1355                for shorter_fr_plus in &shorter_fr_plus {
1356                    constraints.push((fr_minus, *shorter_fr_plus));
1357                }
1358            }
1359
1360            // We only need to propagate at least one of the constraints for
1361            // soundness. However, we want to avoid arbitrary choices here
1362            // and currently don't support returning OR constraints.
1363            //
1364            // If any of the `shorter_fr+` regions are already outlived by `longer_fr-`,
1365            // we propagate only those.
1366            //
1367            // Consider this example (`'b: 'a` == `a -> b`), where we try to propagate `'d: 'a`:
1368            // a --> b --> d
1369            //  \
1370            //   \-> c
1371            // Here, `shorter_fr+` of `'a` == `['b, 'c]`.
1372            // Propagating `'d: 'b` is correct and should occur; `'d: 'c` is redundant because of
1373            // `'d: 'b` and could reject valid code.
1374            //
1375            // So we filter the constraints to regions already outlived by `longer_fr-`, but if
1376            // the filter yields an empty set, we fall back to the original one.
1377            let subset: Vec<_> = constraints
1378                .iter()
1379                .filter(|&&(fr_minus, shorter_fr_plus)| {
1380                    self.eval_outlives(fr_minus, shorter_fr_plus)
1381                })
1382                .copied()
1383                .collect();
1384            let propagated_constraints = if subset.is_empty() { constraints } else { subset };
1385            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1385",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1385u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("try_propagate_universal_region_error: constraints={0:?}",
                                                    propagated_constraints) as &dyn Value))])
            });
    } else { ; }
};debug!(
1386                "try_propagate_universal_region_error: constraints={:?}",
1387                propagated_constraints
1388            );
1389
1390            if !!propagated_constraints.is_empty() {
    {
        ::core::panicking::panic_fmt(format_args!("Expected at least one constraint to propagate here"));
    }
};assert!(
1391                !propagated_constraints.is_empty(),
1392                "Expected at least one constraint to propagate here"
1393            );
1394
1395            for (fr_minus, fr_plus) in propagated_constraints {
1396                // Push the constraint `long_fr-: shorter_fr+`
1397                propagated_outlives_requirements.push(ClosureOutlivesRequirement {
1398                    subject: ClosureOutlivesSubject::Region(fr_minus),
1399                    outlived_free_region: fr_plus,
1400                    blame_span: blame_constraint.cause.span,
1401                    category: blame_constraint.category,
1402                });
1403            }
1404            return RegionRelationCheckResult::Propagated;
1405        }
1406
1407        RegionRelationCheckResult::Error
1408    }
1409
1410    fn check_bound_universal_region(
1411        &self,
1412        longer_fr: RegionVid,
1413        placeholder: ty::PlaceholderRegion<'tcx>,
1414        errors_buffer: &mut RegionErrors<'tcx>,
1415    ) {
1416        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1416",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1416u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_bound_universal_region(fr={0:?}, placeholder={1:?})",
                                                    longer_fr, placeholder) as &dyn Value))])
            });
    } else { ; }
};debug!("check_bound_universal_region(fr={:?}, placeholder={:?})", longer_fr, placeholder,);
1417
1418        let longer_fr_scc = self.constraint_sccs.scc(longer_fr);
1419        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1419",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1419u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_bound_universal_region: longer_fr_scc={0:?}",
                                                    longer_fr_scc) as &dyn Value))])
            });
    } else { ; }
};debug!("check_bound_universal_region: longer_fr_scc={:?}", longer_fr_scc,);
1420
1421        // If we have some bound universal region `'a`, then the only
1422        // elements it can contain is itself -- we don't know anything
1423        // else about it!
1424        if let Some(error_element) = self
1425            .scc_values
1426            .elements_contained_in(longer_fr_scc)
1427            .find(|e| *e != RegionElement::PlaceholderRegion(placeholder))
1428        {
1429            let illegally_outlived_r = self.region_from_element(longer_fr, &error_element);
1430            // Stop after the first error, it gets too noisy otherwise, and does not provide more information.
1431            errors_buffer.push(RegionErrorKind::PlaceholderOutlivesIllegalRegion {
1432                longer_fr,
1433                illegally_outlived_r,
1434            });
1435        } else {
1436            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1436",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1436u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("check_bound_universal_region: all bounds satisfied")
                                            as &dyn Value))])
            });
    } else { ; }
};debug!("check_bound_universal_region: all bounds satisfied");
1437        }
1438    }
1439
1440    pub(crate) fn constraint_path_between_regions(
1441        &self,
1442        from_region: RegionVid,
1443        to_region: RegionVid,
1444    ) -> Option<Vec<OutlivesConstraint<'tcx>>> {
1445        if from_region == to_region {
1446            ::rustc_middle::util::bug::bug_fmt(format_args!("Tried to find a path between {0:?} and itself!",
        from_region));bug!("Tried to find a path between {from_region:?} and itself!");
1447        }
1448        self.constraint_path_to(from_region, |to| to == to_region, true).map(|o| o.0)
1449    }
1450
1451    /// Walks the graph of constraints (where `'a: 'b` is considered
1452    /// an edge `'a -> 'b`) to find a path from `from_region` to
1453    /// `to_region`.
1454    ///
1455    /// Returns: a series of constraints as well as the region `R`
1456    /// that passed the target test.
1457    /// If `include_static_outlives_all` is `true`, then the synthetic
1458    /// outlives constraints `'static -> a` for every region `a` are
1459    /// considered in the search, otherwise they are ignored.
1460    x;#[instrument(skip(self, target_test), ret)]
1461    pub(crate) fn constraint_path_to(
1462        &self,
1463        from_region: RegionVid,
1464        target_test: impl Fn(RegionVid) -> bool,
1465        include_placeholder_static: bool,
1466    ) -> Option<(Vec<OutlivesConstraint<'tcx>>, RegionVid)> {
1467        self.find_constraint_path_between_regions_inner(
1468            true,
1469            from_region,
1470            &target_test,
1471            include_placeholder_static,
1472        )
1473        .or_else(|| {
1474            self.find_constraint_path_between_regions_inner(
1475                false,
1476                from_region,
1477                &target_test,
1478                include_placeholder_static,
1479            )
1480        })
1481    }
1482
1483    /// The constraints we get from equating the hidden type of each use of an opaque
1484    /// with its final hidden type may end up getting preferred over other, potentially
1485    /// longer constraint paths.
1486    ///
1487    /// Given that we compute the final hidden type by relying on this existing constraint
1488    /// path, this can easily end up hiding the actual reason for why we require these regions
1489    /// to be equal.
1490    ///
1491    /// To handle this, we first look at the path while ignoring these constraints and then
1492    /// retry while considering them. This is not perfect, as the `from_region` may have already
1493    /// been partially related to its argument region, so while we rely on a member constraint
1494    /// to get a complete path, the most relevant step of that path already existed before then.
1495    fn find_constraint_path_between_regions_inner(
1496        &self,
1497        ignore_opaque_type_constraints: bool,
1498        from_region: RegionVid,
1499        target_test: impl Fn(RegionVid) -> bool,
1500        include_placeholder_static: bool,
1501    ) -> Option<(Vec<OutlivesConstraint<'tcx>>, RegionVid)> {
1502        let mut context = IndexVec::from_elem(Trace::NotVisited, &self.definitions);
1503        context[from_region] = Trace::StartRegion;
1504
1505        let fr_static = self.universal_regions().fr_static;
1506
1507        // Use a deque so that we do a breadth-first search. We will
1508        // stop at the first match, which ought to be the shortest
1509        // path (fewest constraints).
1510        let mut deque = VecDeque::new();
1511        deque.push_back(from_region);
1512
1513        while let Some(r) = deque.pop_front() {
1514            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1514",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1514u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("constraint_path_to: from_region={0:?} r={1:?} value={2}",
                                                    from_region, r, self.region_value_str(r)) as &dyn Value))])
            });
    } else { ; }
};debug!(
1515                "constraint_path_to: from_region={:?} r={:?} value={}",
1516                from_region,
1517                r,
1518                self.region_value_str(r),
1519            );
1520
1521            // Check if we reached the region we were looking for. If so,
1522            // we can reconstruct the path that led to it and return it.
1523            if target_test(r) {
1524                let mut result = ::alloc::vec::Vec::new()vec![];
1525                let mut p = r;
1526                // This loop is cold and runs at the end, which is why we delay
1527                // `OutlivesConstraint` construction until now.
1528                loop {
1529                    match context[p] {
1530                        Trace::FromGraph(c) => {
1531                            p = c.sup;
1532                            result.push(*c);
1533                        }
1534
1535                        Trace::FromStatic(sub) => {
1536                            let c = OutlivesConstraint {
1537                                sup: fr_static,
1538                                sub,
1539                                locations: Locations::All(DUMMY_SP),
1540                                span: DUMMY_SP,
1541                                category: ConstraintCategory::Internal,
1542                                variance_info: ty::VarianceDiagInfo::default(),
1543                                from_closure: false,
1544                            };
1545                            p = c.sup;
1546                            result.push(c);
1547                        }
1548
1549                        Trace::StartRegion => {
1550                            result.reverse();
1551                            return Some((result, r));
1552                        }
1553
1554                        Trace::NotVisited => {
1555                            ::rustc_middle::util::bug::bug_fmt(format_args!("found unvisited region {0:?} on path to {1:?}",
        p, r))bug!("found unvisited region {:?} on path to {:?}", p, r)
1556                        }
1557                    }
1558                }
1559            }
1560
1561            // Otherwise, walk over the outgoing constraints and
1562            // enqueue any regions we find, keeping track of how we
1563            // reached them.
1564
1565            // A constraint like `'r: 'x` can come from our constraint
1566            // graph.
1567
1568            // Always inline this closure because it can be hot.
1569            let mut handle_trace = #[inline(always)]
1570            |sub, trace| {
1571                if let Trace::NotVisited = context[sub] {
1572                    context[sub] = trace;
1573                    deque.push_back(sub);
1574                }
1575            };
1576
1577            // If this is the `'static` region and the graph's direction is normal, then set up the
1578            // Edges iterator to return all regions (#53178).
1579            if r == fr_static && self.constraint_graph.is_normal() {
1580                for sub in self.constraint_graph.outgoing_edges_from_static() {
1581                    handle_trace(sub, Trace::FromStatic(sub));
1582                }
1583            } else {
1584                let edges = self.constraint_graph.outgoing_edges_from_graph(r, &self.constraints);
1585                // This loop can be hot.
1586                for constraint in edges {
1587                    match constraint.category {
1588                        ConstraintCategory::OutlivesUnnameablePlaceholder(_)
1589                            if !include_placeholder_static =>
1590                        {
1591                            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1591",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1591u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("Ignoring illegal placeholder constraint: {0:?}",
                                                    constraint) as &dyn Value))])
            });
    } else { ; }
};debug!("Ignoring illegal placeholder constraint: {constraint:?}");
1592                            continue;
1593                        }
1594                        ConstraintCategory::OpaqueType if ignore_opaque_type_constraints => {
1595                            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1595",
                        "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1595u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                        ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("Ignoring member constraint: {0:?}",
                                                    constraint) as &dyn Value))])
            });
    } else { ; }
};debug!("Ignoring member constraint: {constraint:?}");
1596                            continue;
1597                        }
1598                        _ => {}
1599                    }
1600
1601                    if true {
    match (&constraint.sup, &r) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    };
};debug_assert_eq!(constraint.sup, r);
1602                    handle_trace(constraint.sub, Trace::FromGraph(constraint));
1603                }
1604            }
1605        }
1606
1607        None
1608    }
1609
1610    /// Finds some region R such that `fr1: R` and `R` is live at `location`.
1611    x;#[instrument(skip(self), level = "trace", ret)]
1612    pub(crate) fn find_sub_region_live_at(&self, fr1: RegionVid, location: Location) -> RegionVid {
1613        trace!(scc = ?self.constraint_sccs.scc(fr1));
1614        trace!(universe = ?self.max_nameable_universe(self.constraint_sccs.scc(fr1)));
1615        self.constraint_path_to(fr1, |r| {
1616            trace!(?r, liveness_constraints=?self.liveness_constraints.pretty_print_live_points(r));
1617            self.liveness_constraints.is_live_at(r, location)
1618        }, true).unwrap().1
1619    }
1620
1621    /// Get the region outlived by `longer_fr` and live at `element`.
1622    fn region_from_element(
1623        &self,
1624        longer_fr: RegionVid,
1625        element: &RegionElement<'tcx>,
1626    ) -> RegionVid {
1627        match *element {
1628            RegionElement::Location(l) => self.find_sub_region_live_at(longer_fr, l),
1629            RegionElement::RootUniversalRegion(r) => r,
1630            RegionElement::PlaceholderRegion(error_placeholder) => self
1631                .definitions
1632                .iter_enumerated()
1633                .find_map(|(r, definition)| match definition.origin {
1634                    NllRegionVariableOrigin::Placeholder(p) if p == error_placeholder => Some(r),
1635                    _ => None,
1636                })
1637                .unwrap(),
1638        }
1639    }
1640
1641    /// Get the region definition of `r`.
1642    pub(crate) fn region_definition(&self, r: RegionVid) -> &RegionDefinition<'tcx> {
1643        &self.definitions[r]
1644    }
1645
1646    /// Check if the SCC of `r` contains `upper`.
1647    pub(crate) fn upper_bound_in_region_scc(&self, r: RegionVid, upper: RegionVid) -> bool {
1648        let r_scc = self.constraint_sccs.scc(r);
1649        self.scc_values.contains(r_scc, upper)
1650    }
1651
1652    pub(crate) fn universal_regions(&self) -> &UniversalRegions<'tcx> {
1653        &self.universal_region_relations.universal_regions
1654    }
1655
1656    /// Tries to find the best constraint to blame for the fact that
1657    /// `R: from_region`, where `R` is some region that meets
1658    /// `target_test`. This works by following the constraint graph,
1659    /// creating a constraint path that forces `R` to outlive
1660    /// `from_region`, and then finding the best choices within that
1661    /// path to blame.
1662    #[allow(clippy :: suspicious_else_formatting)]
{
    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("best_blame_constraint",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1662u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["from_region",
                                                    "from_region_origin", "to_region"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&from_region)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&from_region_origin)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&to_region)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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:
                    (BlameConstraint<'tcx>, Vec<OutlivesConstraint<'tcx>>) =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !(from_region != to_region) {
                {
                    ::core::panicking::panic_fmt(format_args!("Trying to blame a region for itself!"));
                }
            };
            let path =
                self.constraint_path_between_regions(from_region,
                        to_region).unwrap();
            let due_to_placeholder_outlives =
                path.iter().find_map(|c|
                        {
                            if let ConstraintCategory::OutlivesUnnameablePlaceholder(unnameable)
                                    = c.category {
                                Some(unnameable)
                            } else { None }
                        });
            let path =
                if let Some(unnameable) = due_to_placeholder_outlives &&
                        unnameable != from_region {
                    self.constraint_path_to(from_region, |r| r == unnameable,
                                false).unwrap().0
                } else { path };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1694",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1694u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&format_args!("path={0:#?}",
                                                                path.iter().map(|c|
                                                                            ::alloc::__export::must_use({
                                                                                    ::alloc::fmt::format(format_args!("{0:?} ({1:?}: {2:?})", c,
                                                                                            self.constraint_sccs.scc(c.sup),
                                                                                            self.constraint_sccs.scc(c.sub)))
                                                                                })).collect::<Vec<_>>()) as &dyn Value))])
                        });
                } else { ; }
            };
            let cause_code =
                path.iter().find_map(|constraint|
                            {
                                if let ConstraintCategory::Predicate(predicate_span) =
                                        constraint.category {
                                    Some(ObligationCauseCode::WhereClause(CRATE_DEF_ID.to_def_id(),
                                            predicate_span))
                                } else { None }
                            }).unwrap_or_else(|| ObligationCauseCode::Misc);
            let blame_source =
                match from_region_origin {
                    NllRegionVariableOrigin::FreeRegion => true,
                    NllRegionVariableOrigin::Placeholder(_) => false,
                    NllRegionVariableOrigin::Existential { name: _ } => {
                        {
                            ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                    format_args!("existentials can outlive everything")));
                        }
                    }
                };
            let constraint_interest =
                |constraint: &OutlivesConstraint<'tcx>|
                    {
                        let category =
                            if let Some(kind) = constraint.span.desugaring_kind() &&
                                    (kind != DesugaringKind::QuestionMark ||
                                            !#[allow(non_exhaustive_omitted_patterns)] match constraint.category
                                                    {
                                                    ConstraintCategory::Return(_) => true,
                                                    _ => false,
                                                }) {
                                ConstraintCategory::Boring
                            } else { constraint.category };
                        let interest =
                            match category {
                                ConstraintCategory::Return(_) => 0,
                                ConstraintCategory::Cast {
                                    is_raw_ptr_dyn_type_cast: _,
                                    unsize_to: Some(unsize_ty),
                                    is_implicit_coercion: true } if
                                    to_region == self.universal_regions().fr_static &&
                                                let ty::Adt(_, args) = unsize_ty.kind() &&
                                            args.iter().any(|arg|
                                                    arg.as_type().is_some_and(|ty| ty.is_trait())) &&
                                        !path.iter().any(|c|
                                                    #[allow(non_exhaustive_omitted_patterns)] match c.category {
                                                        ConstraintCategory::TypeAnnotation(_) => true,
                                                        _ => false,
                                                    }) => {
                                    1
                                }
                                ConstraintCategory::Yield | ConstraintCategory::UseAsConst |
                                    ConstraintCategory::UseAsStatic |
                                    ConstraintCategory::TypeAnnotation(AnnotationSource::Ascription
                                    | AnnotationSource::Declaration |
                                    AnnotationSource::OpaqueCast) | ConstraintCategory::Cast {
                                    .. } | ConstraintCategory::CallArgument(_) |
                                    ConstraintCategory::CopyBound |
                                    ConstraintCategory::SizedBound |
                                    ConstraintCategory::Assignment | ConstraintCategory::Usage |
                                    ConstraintCategory::ClosureUpvar(_) => 2,
                                ConstraintCategory::TypeAnnotation(AnnotationSource::GenericArg)
                                    => 3,
                                ConstraintCategory::Predicate(_) |
                                    ConstraintCategory::OpaqueType => 4,
                                ConstraintCategory::Boring => 5,
                                ConstraintCategory::BoringNoLocation => 6,
                                ConstraintCategory::Internal => 7,
                                ConstraintCategory::OutlivesUnnameablePlaceholder(_) => 8,
                                ConstraintCategory::SolverRegionConstraint(_) => 9,
                            };
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1846",
                                                "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1846u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                                ::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};
                                        let mut iter = __CALLSITE.metadata().fields().iter();
                                        __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                            ::tracing::__macro_support::Option::Some(&format_args!("constraint {0:?} category: {1:?}, interest: {2:?}",
                                                                            constraint, category, interest) as &dyn Value))])
                                    });
                            } else { ; }
                        };
                        interest
                    };
            let best_choice =
                if blame_source {
                    path.iter().enumerate().rev().min_by_key(|(_, c)|
                                    constraint_interest(c)).unwrap().0
                } else {
                    path.iter().enumerate().min_by_key(|(_, c)|
                                    constraint_interest(c)).unwrap().0
                };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_borrowck/src/region_infer/mod.rs:1857",
                                    "rustc_borrowck::region_infer", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/region_infer/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1857u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::region_infer"),
                                    ::tracing_core::field::FieldSet::new(&["best_choice",
                                                    "blame_source"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&best_choice)
                                                        as &dyn Value)),
                                            (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&blame_source)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            let best_constraint =
                if let Some(next) = path.get(best_choice + 1) &&
                            #[allow(non_exhaustive_omitted_patterns)] match path[best_choice].category
                                {
                                ConstraintCategory::Return(_) => true,
                                _ => false,
                            } && next.category == ConstraintCategory::OpaqueType {
                    *next
                } else if path[best_choice].category ==
                            ConstraintCategory::Return(ReturnConstraint::Normal) &&
                        let Some(field) =
                            path.iter().find_map(|p|
                                    {
                                        if let ConstraintCategory::ClosureUpvar(f) = p.category {
                                            Some(f)
                                        } else { None }
                                    }) {
                    OutlivesConstraint {
                        category: ConstraintCategory::Return(ReturnConstraint::ClosureUpvar(field)),
                        ..path[best_choice]
                    }
                } else { path[best_choice] };
            if !!#[allow(non_exhaustive_omitted_patterns)] match best_constraint.category
                            {
                            ConstraintCategory::OutlivesUnnameablePlaceholder(_) =>
                                true,
                            _ => false,
                        } {
                {
                    ::core::panicking::panic_fmt(format_args!("Illegal placeholder constraint blamed; should have redirected to other region relation"));
                }
            };
            let blame_constraint =
                BlameConstraint {
                    category: best_constraint.category,
                    from_closure: best_constraint.from_closure,
                    cause: ObligationCause::new(best_constraint.span,
                        CRATE_DEF_ID, cause_code.clone()),
                    variance_info: best_constraint.variance_info,
                };
            (blame_constraint, path)
        }
    }
}#[instrument(level = "debug", skip(self))]
1663    pub(crate) fn best_blame_constraint(
1664        &self,
1665        from_region: RegionVid,
1666        from_region_origin: NllRegionVariableOrigin<'tcx>,
1667        to_region: RegionVid,
1668    ) -> (BlameConstraint<'tcx>, Vec<OutlivesConstraint<'tcx>>) {
1669        assert!(from_region != to_region, "Trying to blame a region for itself!");
1670
1671        let path = self.constraint_path_between_regions(from_region, to_region).unwrap();
1672
1673        // If we are passing through a constraint added because we reached an unnameable placeholder `'unnameable`,
1674        // redirect search towards `'unnameable`.
1675        let due_to_placeholder_outlives = path.iter().find_map(|c| {
1676            if let ConstraintCategory::OutlivesUnnameablePlaceholder(unnameable) = c.category {
1677                Some(unnameable)
1678            } else {
1679                None
1680            }
1681        });
1682
1683        // Edge case: it's possible that `'from_region` is an unnameable placeholder.
1684        let path = if let Some(unnameable) = due_to_placeholder_outlives
1685            && unnameable != from_region
1686        {
1687            // We ignore the extra edges due to unnameable placeholders to get
1688            // an explanation that was present in the original constraint graph.
1689            self.constraint_path_to(from_region, |r| r == unnameable, false).unwrap().0
1690        } else {
1691            path
1692        };
1693
1694        debug!(
1695            "path={:#?}",
1696            path.iter()
1697                .map(|c| format!(
1698                    "{:?} ({:?}: {:?})",
1699                    c,
1700                    self.constraint_sccs.scc(c.sup),
1701                    self.constraint_sccs.scc(c.sub),
1702                ))
1703                .collect::<Vec<_>>()
1704        );
1705
1706        // We try to avoid reporting a `ConstraintCategory::Predicate` as our best constraint.
1707        // Instead, we use it to produce an improved `ObligationCauseCode`.
1708        // FIXME - determine what we should do if we encounter multiple
1709        // `ConstraintCategory::Predicate` constraints. Currently, we just pick the first one.
1710        let cause_code = path
1711            .iter()
1712            .find_map(|constraint| {
1713                if let ConstraintCategory::Predicate(predicate_span) = constraint.category {
1714                    // We currently do not store the `DefId` in the `ConstraintCategory`
1715                    // for performances reasons. The error reporting code used by NLL only
1716                    // uses the span, so this doesn't cause any problems at the moment.
1717                    Some(ObligationCauseCode::WhereClause(CRATE_DEF_ID.to_def_id(), predicate_span))
1718                } else {
1719                    None
1720                }
1721            })
1722            .unwrap_or_else(|| ObligationCauseCode::Misc);
1723
1724        // When reporting an error, there is typically a chain of constraints leading from some
1725        // "source" region which must outlive some "target" region.
1726        // In most cases, we prefer to "blame" the constraints closer to the target --
1727        // but there is one exception. When constraints arise from higher-ranked subtyping,
1728        // we generally prefer to blame the source value,
1729        // as the "target" in this case tends to be some type annotation that the user gave.
1730        // Therefore, if we find that the region origin is some instantiation
1731        // of a higher-ranked region, we start our search from the "source" point
1732        // rather than the "target", and we also tweak a few other things.
1733        //
1734        // An example might be this bit of Rust code:
1735        //
1736        // ```rust
1737        // let x: fn(&'static ()) = |_| {};
1738        // let y: for<'a> fn(&'a ()) = x;
1739        // ```
1740        //
1741        // In MIR, this will be converted into a combination of assignments and type ascriptions.
1742        // In particular, the 'static is imposed through a type ascription:
1743        //
1744        // ```rust
1745        // x = ...;
1746        // AscribeUserType(x, fn(&'static ())
1747        // y = x;
1748        // ```
1749        //
1750        // We wind up ultimately with constraints like
1751        //
1752        // ```rust
1753        // !a: 'temp1 // from the `y = x` statement
1754        // 'temp1: 'temp2
1755        // 'temp2: 'static // from the AscribeUserType
1756        // ```
1757        //
1758        // and here we prefer to blame the source (the y = x statement).
1759        let blame_source = match from_region_origin {
1760            NllRegionVariableOrigin::FreeRegion => true,
1761            NllRegionVariableOrigin::Placeholder(_) => false,
1762            // `'existential: 'whatever` never results in a region error by itself.
1763            // We may always infer it to `'static` afterall. This means while an error
1764            // path may go through an existential, these existentials are never the
1765            // `from_region`.
1766            NllRegionVariableOrigin::Existential { name: _ } => {
1767                unreachable!("existentials can outlive everything")
1768            }
1769        };
1770
1771        // To pick a constraint to blame, we organize constraints by how interesting we expect them
1772        // to be in diagnostics, then pick the most interesting one closest to either the source or
1773        // the target on our constraint path.
1774        let constraint_interest = |constraint: &OutlivesConstraint<'tcx>| {
1775            // Try to avoid blaming constraints from desugarings, since they may not clearly match
1776            // match what users have written. As an exception, allow blaming returns generated by
1777            // `?` desugaring, since the correspondence is fairly clear.
1778            let category = if let Some(kind) = constraint.span.desugaring_kind()
1779                && (kind != DesugaringKind::QuestionMark
1780                    || !matches!(constraint.category, ConstraintCategory::Return(_)))
1781            {
1782                ConstraintCategory::Boring
1783            } else {
1784                constraint.category
1785            };
1786
1787            let interest = match category {
1788                // Returns usually provide a type to blame and have specially written diagnostics,
1789                // so prioritize them.
1790                ConstraintCategory::Return(_) => 0,
1791                // Unsizing coercions are interesting, since we have a note for that:
1792                // `BorrowExplanation::add_object_lifetime_default_note`.
1793                // FIXME(dianne): That note shouldn't depend on a coercion being blamed; see issue
1794                // #131008 for an example of where we currently don't emit it but should.
1795                // Once the note is handled properly, this case should be removed. Until then, it
1796                // should be as limited as possible; the note is prone to false positives and this
1797                // constraint usually isn't best to blame.
1798                ConstraintCategory::Cast {
1799                    is_raw_ptr_dyn_type_cast: _,
1800                    unsize_to: Some(unsize_ty),
1801                    is_implicit_coercion: true,
1802                } if to_region == self.universal_regions().fr_static
1803                    // Mirror the note's condition, to minimize how often this diverts blame.
1804                    && let ty::Adt(_, args) = unsize_ty.kind()
1805                    && args.iter().any(|arg| arg.as_type().is_some_and(|ty| ty.is_trait()))
1806                    // Mimic old logic for this, to minimize false positives in tests.
1807                    && !path
1808                        .iter()
1809                        .any(|c| matches!(c.category, ConstraintCategory::TypeAnnotation(_))) =>
1810                {
1811                    1
1812                }
1813                // Between other interesting constraints, order by their position on the `path`.
1814                ConstraintCategory::Yield
1815                | ConstraintCategory::UseAsConst
1816                | ConstraintCategory::UseAsStatic
1817                | ConstraintCategory::TypeAnnotation(
1818                    AnnotationSource::Ascription
1819                    | AnnotationSource::Declaration
1820                    | AnnotationSource::OpaqueCast,
1821                )
1822                | ConstraintCategory::Cast { .. }
1823                | ConstraintCategory::CallArgument(_)
1824                | ConstraintCategory::CopyBound
1825                | ConstraintCategory::SizedBound
1826                | ConstraintCategory::Assignment
1827                | ConstraintCategory::Usage
1828                | ConstraintCategory::ClosureUpvar(_) => 2,
1829                // Generic arguments are unlikely to be what relates regions together
1830                ConstraintCategory::TypeAnnotation(AnnotationSource::GenericArg) => 3,
1831                // We handle predicates and opaque types specially; don't prioritize them here.
1832                ConstraintCategory::Predicate(_) | ConstraintCategory::OpaqueType => 4,
1833                // `Boring` constraints can correspond to user-written code and have useful spans,
1834                // but don't provide any other useful information for diagnostics.
1835                ConstraintCategory::Boring => 5,
1836                // `BoringNoLocation` constraints can point to user-written code, but are less
1837                // specific, and are not used for relations that would make sense to blame.
1838                ConstraintCategory::BoringNoLocation => 6,
1839                // Do not blame internal constraints if we can avoid it. Never blame
1840                // the `'region: 'static` constraints introduced by placeholder outlives.
1841                ConstraintCategory::Internal => 7,
1842                ConstraintCategory::OutlivesUnnameablePlaceholder(_) => 8,
1843                ConstraintCategory::SolverRegionConstraint(_) => 9,
1844            };
1845
1846            debug!("constraint {constraint:?} category: {category:?}, interest: {interest:?}");
1847
1848            interest
1849        };
1850
1851        let best_choice = if blame_source {
1852            path.iter().enumerate().rev().min_by_key(|(_, c)| constraint_interest(c)).unwrap().0
1853        } else {
1854            path.iter().enumerate().min_by_key(|(_, c)| constraint_interest(c)).unwrap().0
1855        };
1856
1857        debug!(?best_choice, ?blame_source);
1858
1859        let best_constraint = if let Some(next) = path.get(best_choice + 1)
1860            && matches!(path[best_choice].category, ConstraintCategory::Return(_))
1861            && next.category == ConstraintCategory::OpaqueType
1862        {
1863            // The return expression is being influenced by the return type being
1864            // impl Trait, point at the return type and not the return expr.
1865            *next
1866        } else if path[best_choice].category == ConstraintCategory::Return(ReturnConstraint::Normal)
1867            && let Some(field) = path.iter().find_map(|p| {
1868                if let ConstraintCategory::ClosureUpvar(f) = p.category { Some(f) } else { None }
1869            })
1870        {
1871            OutlivesConstraint {
1872                category: ConstraintCategory::Return(ReturnConstraint::ClosureUpvar(field)),
1873                ..path[best_choice]
1874            }
1875        } else {
1876            path[best_choice]
1877        };
1878
1879        assert!(
1880            !matches!(
1881                best_constraint.category,
1882                ConstraintCategory::OutlivesUnnameablePlaceholder(_)
1883            ),
1884            "Illegal placeholder constraint blamed; should have redirected to other region relation"
1885        );
1886
1887        let blame_constraint = BlameConstraint {
1888            category: best_constraint.category,
1889            from_closure: best_constraint.from_closure,
1890            cause: ObligationCause::new(best_constraint.span, CRATE_DEF_ID, cause_code.clone()),
1891            variance_info: best_constraint.variance_info,
1892        };
1893        (blame_constraint, path)
1894    }
1895
1896    pub(crate) fn universe_info(&self, universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
1897        // Query canonicalization can create local superuniverses (for example in
1898        // `InferCtx::query_response_instantiation_guess`), but they don't have an associated
1899        // `UniverseInfo` explaining why they were created.
1900        // This can cause ICEs if these causes are accessed in diagnostics, for example in issue
1901        // #114907 where this happens via liveness and dropck outlives results.
1902        // Therefore, we return a default value in case that happens, which should at worst emit a
1903        // suboptimal error, instead of the ICE.
1904        self.universe_causes.get(&universe).cloned().unwrap_or_else(UniverseInfo::other)
1905    }
1906
1907    /// Tries to find the terminator of the loop in which the region 'r' resides.
1908    /// Returns the location of the terminator if found.
1909    pub(crate) fn find_loop_terminator_location(
1910        &self,
1911        r: RegionVid,
1912        body: &Body<'_>,
1913    ) -> Option<Location> {
1914        let scc = self.constraint_sccs.scc(r);
1915        let locations = self.scc_values.locations_outlived_by(scc);
1916        for location in locations {
1917            let bb = &body[location.block];
1918            if let Some(terminator) = &bb.terminator
1919                // terminator of a loop should be TerminatorKind::FalseUnwind
1920                && let TerminatorKind::FalseUnwind { .. } = terminator.kind
1921            {
1922                return Some(location);
1923            }
1924        }
1925        None
1926    }
1927
1928    /// Access to the SCC constraint graph.
1929    /// This can be used to quickly under-approximate the regions which are equal to each other
1930    /// and their relative orderings.
1931    // This is `pub` because it's used by unstable external borrowck data users, see `consumers.rs`.
1932    pub fn constraint_sccs(&self) -> &ConstraintSccs {
1933        &self.constraint_sccs
1934    }
1935
1936    /// Returns the representative `RegionVid` for a given SCC.
1937    /// See `RegionTracker` for how a region variable ID is chosen.
1938    ///
1939    /// It is a hacky way to manage checking regions for equality,
1940    /// since we can 'canonicalize' each region to the representative
1941    /// of its SCC and be sure that -- if they have the same repr --
1942    /// they *must* be equal (though not having the same repr does not
1943    /// mean they are unequal).
1944    fn scc_representative(&self, scc: ConstraintSccIndex) -> RegionVid {
1945        self.scc_annotations[scc].representative.rvid()
1946    }
1947
1948    pub(crate) fn liveness_constraints(&self) -> &LivenessValues {
1949        &self.liveness_constraints
1950    }
1951
1952    /// When using `-Zpolonius=next`, records the given live loans for the loan scopes and active
1953    /// loans dataflow computations.
1954    pub(crate) fn record_live_loans(&mut self, live_loans: LiveLoans) {
1955        self.liveness_constraints.record_live_loans(live_loans);
1956    }
1957
1958    /// Returns whether the `loan_idx` is live at the given `location`: whether its issuing
1959    /// region is contained within the type of a variable that is live at this point.
1960    /// Note: for now, the sets of live loans is only available when using `-Zpolonius=next`.
1961    pub(crate) fn is_loan_live_at(&self, loan_idx: BorrowIndex, location: Location) -> bool {
1962        let point = self.liveness_constraints.point_from_location(location);
1963        self.liveness_constraints.is_loan_live_at(loan_idx, point)
1964    }
1965}
1966
1967#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for BlameConstraint<'tcx> {
    #[inline]
    fn clone(&self) -> BlameConstraint<'tcx> {
        BlameConstraint {
            category: ::core::clone::Clone::clone(&self.category),
            from_closure: ::core::clone::Clone::clone(&self.from_closure),
            cause: ::core::clone::Clone::clone(&self.cause),
            variance_info: ::core::clone::Clone::clone(&self.variance_info),
        }
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for BlameConstraint<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "BlameConstraint", "category", &self.category, "from_closure",
            &self.from_closure, "cause", &self.cause, "variance_info",
            &&self.variance_info)
    }
}Debug)]
1968pub(crate) struct BlameConstraint<'tcx> {
1969    pub category: ConstraintCategory<'tcx>,
1970    pub from_closure: bool,
1971    pub cause: ObligationCause<'tcx>,
1972    pub variance_info: ty::VarianceDiagInfo<TyCtxt<'tcx>>,
1973}