Skip to main content

rustc_infer/infer/relate/
generalize.rs

1use std::mem;
2
3use rustc_data_structures::sso::SsoHashMap;
4use rustc_hir::def_id::DefId;
5use rustc_middle::ty::error::TypeError;
6use rustc_middle::ty::{self, InferConst, Term, Ty, TyCtxt, TypeVisitableExt};
7use rustc_span::{Span, bug};
8use tracing::{debug, instrument, warn};
9
10use super::{PredicateEmittingRelation, Relate, RelateResult, TypeRelation};
11use crate::infer::type_variable::TypeVariableValue;
12use crate::infer::unify_key::ConstVariableValue;
13use crate::infer::{InferCtxt, RegionVariableOrigin, relate};
14
15#[derive(#[automatically_derived]
impl ::core::marker::Copy for TermVid { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for TermVid { }
#[automatically_derived]
impl ::core::clone::Clone for TermVid {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<ty::TyVid>;
        let _: ::core::clone::AssertParamIsClone<ty::ConstVid>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::Eq for TermVid {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<ty::TyVid>;
        let _: ::core::cmp::AssertParamIsEq<ty::ConstVid>;
    }
}Eq, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for TermVid { }
#[automatically_derived]
impl ::core::cmp::PartialEq for TermVid {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Ty(__self_0), Self::Ty(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Const(__self_0), Self::Const(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for TermVid {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Ty(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
                    &__self_0),
            Self::Const(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
                    &__self_0),
        }
    }
}Debug)]
16enum TermVid {
17    Ty(ty::TyVid),
18    Const(ty::ConstVid),
19}
20
21impl From<ty::TyVid> for TermVid {
22    fn from(value: ty::TyVid) -> Self {
23        TermVid::Ty(value)
24    }
25}
26
27impl From<ty::ConstVid> for TermVid {
28    fn from(value: ty::ConstVid) -> Self {
29        TermVid::Const(value)
30    }
31}
32
33impl<'tcx> InferCtxt<'tcx> {
34    /// The idea is that we should ensure that the type variable `target_vid`
35    /// is equal to, a subtype of, or a supertype of `source_ty`.
36    ///
37    /// For this, we will instantiate `target_vid` with a *generalized* version
38    /// of `source_ty`. Generalization introduces other inference variables wherever
39    /// subtyping could occur. This also does the occurs checks, detecting whether
40    /// instantiating `target_vid` would result in a cyclic type. We eagerly error
41    /// in this case.
42    ///
43    /// This is *not* expected to be used anywhere except for an implementation of
44    /// `TypeRelation`. Do not use this, and instead please use `At::eq`, for all
45    /// other usecases (i.e. setting the value of a type var).
46    {}
#[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("instantiate_ty_var",
                                    "rustc_infer::infer::relate::generalize",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                    ::tracing_core::__macro_support::Option::Some(46u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("target_is_expected")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("target_is_expected");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("target_vid")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("target_vid");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("instantiation_variance")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("instantiation_variance");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source_ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&target_is_expected
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target_vid)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instantiation_variance)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source_ty)
                                                            as &dyn ::tracing::field::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: RelateResult<'tcx, ()> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if true {
                if !self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown()
                    {
                    ::core::panicking::panic("assertion failed: self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown()")
                };
            };
            self.instantiate_var(relation, target_is_expected,
                target_vid.into(), instantiation_variance, source_ty.into())
        }
    }
}#[instrument(level = "debug", skip(self, relation))]
47    pub fn instantiate_ty_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
48        &self,
49        relation: &mut R,
50        target_is_expected: bool,
51        target_vid: ty::TyVid,
52        instantiation_variance: ty::Variance,
53        source_ty: Ty<'tcx>,
54    ) -> RelateResult<'tcx, ()> {
55        debug_assert!(self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown());
56
57        self.instantiate_var(
58            relation,
59            target_is_expected,
60            target_vid.into(),
61            instantiation_variance,
62            source_ty.into(),
63        )
64    }
65
66    /// Instantiates the const variable `target_vid` with the given constant.
67    ///
68    /// This also tests if the given const `ct` contains an inference variable which was previously
69    /// unioned with `target_vid`. If this is the case, inferring `target_vid` to `ct`
70    /// would result in an infinite type as we continuously replace an inference variable
71    /// in `ct` with `ct` itself.
72    ///
73    /// This is especially important as alias consts use their parents generics.
74    /// They therefore often contain unused args, making these errors far more likely.
75    ///
76    /// A good example of this is the following:
77    ///
78    /// ```compile_fail,E0308
79    /// #![feature(generic_const_exprs)]
80    ///
81    /// fn bind<const N: usize>(value: [u8; N]) -> [u8; 3 + 4] {
82    ///     todo!()
83    /// }
84    ///
85    /// fn main() {
86    ///     let mut arr = Default::default();
87    ///     arr = bind(arr);
88    /// }
89    /// ```
90    ///
91    /// Here `3 + 4` ends up as `ConstKind::Alias` which uses the generics
92    /// of `fn bind` (meaning that its args contain `N`).
93    ///
94    /// `bind(arr)` now infers that the type of `arr` must be `[u8; N]`.
95    /// The assignment `arr = bind(arr)` now tries to equate `N` with `3 + 4`.
96    ///
97    /// As `3 + 4` contains `N` in its args, this must not succeed.
98    ///
99    /// See `tests/ui/const-generics/occurs-check/` for more examples where this is relevant.
100    {}
#[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("instantiate_const_var",
                                    "rustc_infer::infer::relate::generalize",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                    ::tracing_core::__macro_support::Option::Some(100u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("target_is_expected")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("target_is_expected");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("target_vid")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("target_vid");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source_ct")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source_ct");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&target_is_expected
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target_vid)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source_ct)
                                                            as &dyn ::tracing::field::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: RelateResult<'tcx, ()> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if true {
                if !self.inner.borrow_mut().const_unification_table().probe_value(target_vid).is_unknown()
                    {
                    ::core::panicking::panic("assertion failed: self.inner.borrow_mut().const_unification_table().probe_value(target_vid).is_unknown()")
                };
            };
            self.instantiate_var(relation, target_is_expected,
                target_vid.into(), ty::Invariant, source_ct.into())
        }
    }
}#[instrument(level = "debug", skip(self, relation))]
101    pub(crate) fn instantiate_const_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
102        &self,
103        relation: &mut R,
104        target_is_expected: bool,
105        target_vid: ty::ConstVid,
106        source_ct: ty::Const<'tcx>,
107    ) -> RelateResult<'tcx, ()> {
108        // FIXME(generic_const_exprs): Occurs check failures for alias consts
109        // and generic expressions are not yet handled correctly.
110        debug_assert!(
111            self.inner.borrow_mut().const_unification_table().probe_value(target_vid).is_unknown()
112        );
113
114        self.instantiate_var(
115            relation,
116            target_is_expected,
117            target_vid.into(),
118            ty::Invariant,
119            source_ct.into(),
120        )
121    }
122
123    {}
#[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("instantiate_var",
                                    "rustc_infer::infer::relate::generalize",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                    ::tracing_core::__macro_support::Option::Some(123u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("target_is_expected")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("target_is_expected");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("target_vid")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("target_vid");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("instantiation_variance")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("instantiation_variance");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source_term")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source_term");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&target_is_expected
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target_vid)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instantiation_variance)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source_term)
                                                            as &dyn ::tracing::field::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: RelateResult<'tcx, ()> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let Generalization { value_may_be_infer: generalized_term } =
                self.generalize(relation.span(), target_vid,
                        instantiation_variance, source_term)?;
            self.union_var_term(target_vid, generalized_term);
            if generalized_term.is_infer() {
                let Some(source_alias) =
                    source_term.to_alias_term() else {
                        ::rustc_span::macros::bug_impl(None,
                            format_args!("generalized `{0:?} to infer, not an alias",
                                source_term), Location::caller());
                    };
                if !!self.next_trait_solver() {
                    {
                        ::core::panicking::panic_fmt(format_args!("nonrigid aliases should be handled in relations, not here"));
                    }
                };
                match source_alias.kind {
                    ty::AliasTermKind::ProjectionTy { .. } |
                        ty::AliasTermKind::ProjectionConst { .. } => {
                        relation.register_predicates([ty::ProjectionClause {
                                        projection_term: source_alias,
                                        term: generalized_term,
                                    }]);
                    }
                    ty::AliasTermKind::InherentTy { .. } |
                        ty::AliasTermKind::FreeTy { .. } |
                        ty::AliasTermKind::OpaqueTy { .. } => {
                        return Err(TypeError::CyclicTy(source_term.expect_type()));
                    }
                    ty::AliasTermKind::InherentConstSelf { .. } |
                        ty::AliasTermKind::InherentConstImpl { .. } |
                        ty::AliasTermKind::FreeConst { .. } |
                        ty::AliasTermKind::AnonConst { .. } => {
                        return Err(TypeError::CyclicConst(source_term.expect_const()));
                    }
                }
            } else {
                match generalized_term.kind() {
                    ty::TermKind::Ty(_) => {
                        if target_is_expected {
                            relation.relate(generalized_term, source_term)?;
                        } else {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:214",
                                                    "rustc_infer::infer::relate::generalize",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(214u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                                    ::tracing_core::field::FieldSet::new(&["message"],
                                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                    ::tracing::metadata::Kind::EVENT)
                                            };
                                        ::tracing::callsite::DefaultCallsite::new(&META)
                                    };
                                let enabled =
                                    ::tracing::Level::DEBUG <=
                                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                            ::tracing::Level::DEBUG <=
                                                ::tracing::level_filters::LevelFilter::current() &&
                                        {
                                            let interest = __CALLSITE.interest();
                                            !interest.is_never() &&
                                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                    interest)
                                        };
                                if enabled {
                                    (|value_set: ::tracing::field::ValueSet|
                                                {
                                                    let meta = __CALLSITE.metadata();
                                                    ::tracing::Event::dispatch(meta, &value_set);
                                                    ;
                                                })({
                                            #[allow(unused_imports)]
                                            use ::tracing::field::{debug, display, Value};
                                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("flip relation")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            relation.relate(source_term, generalized_term)?;
                        }
                    }
                    ty::TermKind::Const(_) => {
                        if target_is_expected {
                            relation.relate_with_variance(ty::Invariant,
                                    ty::VarianceDiagInfo::default(), generalized_term,
                                    source_term)?;
                        } else {
                            relation.relate_with_variance(ty::Invariant,
                                    ty::VarianceDiagInfo::default(), source_term,
                                    generalized_term)?;
                        }
                    }
                }
            }
            Ok(())
        }
    }
}#[instrument(level = "debug", skip(self, relation))]
124    fn instantiate_var<R: PredicateEmittingRelation<Self>>(
125        &self,
126        relation: &mut R,
127        target_is_expected: bool,
128        target_vid: TermVid,
129        instantiation_variance: ty::Variance,
130        source_term: Term<'tcx>,
131    ) -> RelateResult<'tcx, ()> {
132        // Generalize `source_term` depending on the current variance. As an example, assume
133        // `?target <: &'x ?1`, where `'x` is some free region and `?1` is an inference
134        // variable.
135        //
136        // Then the `generalized_term` would be `&'?2 ?3`, where `'?2` and `?3` are fresh
137        // region/type inference variables.
138        //
139        // We then relate `generalized_term <: source_term`, adding constraints like `'x: '?2` and
140        // `?1 <: ?3`.
141        let Generalization { value_may_be_infer: generalized_term } =
142            self.generalize(relation.span(), target_vid, instantiation_variance, source_term)?;
143
144        // Constrain `b_vid` to the generalized type `generalized_term`.
145        self.union_var_term(target_vid, generalized_term);
146
147        // Finally, relate `generalized_term` to `source_term`, as described in previous comment.
148        //
149        // FIXME(#16847): This code is non-ideal because all these subtype
150        // relations wind up attributed to the same spans. We need
151        // to associate causes/spans with each of the relations in
152        // the stack to get this right.
153        if generalized_term.is_infer() {
154            // This happens for cases like `<?0 as Trait>::Assoc == ?0`.
155            // We can't instantiate `?0` here as that would result in a
156            // cyclic type. We instead delay the unification in case
157            // the alias can be normalized to something which does not
158            // mention `?0`.
159            let Some(source_alias) = source_term.to_alias_term() else {
160                bug!("generalized `{source_term:?} to infer, not an alias");
161            };
162            assert!(
163                !self.next_trait_solver(),
164                "nonrigid aliases should be handled in relations, not here"
165            );
166            match source_alias.kind {
167                ty::AliasTermKind::ProjectionTy { .. }
168                | ty::AliasTermKind::ProjectionConst { .. } => {
169                    // FIXME: This does not handle subtyping correctly, we could
170                    // instead create a new inference variable `?normalized_source`, emitting
171                    // `Projection(normalized_source, ?ty_normalized)` and
172                    // `?normalized_source <: generalized_term`.
173                    relation.register_predicates([ty::ProjectionClause {
174                        projection_term: source_alias,
175                        term: generalized_term,
176                    }]);
177                }
178                // The old solver only accepts projection predicates for associated types.
179                ty::AliasTermKind::InherentTy { .. }
180                | ty::AliasTermKind::FreeTy { .. }
181                | ty::AliasTermKind::OpaqueTy { .. } => {
182                    return Err(TypeError::CyclicTy(source_term.expect_type()));
183                }
184                ty::AliasTermKind::InherentConstSelf { .. }
185                | ty::AliasTermKind::InherentConstImpl { .. }
186                | ty::AliasTermKind::FreeConst { .. }
187                | ty::AliasTermKind::AnonConst { .. } => {
188                    return Err(TypeError::CyclicConst(source_term.expect_const()));
189                }
190            }
191        } else {
192            // NOTE: The `instantiation_variance` is not the same variance as
193            // used by the relation. When instantiating `b`, `target_is_expected`
194            // is flipped and the `instantiation_variance` is also flipped. To
195            // constrain the `generalized_term` while using the original relation,
196            // we therefore only have to flip the arguments.
197            //
198            // ```ignore (not code)
199            // ?a rel B
200            // instantiate_ty_var(?a, B) # expected and variance not flipped
201            // B' rel B
202            // ```
203            // or
204            // ```ignore (not code)
205            // A rel ?b
206            // instantiate_ty_var(?b, A) # expected and variance flipped
207            // A rel A'
208            // ```
209            match generalized_term.kind() {
210                ty::TermKind::Ty(_) => {
211                    if target_is_expected {
212                        relation.relate(generalized_term, source_term)?;
213                    } else {
214                        debug!("flip relation");
215                        relation.relate(source_term, generalized_term)?;
216                    }
217                }
218                ty::TermKind::Const(_) => {
219                    // Override consts to always be invariant
220                    if target_is_expected {
221                        relation.relate_with_variance(
222                            ty::Invariant,
223                            ty::VarianceDiagInfo::default(),
224                            generalized_term,
225                            source_term,
226                        )?;
227                    } else {
228                        relation.relate_with_variance(
229                            ty::Invariant,
230                            ty::VarianceDiagInfo::default(),
231                            source_term,
232                            generalized_term,
233                        )?;
234                    }
235                }
236            }
237        }
238
239        Ok(())
240    }
241
242    /// This is a thin wrapper around inserting into the var tables. You probably want
243    /// [`Self::instantiate_var`] instead, which calls this method.
244    fn union_var_term(&self, l: TermVid, r: ty::Term<'tcx>) {
245        match (l, r.kind()) {
246            (TermVid::Ty(l), ty::TermKind::Ty(r)) => {
247                if let Some(r) = r.ty_vid() {
248                    self.inner.borrow_mut().type_variables().equate(l, r)
249                } else {
250                    // Ideally, we put this assert into `type_variables().instantiate()`.
251                    // But we can't pass the infcx into it as the infcx is already
252                    // mutably borrowed.
253                    if true {
    if !self.try_resolve_ty_var(l).unwrap_err().can_name(ty::max_universe(self,
                    r)) {
        ::core::panicking::panic("assertion failed: self.try_resolve_ty_var(l).unwrap_err().can_name(ty::max_universe(self, r))")
    };
};debug_assert!(
254                        self.try_resolve_ty_var(l).unwrap_err().can_name(ty::max_universe(self, r))
255                    );
256                    self.inner.borrow_mut().type_variables().instantiate(l, r)
257                }
258            }
259            (TermVid::Const(l), ty::TermKind::Const(r)) => {
260                if let Some(r) = r.ct_vid() {
261                    self.inner.borrow_mut().const_unification_table().union(l, r)
262                } else {
263                    if true {
    if !self.try_resolve_const_var(l).unwrap_err().can_name(ty::max_universe(self,
                    r)) {
        ::core::panicking::panic("assertion failed: self.try_resolve_const_var(l).unwrap_err().can_name(ty::max_universe(self, r))")
    };
};debug_assert!(
264                        self.try_resolve_const_var(l)
265                            .unwrap_err()
266                            .can_name(ty::max_universe(self, r))
267                    );
268                    self.inner
269                        .borrow_mut()
270                        .const_unification_table()
271                        .union_value(l, ConstVariableValue::Known { value: r })
272                }
273            }
274            _ => ::rustc_span::macros::bug_impl(None,
    format_args!("mismatched term kinds in generalize: {0:?}, {1:?}", l, r),
    Location::caller())bug!("mismatched term kinds in generalize: {l:?}, {r:?}"),
275        }
276    }
277
278    /// Attempts to generalize `source_term` for the type variable `target_vid`.
279    /// This checks for cycles -- that is, whether `source_term` references `target_vid`.
280    fn generalize(
281        &self,
282        span: Span,
283        target_vid: TermVid,
284        ambient_variance: ty::Variance,
285        source_term: Term<'tcx>,
286    ) -> RelateResult<'tcx, Generalization<Term<'tcx>>> {
287        if !!source_term.has_escaping_bound_vars() {
    ::core::panicking::panic("assertion failed: !source_term.has_escaping_bound_vars()")
};assert!(!source_term.has_escaping_bound_vars());
288        let (for_universe, root_vid) = match target_vid {
289            TermVid::Ty(ty_vid) => {
290                (self.try_resolve_ty_var(ty_vid).unwrap_err(), TermVid::Ty(self.root_var(ty_vid)))
291            }
292            TermVid::Const(ct_vid) => (
293                self.try_resolve_const_var(ct_vid).unwrap_err(),
294                TermVid::Const(self.inner.borrow_mut().const_unification_table().find(ct_vid).vid),
295            ),
296        };
297
298        let mut generalizer = Generalizer {
299            infcx: self,
300            span,
301            root_vid,
302            for_universe,
303            root_term: source_term,
304            ambient_variance,
305            in_alias: false,
306            cache: Default::default(),
307        };
308
309        let value_may_be_infer = generalizer.relate(source_term, source_term)?;
310        Ok(Generalization { value_may_be_infer })
311    }
312}
313
314/// The "generalizer" is used when handling inference variables.
315///
316/// The basic strategy for handling a constraint like `?A <: B` is to
317/// apply a "generalization strategy" to the term `B` -- this replaces
318/// all the lifetimes in the term `B` with fresh inference variables.
319/// (You can read more about the strategy in this [blog post].)
320///
321/// As an example, if we had `?A <: &'x u32`, we would generalize `&'x
322/// u32` to `&'0 u32` where `'0` is a fresh variable. This becomes the
323/// value of `A`. Finally, we relate `&'0 u32 <: &'x u32`, which
324/// establishes `'0: 'x` as a constraint.
325///
326/// [blog post]: https://is.gd/0hKvIr
327struct Generalizer<'me, 'tcx> {
328    infcx: &'me InferCtxt<'tcx>,
329
330    span: Span,
331
332    /// The vid of the type variable that is in the process of being
333    /// instantiated. If we find this within the value we are folding,
334    /// that means we would have created a cyclic value.
335    root_vid: TermVid,
336
337    /// The universe of the type variable that is in the process of being
338    /// instantiated. If we find anything that this universe cannot name,
339    /// we reject the relation.
340    for_universe: ty::UniverseIndex,
341
342    /// The root term (const or type) we're generalizing. Used for cycle errors.
343    root_term: Term<'tcx>,
344
345    /// After we generalize this type, we are going to relate it to
346    /// some other type. What will be the variance at this point?
347    ambient_variance: ty::Variance,
348
349    /// This is set once we're generalizing the arguments of an alias.
350    ///
351    /// This is necessary to correctly handle
352    /// `<T as Bar<<?0 as Foo>::Assoc>::Assoc == ?0`. This equality can
353    /// hold by either normalizing the outer or the inner associated type.
354    in_alias: bool,
355
356    cache: SsoHashMap<(Ty<'tcx>, ty::Variance, bool), Ty<'tcx>>,
357}
358
359impl<'tcx> Generalizer<'_, 'tcx> {
360    /// Create an error that corresponds to the term kind in `root_term`
361    fn cyclic_term_error(&self) -> TypeError<'tcx> {
362        match self.root_term.kind() {
363            ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty),
364            ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
365        }
366    }
367
368    /// Create a new type variable in the universe of the target when
369    /// generalizing an alias.
370    fn next_var_for_alias_of_kind(&self, alias: ty::AliasTerm<'tcx>) -> ty::Term<'tcx> {
371        if alias.kind.is_type() {
372            self.infcx.next_ty_var_in_universe(self.span, self.for_universe).into()
373        } else {
374            self.infcx.next_const_var_in_universe(self.span, self.for_universe).into()
375        }
376    }
377
378    /// We only handle potentially normalizable aliases via this method. For rigid alias,
379    /// we always generalize structurally.
380    ///
381    /// An occurs check failure inside of an alias does not mean
382    /// that the types definitely don't unify. We may be able
383    /// to normalize the alias after all.
384    ///
385    /// We handle this by lazily equating the normalizable alias
386    /// and generalizing it to an inference variable. In the new solver,
387    /// we always generalize to an infer var unless the alias contains escaping
388    /// bound variables.
389    ///
390    /// Correctly handling aliases with escaping bound variables is
391    /// difficult and currently incomplete in two opposite ways:
392    /// - if we get an occurs check failure in the alias, replace it with a new infer var.
393    ///   This causes us to later emit an alias-relate goal and is incomplete in case the
394    ///   alias normalizes to type containing one of the bound variables.
395    /// - if the alias contains an inference variable not nameable by `for_universe`, we
396    ///   continue generalizing the alias. This ends up pulling down the universe of the
397    ///   inference variable and is incomplete in case the alias would normalize to a type
398    ///   which does not mention that inference variable.
399    fn generalize_alias_term(
400        &mut self,
401        alias: ty::AliasTerm<'tcx>,
402    ) -> Result<Term<'tcx>, TypeError<'tcx>> {
403        // We do not eagerly replace aliases with inference variables if they have
404        // escaping bound vars, see the method comment for details. However, when we
405        // are inside of an alias with escaping bound vars replacing nested aliases
406        // with inference variables can cause incorrect ambiguity.
407        //
408        // cc trait-system-refactor-initiative#110
409        if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() && !self.in_alias {
410            return Ok(self.next_var_for_alias_of_kind(alias));
411        }
412
413        let is_nested_alias = mem::replace(&mut self.in_alias, true);
414        let result = match self.relate(alias, alias) {
415            Ok(alias) => Ok(alias.to_term(self.cx(), ty::IsRigid::No)),
416            Err(e) => {
417                if is_nested_alias {
418                    return Err(e);
419                } else {
420                    let alias_max_universe = ty::max_universe_of_placeholders(self.infcx, alias);
421                    let infer_replacement_is_complete =
422                        self.for_universe.can_name(alias_max_universe)
423                            && !alias.has_escaping_bound_vars();
424                    if !infer_replacement_is_complete {
425                        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:425",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::WARN,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(425u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::WARN <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::WARN <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("may incompletely handle alias type: {0:?}",
                                                    alias) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};warn!("may incompletely handle alias type: {alias:?}");
426                    }
427
428                    {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:428",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(428u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("generalization failure in alias")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("generalization failure in alias");
429                    Ok(self.next_var_for_alias_of_kind(alias))
430                }
431            }
432        };
433        self.in_alias = is_nested_alias;
434        result
435    }
436}
437
438impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
439    fn cx(&self) -> TyCtxt<'tcx> {
440        self.infcx.tcx
441    }
442
443    fn relate_ty_args(
444        &mut self,
445        a_ty: Ty<'tcx>,
446        _: Ty<'tcx>,
447        def_id: DefId,
448        a_args: ty::GenericArgsRef<'tcx>,
449        b_args: ty::GenericArgsRef<'tcx>,
450        mk: impl FnOnce(ty::GenericArgsRef<'tcx>) -> Ty<'tcx>,
451    ) -> RelateResult<'tcx, Ty<'tcx>> {
452        let args = if self.ambient_variance == ty::Invariant {
453            // Avoid fetching the variance if we are in an invariant
454            // context; no need, and it can induce dependency cycles
455            // (e.g., #41849).
456            relate::relate_args_invariantly(self, a_args, b_args)
457        } else {
458            let tcx = self.cx();
459            let variances = tcx.variances_of(def_id);
460            relate::relate_args_with_variances(self, variances, a_args, b_args)
461        }?;
462        if args == a_args { Ok(a_ty) } else { Ok(mk(args)) }
463    }
464
465    {}
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("relate_with_variance",
                                "rustc_infer::infer::relate::generalize",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(465u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("_info")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("_info");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("a")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("a");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&_info)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&a)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RelateResult<'tcx, T> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let old_ambient_variance = self.ambient_variance;
                        self.ambient_variance =
                            self.ambient_variance.xform(variance);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:475",
                                                "rustc_infer::infer::relate::generalize",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                ::tracing_core::__macro_support::Option::Some(475u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                                ::tracing_core::field::FieldSet::new(&["message",
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("self.ambient_variance")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("self.ambient_variance");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("new ambient variance")
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self.ambient_variance)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let r = self.relate(a, b);
                        self.ambient_variance = old_ambient_variance;
                        r
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:465",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(465u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, variance, b), ret)]
466    fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
467        &mut self,
468        variance: ty::Variance,
469        _info: ty::VarianceDiagInfo<TyCtxt<'tcx>>,
470        a: T,
471        b: T,
472    ) -> RelateResult<'tcx, T> {
473        let old_ambient_variance = self.ambient_variance;
474        self.ambient_variance = self.ambient_variance.xform(variance);
475        debug!(?self.ambient_variance, "new ambient variance");
476        // Recursive calls to `relate` can overflow the stack. For example a deeper version of
477        // `ui/associated-consts/issue-93775.rs`.
478        let r = self.relate(a, b);
479        self.ambient_variance = old_ambient_variance;
480        r
481    }
482
483    {}
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("tys",
                                "rustc_infer::infer::relate::generalize",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(483u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("t")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("t");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&t)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                RelateResult<'tcx, Ty<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        {
                            match (&t, &t2) {
                                (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);
                                    }
                                }
                            }
                        };
                        if let Some(&result) =
                                self.cache.get(&(t, self.ambient_variance, self.in_alias)) {
                            return Ok(result);
                        }
                        let g =
                            match *t.kind() {
                                    ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) |
                                        ty::FreshFloatTy(_)) => {
                                        ::rustc_span::macros::bug_impl(None,
                                            format_args!("unexpected infer type: {0}", t),
                                            Location::caller())
                                    }
                                    ty::Infer(ty::TyVar(vid)) => {
                                        let mut inner = self.infcx.inner.borrow_mut();
                                        let vid = inner.type_variables().root_var(vid);
                                        if TermVid::Ty(vid) == self.root_vid {
                                            Err(self.cyclic_term_error())
                                        } else {
                                            let probe = inner.type_variables().probe(vid);
                                            match probe {
                                                TypeVariableValue::Known { value: u } => {
                                                    drop(inner);
                                                    self.relate(u, u)
                                                }
                                                TypeVariableValue::Unknown { universe } => {
                                                    match self.ambient_variance {
                                                        ty::Invariant => {
                                                            if self.for_universe.can_name(universe) { return Ok(t); }
                                                        }
                                                        ty::Bivariant | ty::Covariant | ty::Contravariant => (),
                                                    }
                                                    let origin = inner.type_variables().var_origin(vid);
                                                    let new_var_id =
                                                        inner.type_variables().new_var(self.for_universe, origin);
                                                    inner.type_variables().sub_unify(vid, new_var_id);
                                                    if self.infcx.next_trait_solver() &&
                                                                !self.infcx.typing_mode_raw().is_coherence() &&
                                                            self.in_alias {
                                                        inner.type_variables().equate(vid, new_var_id);
                                                    }
                                                    {
                                                        use ::tracing::__macro_support::Callsite as _;
                                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                                            {
                                                                static META: ::tracing::Metadata<'static> =
                                                                    {
                                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:557",
                                                                            "rustc_infer::infer::relate::generalize",
                                                                            ::tracing::Level::DEBUG,
                                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                                            ::tracing_core::__macro_support::Option::Some(557u32),
                                                                            ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                                                            ::tracing_core::field::FieldSet::new(&["message"],
                                                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                                            ::tracing::metadata::Kind::EVENT)
                                                                    };
                                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                                            };
                                                        let enabled =
                                                            ::tracing::Level::DEBUG <=
                                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                                    ::tracing::Level::DEBUG <=
                                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                                {
                                                                    let interest = __CALLSITE.interest();
                                                                    !interest.is_never() &&
                                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                                            interest)
                                                                };
                                                        if enabled {
                                                            (|value_set: ::tracing::field::ValueSet|
                                                                        {
                                                                            let meta = __CALLSITE.metadata();
                                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                                            ;
                                                                        })({
                                                                    #[allow(unused_imports)]
                                                                    use ::tracing::field::{debug, display, Value};
                                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("replacing original vid={0:?} with new={1:?}",
                                                                                                        vid, new_var_id) as &dyn ::tracing::field::Value))])
                                                                });
                                                        } else { ; }
                                                    };
                                                    Ok(Ty::new_var(self.cx(), new_var_id))
                                                }
                                            }
                                        }
                                    }
                                    ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) => { Ok(t) }
                                    ty::Placeholder(placeholder) => {
                                        if self.for_universe.can_name(placeholder.universe) {
                                            Ok(t)
                                        } else {
                                            {
                                                use ::tracing::__macro_support::Callsite as _;
                                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                                    {
                                                        static META: ::tracing::Metadata<'static> =
                                                            {
                                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:575",
                                                                    "rustc_infer::infer::relate::generalize",
                                                                    ::tracing::Level::DEBUG,
                                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                                    ::tracing_core::__macro_support::Option::Some(575u32),
                                                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                                                    ::tracing_core::field::FieldSet::new(&["message"],
                                                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                                    ::tracing::metadata::Kind::EVENT)
                                                            };
                                                        ::tracing::callsite::DefaultCallsite::new(&META)
                                                    };
                                                let enabled =
                                                    ::tracing::Level::DEBUG <=
                                                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                            ::tracing::Level::DEBUG <=
                                                                ::tracing::level_filters::LevelFilter::current() &&
                                                        {
                                                            let interest = __CALLSITE.interest();
                                                            !interest.is_never() &&
                                                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                                    interest)
                                                        };
                                                if enabled {
                                                    (|value_set: ::tracing::field::ValueSet|
                                                                {
                                                                    let meta = __CALLSITE.metadata();
                                                                    ::tracing::Event::dispatch(meta, &value_set);
                                                                    ;
                                                                })({
                                                            #[allow(unused_imports)]
                                                            use ::tracing::field::{debug, display, Value};
                                                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("root universe {0:?} cannot name placeholder in universe {1:?}",
                                                                                                self.for_universe, placeholder.universe) as
                                                                                        &dyn ::tracing::field::Value))])
                                                        });
                                                } else { ; }
                                            };
                                            Err(TypeError::Mismatch)
                                        }
                                    }
                                    ty::Alias(ty::IsRigid::No, data) => {
                                        self.generalize_alias_term(data.into()).map(|v|
                                                v.expect_type())
                                    }
                                    _ => relate::structurally_relate_tys(self, t, t),
                                }?;
                        self.cache.insert((t, self.ambient_variance, self.in_alias),
                            g);
                        Ok(g)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:483",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(483u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, t2), ret)]
484    fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
485        assert_eq!(t, t2); // we are misusing TypeRelation here; both LHS and RHS ought to be ==
486
487        if let Some(&result) = self.cache.get(&(t, self.ambient_variance, self.in_alias)) {
488            return Ok(result);
489        }
490
491        // Check to see whether the type we are generalizing references
492        // any other type variable related to `vid` via
493        // subtyping. This is basically our "occurs check", preventing
494        // us from creating infinitely sized types.
495        let g = match *t.kind() {
496            ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
497                bug!("unexpected infer type: {t}")
498            }
499
500            ty::Infer(ty::TyVar(vid)) => {
501                let mut inner = self.infcx.inner.borrow_mut();
502                let vid = inner.type_variables().root_var(vid);
503                if TermVid::Ty(vid) == self.root_vid {
504                    // If sub-roots are equal, then `root_vid` and
505                    // `vid` are related via subtyping.
506                    Err(self.cyclic_term_error())
507                } else {
508                    let probe = inner.type_variables().probe(vid);
509                    match probe {
510                        TypeVariableValue::Known { value: u } => {
511                            drop(inner);
512                            self.relate(u, u)
513                        }
514                        TypeVariableValue::Unknown { universe } => {
515                            match self.ambient_variance {
516                                // Invariant: no need to make a fresh type variable
517                                // if we can name the universe.
518                                ty::Invariant => {
519                                    if self.for_universe.can_name(universe) {
520                                        return Ok(t);
521                                    }
522                                }
523
524                                // We do need a fresh type variable otherwise.
525                                ty::Bivariant | ty::Covariant | ty::Contravariant => (),
526                            }
527
528                            let origin = inner.type_variables().var_origin(vid);
529                            let new_var_id =
530                                inner.type_variables().new_var(self.for_universe, origin);
531                            // Record that `vid` and `new_var_id` have to be subtypes
532                            // of each other. This is currently only used for diagnostics.
533                            // To see why, see the docs in the `type_variables` module.
534                            inner.type_variables().sub_unify(vid, new_var_id);
535                            // If we're in the new solver and create a new inference
536                            // variable inside of an alias we eagerly constrain that
537                            // inference variable to prevent unexpected ambiguity errors.
538                            //
539                            // This is incomplete as it pulls down the universe of the
540                            // original inference variable, even though the alias could
541                            // normalize to a type which does not refer to that type at
542                            // all. I don't expect this to cause unexpected errors in
543                            // practice.
544                            //
545                            // We only need to do so for type and const variables, as
546                            // region variables do not impact normalization, and will get
547                            // correctly constrained by `AliasRelate` later on.
548                            //
549                            // cc trait-system-refactor-initiative#108
550                            if self.infcx.next_trait_solver()
551                                && !self.infcx.typing_mode_raw().is_coherence()
552                                && self.in_alias
553                            {
554                                inner.type_variables().equate(vid, new_var_id);
555                            }
556
557                            debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
558                            Ok(Ty::new_var(self.cx(), new_var_id))
559                        }
560                    }
561                }
562            }
563
564            ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) => {
565                // No matter what mode we are in,
566                // integer/floating-point types must be equal to be
567                // relatable.
568                Ok(t)
569            }
570
571            ty::Placeholder(placeholder) => {
572                if self.for_universe.can_name(placeholder.universe) {
573                    Ok(t)
574                } else {
575                    debug!(
576                        "root universe {:?} cannot name placeholder in universe {:?}",
577                        self.for_universe, placeholder.universe
578                    );
579                    Err(TypeError::Mismatch)
580                }
581            }
582
583            // We only need to be careful with potentially normalizeable
584            // aliases here. See `generalize_alias_term` for more information.
585            ty::Alias(ty::IsRigid::No, data) => {
586                self.generalize_alias_term(data.into()).map(|v| v.expect_type())
587            }
588
589            _ => relate::structurally_relate_tys(self, t, t),
590        }?;
591
592        self.cache.insert((t, self.ambient_variance, self.in_alias), g);
593        Ok(g)
594    }
595
596    {}
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("regions",
                                "rustc_infer::infer::relate::generalize",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(596u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("r")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("r");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&r)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                RelateResult<'tcx, ty::Region<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        {
                            match (&r, &r2) {
                                (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);
                                    }
                                }
                            }
                        };
                        match r.kind() {
                            ty::ReBound(..) | ty::ReErased => { return Ok(r); }
                            ty::ReError(_) => { return Ok(r); }
                            ty::RePlaceholder(..) | ty::ReVar(..) | ty::ReStatic |
                                ty::ReEarlyParam(..) | ty::ReLateParam(..) => {}
                        }
                        if let ty::Invariant = self.ambient_variance {
                            let r_universe = self.infcx.universe_of_region(r);
                            if self.for_universe.can_name(r_universe) { return Ok(r); }
                        }
                        Ok(self.infcx.next_region_var_in_universe(RegionVariableOrigin::Misc(self.span),
                                self.for_universe))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:596",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(596u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, r2), ret)]
597    fn regions(
598        &mut self,
599        r: ty::Region<'tcx>,
600        r2: ty::Region<'tcx>,
601    ) -> RelateResult<'tcx, ty::Region<'tcx>> {
602        assert_eq!(r, r2); // we are misusing TypeRelation here; both LHS and RHS ought to be ==
603
604        match r.kind() {
605            // Never make variables for regions bound within the type itself,
606            // nor for erased regions.
607            ty::ReBound(..) | ty::ReErased => {
608                return Ok(r);
609            }
610
611            // It doesn't really matter for correctness if we generalize ReError,
612            // since we're already on a doomed compilation path.
613            ty::ReError(_) => {
614                return Ok(r);
615            }
616
617            ty::RePlaceholder(..)
618            | ty::ReVar(..)
619            | ty::ReStatic
620            | ty::ReEarlyParam(..)
621            | ty::ReLateParam(..) => {
622                // see common code below
623            }
624        }
625
626        // If we are in an invariant context, we can re-use the region
627        // as is, unless it happens to be in some universe that we
628        // can't name.
629        if let ty::Invariant = self.ambient_variance {
630            let r_universe = self.infcx.universe_of_region(r);
631            if self.for_universe.can_name(r_universe) {
632                return Ok(r);
633            }
634        }
635
636        Ok(self
637            .infcx
638            .next_region_var_in_universe(RegionVariableOrigin::Misc(self.span), self.for_universe))
639    }
640
641    {}
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("consts",
                                "rustc_infer::infer::relate::generalize",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(641u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("c")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("c");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&c)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                RelateResult<'tcx, ty::Const<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.cx();
                        {
                            match (&c, &c2) {
                                (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);
                                    }
                                }
                            }
                        };
                        match c.kind() {
                            ty::ConstKind::Infer(InferConst::Var(vid)) => {
                                if TermVid::Const(self.infcx.inner.borrow_mut().const_unification_table().find(vid).vid)
                                        == self.root_vid {
                                    return Err(self.cyclic_term_error());
                                }
                                let mut inner = self.infcx.inner.borrow_mut();
                                let variable_table = &mut inner.const_unification_table();
                                match variable_table.probe_value(vid) {
                                    ConstVariableValue::Known { value: u } => {
                                        drop(inner);
                                        self.relate(u, u)
                                    }
                                    ConstVariableValue::Unknown { origin, universe } => {
                                        if self.for_universe.can_name(universe) {
                                            Ok(c)
                                        } else {
                                            let new_var_id =
                                                variable_table.new_key(ConstVariableValue::Unknown {
                                                            origin,
                                                            universe: self.for_universe,
                                                        }).vid;
                                            if self.infcx.next_trait_solver() &&
                                                        !self.infcx.typing_mode_raw().is_coherence() &&
                                                    self.in_alias {
                                                variable_table.union(vid, new_var_id);
                                            }
                                            Ok(ty::Const::new_var(tcx, new_var_id))
                                        }
                                    }
                                }
                            }
                            ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
                                if self.infcx.next_trait_solver() ||
                                        !tcx.features().generic_const_exprs() {
                                    self.generalize_alias_term(alias_const.into()).map(|v|
                                            v.expect_const())
                                } else {
                                    let ty::AliasConst { kind, args, .. } = alias_const;
                                    let args =
                                        self.relate_with_variance(ty::Invariant,
                                                ty::VarianceDiagInfo::default(), args, args)?;
                                    Ok(ty::Const::new_alias(tcx, ty::IsRigid::No,
                                            ty::AliasConst::new(tcx, kind, args)))
                                }
                            }
                            ty::ConstKind::Placeholder(placeholder) => {
                                if self.for_universe.can_name(placeholder.universe) {
                                    Ok(c)
                                } else {
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:726",
                                                            "rustc_infer::infer::relate::generalize",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(726u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                                            ::tracing_core::field::FieldSet::new(&["message"],
                                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("root universe {0:?} cannot name placeholder in universe {1:?}",
                                                                                        self.for_universe, placeholder.universe) as
                                                                                &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    Err(TypeError::Mismatch)
                                }
                            }
                            _ => relate::structurally_relate_consts(self, c, c),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:641",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(641u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, c2), ret)]
642    fn consts(
643        &mut self,
644        c: ty::Const<'tcx>,
645        c2: ty::Const<'tcx>,
646    ) -> RelateResult<'tcx, ty::Const<'tcx>> {
647        let tcx = self.cx();
648        assert_eq!(c, c2); // we are misusing TypeRelation here; both LHS and RHS ought to be ==
649
650        match c.kind() {
651            ty::ConstKind::Infer(InferConst::Var(vid)) => {
652                // If root const vids are equal, then `root_vid` and
653                // `vid` are related and we'd be inferring an infinitely
654                // deep const.
655                if TermVid::Const(
656                    self.infcx.inner.borrow_mut().const_unification_table().find(vid).vid,
657                ) == self.root_vid
658                {
659                    return Err(self.cyclic_term_error());
660                }
661
662                let mut inner = self.infcx.inner.borrow_mut();
663                let variable_table = &mut inner.const_unification_table();
664                match variable_table.probe_value(vid) {
665                    ConstVariableValue::Known { value: u } => {
666                        drop(inner);
667                        self.relate(u, u)
668                    }
669                    ConstVariableValue::Unknown { origin, universe } => {
670                        if self.for_universe.can_name(universe) {
671                            Ok(c)
672                        } else {
673                            let new_var_id = variable_table
674                                .new_key(ConstVariableValue::Unknown {
675                                    origin,
676                                    universe: self.for_universe,
677                                })
678                                .vid;
679
680                            // See the comment for type inference variables
681                            // for more details.
682                            if self.infcx.next_trait_solver()
683                                && !self.infcx.typing_mode_raw().is_coherence()
684                                && self.in_alias
685                            {
686                                variable_table.union(vid, new_var_id);
687                            }
688                            Ok(ty::Const::new_var(tcx, new_var_id))
689                        }
690                    }
691                }
692            }
693            // FIXME: Alias consts are also not rigid, so the current
694            // approach of always relating them structurally is incomplete.
695            //
696            // FIXME: replace the `else` branch with
697            // `structurally_relate_consts` once it is fully structural.
698            //
699            // We only need to be careful with potentially normalizeable
700            // aliases here. See `generalize_alias_term` for more information.
701            ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
702                // Hack: Fall back to old behavior if GCE is enabled (it used to just be the Yes
703                // path), as doing this new No path breaks some GCE things. I expect GCE to be
704                // ripped out soon so this shouldn't matter soon.
705                if self.infcx.next_trait_solver() || !tcx.features().generic_const_exprs() {
706                    self.generalize_alias_term(alias_const.into()).map(|v| v.expect_const())
707                } else {
708                    let ty::AliasConst { kind, args, .. } = alias_const;
709                    let args = self.relate_with_variance(
710                        ty::Invariant,
711                        ty::VarianceDiagInfo::default(),
712                        args,
713                        args,
714                    )?;
715                    Ok(ty::Const::new_alias(
716                        tcx,
717                        ty::IsRigid::No,
718                        ty::AliasConst::new(tcx, kind, args),
719                    ))
720                }
721            }
722            ty::ConstKind::Placeholder(placeholder) => {
723                if self.for_universe.can_name(placeholder.universe) {
724                    Ok(c)
725                } else {
726                    debug!(
727                        "root universe {:?} cannot name placeholder in universe {:?}",
728                        self.for_universe, placeholder.universe
729                    );
730                    Err(TypeError::Mismatch)
731                }
732            }
733            _ => relate::structurally_relate_consts(self, c, c),
734        }
735    }
736
737    {}
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("binders",
                                "rustc_infer::infer::relate::generalize",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(737u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("a")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("a");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&a)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                RelateResult<'tcx, ty::Binder<'tcx, T>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let result = self.relate(a.skip_binder(), a.skip_binder())?;
                        Ok(a.rebind(result))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:737",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(737u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
738    fn binders<T>(
739        &mut self,
740        a: ty::Binder<'tcx, T>,
741        _: ty::Binder<'tcx, T>,
742    ) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
743    where
744        T: Relate<TyCtxt<'tcx>>,
745    {
746        let result = self.relate(a.skip_binder(), a.skip_binder())?;
747        Ok(a.rebind(result))
748    }
749}
750
751/// Result from a generalization operation. This includes
752/// not only the generalized type, but also a bool flag
753/// indicating whether further WF checks are needed.
754#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for Generalization<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "Generalization", "value_may_be_infer", &&self.value_may_be_infer)
    }
}Debug)]
755struct Generalization<T> {
756    /// When generalizing `<?0 as Trait>::Assoc` or
757    /// `<T as Bar<<?0 as Foo>::Assoc>>::Assoc`
758    /// for `?0` generalization returns an inference
759    /// variable.
760    ///
761    /// This has to be handled with care as it can
762    /// otherwise very easily result in infinite
763    /// recursion.
764    pub value_may_be_infer: T,
765}