Skip to main content

rustc_borrowck/type_check/
free_region_relations.rs

1use rustc_data_structures::frozen::Frozen;
2use rustc_data_structures::transitive_relation::{TransitiveRelation, TransitiveRelationBuilder};
3use rustc_hir::def::DefKind;
4use rustc_infer::infer::canonical::QueryRegionConstraints;
5use rustc_infer::infer::outlives;
6use rustc_infer::infer::outlives::env::RegionBoundPairs;
7use rustc_infer::infer::region_constraints::GenericKind;
8use rustc_infer::traits::query::type_op::DeeplyNormalize;
9use rustc_middle::mir::ConstraintCategory;
10use rustc_middle::traits::query::OutlivesBound;
11use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
12use rustc_span::{ErrorGuaranteed, Span};
13use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
14use tracing::{debug, instrument};
15use type_op::TypeOpOutput;
16
17use crate::BorrowckInferCtxt;
18use crate::type_check::{Locations, MirTypeckRegionConstraints, constraint_conversion};
19use crate::universal_regions::UniversalRegions;
20
21#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for UniversalRegionRelations<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "UniversalRegionRelations", "universal_regions",
            &self.universal_regions, "outlives", &self.outlives,
            "inverse_outlives", &&self.inverse_outlives)
    }
}Debug)]
22#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for UniversalRegionRelations<'tcx> {
    #[inline]
    fn clone(&self) -> UniversalRegionRelations<'tcx> {
        UniversalRegionRelations {
            universal_regions: ::core::clone::Clone::clone(&self.universal_regions),
            outlives: ::core::clone::Clone::clone(&self.outlives),
            inverse_outlives: ::core::clone::Clone::clone(&self.inverse_outlives),
        }
    }
}Clone)] // FIXME(#146079)
23pub(crate) struct UniversalRegionRelations<'tcx> {
24    pub(crate) universal_regions: UniversalRegions<'tcx>,
25
26    /// Stores the outlives relations that are known to hold from the
27    /// implied bounds, in-scope where-clauses, and that sort of
28    /// thing.
29    outlives: TransitiveRelation<RegionVid>,
30
31    /// This is the `<=` relation; that is, if `a: b`, then `b <= a`,
32    /// and we store that here. This is useful when figuring out how
33    /// to express some local region in terms of external regions our
34    /// caller will understand.
35    inverse_outlives: TransitiveRelation<RegionVid>,
36}
37
38/// As part of computing the free region relations, we also have to
39/// normalize the input-output types, which we then need later. So we
40/// return those. This vector consists of first the input types and
41/// then the output type as the last element.
42type NormalizedInputsAndOutput<'tcx> = Vec<Ty<'tcx>>;
43
44pub(crate) struct CreateResult<'tcx> {
45    pub(crate) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
46    pub(crate) region_bound_pairs: Frozen<RegionBoundPairs<'tcx>>,
47    pub(crate) known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesPredicate<'tcx>>>,
48    pub(crate) normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>,
49}
50
51pub(crate) fn create<'tcx>(
52    infcx: &BorrowckInferCtxt<'tcx>,
53    universal_regions: UniversalRegions<'tcx>,
54    constraints: &mut MirTypeckRegionConstraints<'tcx>,
55) -> CreateResult<'tcx> {
56    UniversalRegionRelationsBuilder {
57        infcx,
58        constraints,
59        universal_regions,
60        region_bound_pairs: Default::default(),
61        outlives: Default::default(),
62        inverse_outlives: Default::default(),
63    }
64    .create()
65}
66
67impl UniversalRegionRelations<'_> {
68    /// Given two universal regions, returns the postdominating
69    /// upper-bound (effectively the least upper bound).
70    ///
71    /// (See `TransitiveRelation::postdom_upper_bound` for details on
72    /// the postdominating upper bound in general.)
73    pub(crate) fn postdom_upper_bound(&self, fr1: RegionVid, fr2: RegionVid) -> RegionVid {
74        if !self.universal_regions.is_universal_region(fr1) {
    ::core::panicking::panic("assertion failed: self.universal_regions.is_universal_region(fr1)")
};assert!(self.universal_regions.is_universal_region(fr1));
75        if !self.universal_regions.is_universal_region(fr2) {
    ::core::panicking::panic("assertion failed: self.universal_regions.is_universal_region(fr2)")
};assert!(self.universal_regions.is_universal_region(fr2));
76        self.inverse_outlives
77            .postdom_upper_bound(fr1, fr2)
78            .unwrap_or(self.universal_regions.fr_static)
79    }
80
81    /// Finds an "upper bound" for `fr` that is not local. In other
82    /// words, returns the smallest (*) known region `fr1` that (a)
83    /// outlives `fr` and (b) is not local.
84    ///
85    /// (*) If there are multiple competing choices, we return all of them.
86    pub(crate) fn non_local_upper_bounds(&self, fr: RegionVid) -> Vec<RegionVid> {
87        {
    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/type_check/free_region_relations.rs:87",
                        "rustc_borrowck::type_check::free_region_relations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                        ::tracing_core::__macro_support::Option::Some(87u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                        ::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!("non_local_upper_bound(fr={0:?})",
                                                    fr) as &dyn Value))])
            });
    } else { ; }
};debug!("non_local_upper_bound(fr={:?})", fr);
88        let res = self.non_local_bounds(&self.inverse_outlives, fr);
89        if !!res.is_empty() {
    {
        ::core::panicking::panic_fmt(format_args!("can\'t find an upper bound!?"));
    }
};assert!(!res.is_empty(), "can't find an upper bound!?");
90        res
91    }
92
93    /// Finds a "lower bound" for `fr` that is not local. In other
94    /// words, returns the largest (*) known region `fr1` that (a) is
95    /// outlived by `fr` and (b) is not local.
96    ///
97    /// (*) If there are multiple competing choices, we return all of them.
98    pub(crate) fn non_local_lower_bounds(&self, fr: RegionVid) -> Vec<RegionVid> {
99        {
    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/type_check/free_region_relations.rs:99",
                        "rustc_borrowck::type_check::free_region_relations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                        ::tracing_core::__macro_support::Option::Some(99u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                        ::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!("non_local_lower_bound(fr={0:?})",
                                                    fr) as &dyn Value))])
            });
    } else { ; }
};debug!("non_local_lower_bound(fr={:?})", fr);
100        self.non_local_bounds(&self.outlives, fr)
101    }
102
103    /// Helper for `non_local_upper_bounds` and `non_local_lower_bounds`.
104    /// Repeatedly invokes `postdom_parent` until we find something that is not
105    /// local. Returns `None` if we never do so.
106    fn non_local_bounds(
107        &self,
108        relation: &TransitiveRelation<RegionVid>,
109        fr0: RegionVid,
110    ) -> Vec<RegionVid> {
111        // This method assumes that `fr0` is one of the universally
112        // quantified region variables.
113        if !self.universal_regions.is_universal_region(fr0) {
    ::core::panicking::panic("assertion failed: self.universal_regions.is_universal_region(fr0)")
};assert!(self.universal_regions.is_universal_region(fr0));
114
115        let mut external_parents = ::alloc::vec::Vec::new()vec![];
116
117        let mut queue = ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [relation.minimal_scc_representative(fr0)]))vec![relation.minimal_scc_representative(fr0)];
118
119        // Keep expanding `fr` into its parents until we reach
120        // non-local regions.
121        while let Some(fr) = queue.pop() {
122            if !self.universal_regions.is_local_free_region(fr) {
123                external_parents.push(fr);
124                continue;
125            }
126
127            queue.extend(relation.parents(fr));
128        }
129
130        {
    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/type_check/free_region_relations.rs:130",
                        "rustc_borrowck::type_check::free_region_relations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                        ::tracing_core::__macro_support::Option::Some(130u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                        ::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!("non_local_bound: external_parents={0:?}",
                                                    external_parents) as &dyn Value))])
            });
    } else { ; }
};debug!("non_local_bound: external_parents={:?}", external_parents);
131
132        external_parents
133    }
134
135    /// Returns `true` if fr1 is known to outlive fr2.
136    ///
137    /// This will only ever be true for universally quantified regions.
138    pub(crate) fn outlives(&self, fr1: RegionVid, fr2: RegionVid) -> bool {
139        self.outlives.contains(fr1, fr2)
140    }
141
142    /// Returns `true` if fr1 is known to equal fr2.
143    ///
144    /// This will only ever be true for universally quantified regions.
145    pub(crate) fn equal(&self, fr1: RegionVid, fr2: RegionVid) -> bool {
146        self.outlives.contains(fr1, fr2) && self.outlives.contains(fr2, fr1)
147    }
148
149    /// Returns a vector of free regions `x` such that `fr1: x` is
150    /// known to hold.
151    pub(crate) fn regions_outlived_by(&self, fr1: RegionVid) -> Vec<RegionVid> {
152        self.outlives.reachable_from(fr1)
153    }
154
155    /// Returns the _non-transitive_ set of known `outlives` constraints between free regions.
156    pub(crate) fn known_outlives(&self) -> impl Iterator<Item = (RegionVid, RegionVid)> {
157        self.outlives.base_edges()
158    }
159}
160
161struct UniversalRegionRelationsBuilder<'a, 'tcx> {
162    infcx: &'a BorrowckInferCtxt<'tcx>,
163    universal_regions: UniversalRegions<'tcx>,
164    constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
165
166    // outputs:
167    outlives: TransitiveRelationBuilder<RegionVid>,
168    inverse_outlives: TransitiveRelationBuilder<RegionVid>,
169    region_bound_pairs: RegionBoundPairs<'tcx>,
170}
171
172impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
173    /// Records in the `outlives_relation` (and
174    /// `inverse_outlives_relation`) that `fr_a: fr_b`.
175    fn relate_universal_regions(&mut self, fr_a: RegionVid, fr_b: RegionVid) {
176        {
    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/type_check/free_region_relations.rs:176",
                        "rustc_borrowck::type_check::free_region_relations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                        ::tracing_core::__macro_support::Option::Some(176u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                        ::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!("relate_universal_regions: fr_a={0:?} outlives fr_b={1:?}",
                                                    fr_a, fr_b) as &dyn Value))])
            });
    } else { ; }
};debug!("relate_universal_regions: fr_a={:?} outlives fr_b={:?}", fr_a, fr_b);
177        self.outlives.add(fr_a, fr_b);
178        self.inverse_outlives.add(fr_b, fr_a);
179    }
180
181    #[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("create",
                                    "rustc_borrowck::type_check::free_region_relations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(181u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                                    ::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: CreateResult<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.infcx.tcx;
            let defining_ty_def_id =
                self.universal_regions.defining_ty.def_id().expect_local();
            let span = tcx.def_span(defining_ty_def_id);
            let param_env = self.infcx.param_env;
            self.add_outlives_bounds(outlives::explicit_outlives_bounds(param_env));
            let fr_static = self.universal_regions.fr_static;
            let fr_fn_body = self.universal_regions.fr_fn_body;
            for fr in self.universal_regions.universal_regions_iter() {
                {
                    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/type_check/free_region_relations.rs:199",
                                        "rustc_borrowck::type_check::free_region_relations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(199u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                                        ::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!("build: relating free region {0:?} to itself and to \'static",
                                                                    fr) as &dyn Value))])
                            });
                    } else { ; }
                };
                self.relate_universal_regions(fr, fr);
                self.relate_universal_regions(fr_static, fr);
                self.relate_universal_regions(fr, fr_fn_body);
            }
            let mut constraints = ::alloc::vec::Vec::new();
            let mut known_type_outlives_obligations =
                ::alloc::vec::Vec::new();
            for bound in param_env.caller_bounds() {
                if let Some(outlives) = bound.as_type_outlives_clause() {
                    self.normalize_and_push_type_outlives_obligation(outlives,
                        span, &mut known_type_outlives_obligations,
                        &mut constraints);
                };
            }
            let unnormalized_input_output_tys =
                self.universal_regions.unnormalized_input_tys.iter().cloned().chain(Some(self.universal_regions.unnormalized_output_ty));
            let mut normalized_inputs_and_output =
                Vec::with_capacity(self.universal_regions.unnormalized_input_tys.len()
                        + 1);
            for ty in unnormalized_input_output_tys {
                {
                    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/type_check/free_region_relations.rs:238",
                                        "rustc_borrowck::type_check::free_region_relations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(238u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                                        ::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!("build: input_or_output={0:?}",
                                                                    ty) as &dyn Value))])
                            });
                    } else { ; }
                };
                let constraints_unnorm = self.add_implied_bounds(ty, span);
                if let Some(c) = constraints_unnorm { constraints.push(c) }
                let TypeOpOutput {
                        output: norm_ty, constraints: constraints_normalize, .. } =
                    param_env.and(DeeplyNormalize {
                                    value: ty,
                                }).fully_perform(self.infcx, self.infcx.root_def_id,
                            span).unwrap_or_else(|guar|
                            TypeOpOutput {
                                output: Ty::new_error(self.infcx.tcx, guar),
                                constraints: None,
                                error_info: None,
                            });
                if let Some(c) = constraints_normalize { constraints.push(c) }
                if ty != norm_ty {
                    let constraints_norm =
                        self.add_implied_bounds(norm_ty, span);
                    if let Some(c) = constraints_norm { constraints.push(c) }
                }
                normalized_inputs_and_output.push(norm_ty);
            }
            if #[allow(non_exhaustive_omitted_patterns)] match tcx.def_kind(defining_ty_def_id)
                    {
                    DefKind::AssocFn | DefKind::AssocConst => true,
                    _ => false,
                } {
                for &(ty, _) in
                    tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) {
                    let result: Result<_, ErrorGuaranteed> =
                        param_env.and(DeeplyNormalize {
                                    value: ty,
                                }).fully_perform(self.infcx, self.infcx.root_def_id, span);
                    let Ok(TypeOpOutput { output: norm_ty, constraints: c, ..
                            }) = result else { continue; };
                    constraints.extend(c);
                    let c = self.add_implied_bounds(norm_ty, span);
                    constraints.extend(c);
                }
            }
            for c in constraints {
                constraint_conversion::ConstraintConversion::new(self.infcx,
                        &self.universal_regions, &self.region_bound_pairs,
                        &known_type_outlives_obligations, Locations::All(span),
                        span, ConstraintCategory::Internal,
                        self.constraints).convert_all(c);
            }
            CreateResult {
                universal_region_relations: Frozen::freeze(UniversalRegionRelations {
                        universal_regions: self.universal_regions,
                        outlives: self.outlives.freeze(),
                        inverse_outlives: self.inverse_outlives.freeze(),
                    }),
                known_type_outlives_obligations: Frozen::freeze(known_type_outlives_obligations),
                region_bound_pairs: Frozen::freeze(self.region_bound_pairs),
                normalized_inputs_and_output,
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
182    pub(crate) fn create(mut self) -> CreateResult<'tcx> {
183        let tcx = self.infcx.tcx;
184        let defining_ty_def_id = self.universal_regions.defining_ty.def_id().expect_local();
185        let span = tcx.def_span(defining_ty_def_id);
186
187        // Insert the `'a: 'b` we know from the predicates.
188        // This does not consider the type-outlives.
189        let param_env = self.infcx.param_env;
190        self.add_outlives_bounds(outlives::explicit_outlives_bounds(param_env));
191
192        // - outlives is reflexive, so `'r: 'r` for every region `'r`
193        // - `'static: 'r` for every region `'r`
194        // - `'r: 'fn_body` for every (other) universally quantified
195        //   region `'r`, all of which are provided by our caller
196        let fr_static = self.universal_regions.fr_static;
197        let fr_fn_body = self.universal_regions.fr_fn_body;
198        for fr in self.universal_regions.universal_regions_iter() {
199            debug!("build: relating free region {:?} to itself and to 'static", fr);
200            self.relate_universal_regions(fr, fr);
201            self.relate_universal_regions(fr_static, fr);
202            self.relate_universal_regions(fr, fr_fn_body);
203        }
204
205        // Normalize the assumptions we use to borrowck the program.
206        let mut constraints = vec![];
207        let mut known_type_outlives_obligations = vec![];
208        for bound in param_env.caller_bounds() {
209            if let Some(outlives) = bound.as_type_outlives_clause() {
210                self.normalize_and_push_type_outlives_obligation(
211                    outlives,
212                    span,
213                    &mut known_type_outlives_obligations,
214                    &mut constraints,
215                );
216            };
217        }
218
219        let unnormalized_input_output_tys = self
220            .universal_regions
221            .unnormalized_input_tys
222            .iter()
223            .cloned()
224            .chain(Some(self.universal_regions.unnormalized_output_ty));
225
226        // For each of the input/output types:
227        // - Normalize the type. This will create some region
228        //   constraints, which we buffer up because we are
229        //   not ready to process them yet.
230        // - Then compute the implied bounds. This will adjust
231        //   the `region_bound_pairs` and so forth.
232        // - After this is done, we'll register the constraints in
233        //   the `BorrowckInferCtxt`. Checking these constraints is
234        //   handled later by actual borrow checking.
235        let mut normalized_inputs_and_output =
236            Vec::with_capacity(self.universal_regions.unnormalized_input_tys.len() + 1);
237        for ty in unnormalized_input_output_tys {
238            debug!("build: input_or_output={:?}", ty);
239            // We add implied bounds from both the unnormalized and normalized ty.
240            // See issue #87748
241            let constraints_unnorm = self.add_implied_bounds(ty, span);
242            if let Some(c) = constraints_unnorm {
243                constraints.push(c)
244            }
245            let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } =
246                param_env
247                    .and(DeeplyNormalize { value: ty })
248                    .fully_perform(self.infcx, self.infcx.root_def_id, span)
249                    .unwrap_or_else(|guar| TypeOpOutput {
250                        output: Ty::new_error(self.infcx.tcx, guar),
251                        constraints: None,
252                        error_info: None,
253                    });
254            if let Some(c) = constraints_normalize {
255                constraints.push(c)
256            }
257
258            // Currently `implied_outlives_bounds` will normalize the provided
259            // `Ty`, despite this it's still important to normalize the ty ourselves
260            // as normalization may introduce new region variables (#136547).
261            //
262            // If we do not add implied bounds for the type involving these new
263            // region variables then we'll wind up with the normalized form of
264            // the signature having not-wf types due to unsatisfied region
265            // constraints.
266            //
267            // Note: we need this in examples like
268            // ```
269            // trait Foo {
270            //   type Bar;
271            //   fn foo(&self) -> &Self::Bar;
272            // }
273            // impl Foo for () {
274            //   type Bar = ();
275            //   fn foo(&self) -> &() {}
276            // }
277            // ```
278            // Both &Self::Bar and &() are WF
279            if ty != norm_ty {
280                let constraints_norm = self.add_implied_bounds(norm_ty, span);
281                if let Some(c) = constraints_norm {
282                    constraints.push(c)
283                }
284            }
285
286            normalized_inputs_and_output.push(norm_ty);
287        }
288
289        // Add implied bounds from impl header.
290        //
291        // We don't use `assumed_wf_types` to source the entire set of implied bounds for
292        // a few reasons:
293        // - `DefiningTy` for closure has the `&'env Self` type while `assumed_wf_types` doesn't
294        // - We compute implied bounds from the unnormalized types in the `DefiningTy` but do not
295        //   do so for types in impl headers
296        // - We must compute the normalized signature and then compute implied bounds from that
297        //   in order to connect any unconstrained region vars created during normalization to
298        //   the types of the locals corresponding to the inputs and outputs of the item. (#136547)
299        if matches!(tcx.def_kind(defining_ty_def_id), DefKind::AssocFn | DefKind::AssocConst) {
300            for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) {
301                let result: Result<_, ErrorGuaranteed> = param_env
302                    .and(DeeplyNormalize { value: ty })
303                    .fully_perform(self.infcx, self.infcx.root_def_id, span);
304                let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else {
305                    continue;
306                };
307
308                constraints.extend(c);
309
310                // We currently add implied bounds from the normalized ty only.
311                // This is more conservative and matches wfcheck behavior.
312                let c = self.add_implied_bounds(norm_ty, span);
313                constraints.extend(c);
314            }
315        }
316
317        for c in constraints {
318            constraint_conversion::ConstraintConversion::new(
319                self.infcx,
320                &self.universal_regions,
321                &self.region_bound_pairs,
322                &known_type_outlives_obligations,
323                Locations::All(span),
324                span,
325                ConstraintCategory::Internal,
326                self.constraints,
327            )
328            .convert_all(c);
329        }
330
331        CreateResult {
332            universal_region_relations: Frozen::freeze(UniversalRegionRelations {
333                universal_regions: self.universal_regions,
334                outlives: self.outlives.freeze(),
335                inverse_outlives: self.inverse_outlives.freeze(),
336            }),
337            known_type_outlives_obligations: Frozen::freeze(known_type_outlives_obligations),
338            region_bound_pairs: Frozen::freeze(self.region_bound_pairs),
339            normalized_inputs_and_output,
340        }
341    }
342
343    fn normalize_and_push_type_outlives_obligation(
344        &self,
345        mut outlives: ty::PolyTypeOutlivesPredicate<'tcx>,
346        span: Span,
347        known_type_outlives_obligations: &mut Vec<ty::PolyTypeOutlivesPredicate<'tcx>>,
348        constraints: &mut Vec<&QueryRegionConstraints<'tcx>>,
349    ) {
350        // In the new solver, normalize the type-outlives obligation assumptions.
351        if self.infcx.next_trait_solver() {
352            let Ok(TypeOpOutput {
353                output: normalized_outlives,
354                constraints: constraints_normalize,
355                error_info: _,
356            }) = self.infcx.param_env.and(DeeplyNormalize { value: outlives }).fully_perform(
357                self.infcx,
358                self.infcx.root_def_id,
359                span,
360            )
361            else {
362                self.infcx.dcx().delayed_bug(::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("could not normalize {0:?}",
                outlives))
    })format!("could not normalize {outlives:?}"));
363                return;
364            };
365            outlives = normalized_outlives;
366            if let Some(c) = constraints_normalize {
367                constraints.push(c);
368            }
369        }
370
371        known_type_outlives_obligations.push(outlives);
372    }
373
374    /// Compute and add any implied bounds that come from a given type.
375    #[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("add_implied_bounds",
                                    "rustc_borrowck::type_check::free_region_relations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(375u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                                    ::tracing_core::field::FieldSet::new(&["ty", "span"],
                                        ::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(&ty)
                                                            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(&span)
                                                            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:
                    Option<&'tcx QueryRegionConstraints<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let TypeOpOutput { output: bounds, constraints, .. } =
                self.infcx.param_env.and(type_op::ImpliedOutlivesBounds {
                                        ty,
                                    }).fully_perform(self.infcx, self.infcx.root_def_id,
                                span).map_err(|_: ErrorGuaranteed|
                                {
                                    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/type_check/free_region_relations.rs:386",
                                                        "rustc_borrowck::type_check::free_region_relations",
                                                        ::tracing::Level::DEBUG,
                                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                                                        ::tracing_core::__macro_support::Option::Some(386u32),
                                                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                                                        ::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!("failed to compute implied bounds {0:?}",
                                                                                    ty) as &dyn Value))])
                                            });
                                    } else { ; }
                                }).ok()?;
            {
                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/type_check/free_region_relations.rs:388",
                                    "rustc_borrowck::type_check::free_region_relations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(388u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                                    ::tracing_core::field::FieldSet::new(&["bounds",
                                                    "constraints"],
                                        ::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(&bounds) as
                                                        &dyn Value)),
                                            (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&constraints)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            let bounds =
                bounds.into_iter().filter(|bound| !bound.has_placeholders());
            self.add_outlives_bounds(bounds);
            constraints
        }
    }
}#[instrument(level = "debug", skip(self))]
376    fn add_implied_bounds(
377        &mut self,
378        ty: Ty<'tcx>,
379        span: Span,
380    ) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
381        let TypeOpOutput { output: bounds, constraints, .. } = self
382            .infcx
383            .param_env
384            .and(type_op::ImpliedOutlivesBounds { ty })
385            .fully_perform(self.infcx, self.infcx.root_def_id, span)
386            .map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
387            .ok()?;
388        debug!(?bounds, ?constraints);
389        // Because of #109628, we may have unexpected placeholders. Ignore them!
390        // FIXME(#109628): panic in this case once the issue is fixed.
391        let bounds = bounds.into_iter().filter(|bound| !bound.has_placeholders());
392        self.add_outlives_bounds(bounds);
393        constraints
394    }
395
396    /// Registers the `OutlivesBound` items from `outlives_bounds` in
397    /// the outlives relation as well as the region-bound pairs
398    /// listing.
399    fn add_outlives_bounds<I>(&mut self, outlives_bounds: I)
400    where
401        I: IntoIterator<Item = OutlivesBound<'tcx>>,
402    {
403        for outlives_bound in outlives_bounds {
404            {
    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/type_check/free_region_relations.rs:404",
                        "rustc_borrowck::type_check::free_region_relations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_borrowck/src/type_check/free_region_relations.rs"),
                        ::tracing_core::__macro_support::Option::Some(404u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_borrowck::type_check::free_region_relations"),
                        ::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!("add_outlives_bounds(bound={0:?})",
                                                    outlives_bound) as &dyn Value))])
            });
    } else { ; }
};debug!("add_outlives_bounds(bound={:?})", outlives_bound);
405
406            match outlives_bound {
407                OutlivesBound::RegionSubRegion(r1, r2) => {
408                    // The bound says that `r1 <= r2`; we store `r2: r1`.
409                    let r1 = self.universal_regions.to_region_vid(r1);
410                    let r2 = self.universal_regions.to_region_vid(r2);
411                    self.relate_universal_regions(r2, r1);
412                }
413
414                OutlivesBound::RegionSubParam(r_a, param_b) => {
415                    self.region_bound_pairs
416                        .insert(ty::OutlivesPredicate(GenericKind::Param(param_b), r_a));
417                }
418
419                OutlivesBound::RegionSubAlias(r_a, alias_b) => {
420                    self.region_bound_pairs
421                        .insert(ty::OutlivesPredicate(GenericKind::Alias(alias_b), r_a));
422                }
423            }
424        }
425    }
426}