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, TypeFlags, 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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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
359/// Do we need to generalize this type?
360const NEEDS_GENERALIZATION: TypeFlags = TypeFlags::from_bits(
361    TypeFlags::HAS_FREE_REGIONS.bits()
362        | TypeFlags::HAS_INFER.bits()
363        | TypeFlags::HAS_PLACEHOLDER.bits()
364        | TypeFlags::HAS_NON_RIGID_ALIAS.bits(),
365)
366.unwrap();
367
368impl<'tcx> Generalizer<'_, 'tcx> {
369    /// Create an error that corresponds to the term kind in `root_term`
370    fn cyclic_term_error(&self) -> TypeError<'tcx> {
371        match self.root_term.kind() {
372            ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty),
373            ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
374        }
375    }
376
377    /// Create a new type variable in the universe of the target when
378    /// generalizing an alias.
379    fn next_var_for_alias_of_kind(&self, alias: ty::AliasTerm<'tcx>) -> ty::Term<'tcx> {
380        if alias.kind.is_type() {
381            self.infcx.next_ty_var_in_universe(self.span, self.for_universe).into()
382        } else {
383            self.infcx.next_const_var_in_universe(self.span, self.for_universe).into()
384        }
385    }
386
387    /// We only handle potentially normalizable aliases via this method. For rigid alias,
388    /// we always generalize structurally.
389    ///
390    /// An occurs check failure inside of an alias does not mean
391    /// that the types definitely don't unify. We may be able
392    /// to normalize the alias after all.
393    ///
394    /// We handle this by lazily equating the normalizable alias
395    /// and generalizing it to an inference variable. In the new solver,
396    /// we always generalize to an infer var unless the alias contains escaping
397    /// bound variables.
398    ///
399    /// Correctly handling aliases with escaping bound variables is
400    /// difficult and currently incomplete in two opposite ways:
401    /// - if we get an occurs check failure in the alias, replace it with a new infer var.
402    ///   This causes us to later emit an alias-relate goal and is incomplete in case the
403    ///   alias normalizes to type containing one of the bound variables.
404    /// - if the alias contains an inference variable not nameable by `for_universe`, we
405    ///   continue generalizing the alias. This ends up pulling down the universe of the
406    ///   inference variable and is incomplete in case the alias would normalize to a type
407    ///   which does not mention that inference variable.
408    fn generalize_alias_term(
409        &mut self,
410        alias: ty::AliasTerm<'tcx>,
411    ) -> Result<Term<'tcx>, TypeError<'tcx>> {
412        // We do not eagerly replace aliases with inference variables if they have
413        // escaping bound vars, see the method comment for details. However, when we
414        // are inside of an alias with escaping bound vars replacing nested aliases
415        // with inference variables can cause incorrect ambiguity.
416        //
417        // cc trait-system-refactor-initiative#110
418        if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() && !self.in_alias {
419            return Ok(self.next_var_for_alias_of_kind(alias));
420        }
421
422        let is_nested_alias = mem::replace(&mut self.in_alias, true);
423        let result = match self.relate(alias, alias) {
424            Ok(alias) => Ok(alias.to_term(self.cx(), ty::IsRigid::No)),
425            Err(e) => {
426                if is_nested_alias {
427                    return Err(e);
428                } else {
429                    let alias_max_universe = ty::max_universe_of_placeholders(self.infcx, alias);
430                    let infer_replacement_is_complete =
431                        self.for_universe.can_name(alias_max_universe)
432                            && !alias.has_escaping_bound_vars();
433                    if !infer_replacement_is_complete {
434                        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:434",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::WARN,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(434u32),
                        ::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:?}");
435                    }
436
437                    {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:437",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(437u32),
                        ::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");
438                    Ok(self.next_var_for_alias_of_kind(alias))
439                }
440            }
441        };
442        self.in_alias = is_nested_alias;
443        result
444    }
445}
446
447impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
448    fn cx(&self) -> TyCtxt<'tcx> {
449        self.infcx.tcx
450    }
451
452    fn relate_ty_args(
453        &mut self,
454        a_ty: Ty<'tcx>,
455        _: Ty<'tcx>,
456        def_id: DefId,
457        a_args: ty::GenericArgsRef<'tcx>,
458        b_args: ty::GenericArgsRef<'tcx>,
459        mk: impl FnOnce(ty::GenericArgsRef<'tcx>) -> Ty<'tcx>,
460    ) -> RelateResult<'tcx, Ty<'tcx>> {
461        let args = if self.ambient_variance == ty::Invariant {
462            // Avoid fetching the variance if we are in an invariant
463            // context; no need, and it can induce dependency cycles
464            // (e.g., #41849).
465            relate::relate_args_invariantly(self, a_args, b_args)
466        } else {
467            let tcx = self.cx();
468            let variances = tcx.variances_of(def_id);
469            relate::relate_args_with_variances(self, variances, a_args, b_args)
470        }?;
471        if args == a_args { Ok(a_ty) } else { Ok(mk(args)) }
472    }
473
474    {}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(474u32),
                                ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:484",
                                                "rustc_infer::infer::relate::generalize",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                ::tracing_core::__macro_support::Option::Some(484u32),
                                                ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:474",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(474u32),
                        ::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)]
475    fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
476        &mut self,
477        variance: ty::Variance,
478        _info: ty::VarianceDiagInfo<TyCtxt<'tcx>>,
479        a: T,
480        b: T,
481    ) -> RelateResult<'tcx, T> {
482        let old_ambient_variance = self.ambient_variance;
483        self.ambient_variance = self.ambient_variance.xform(variance);
484        debug!(?self.ambient_variance, "new ambient variance");
485        // Recursive calls to `relate` can overflow the stack. For example a deeper version of
486        // `ui/associated-consts/issue-93775.rs`.
487        let r = self.relate(a, b);
488        self.ambient_variance = old_ambient_variance;
489        r
490    }
491
492    {}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(492u32),
                                ::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 !t.has_type_flags(NEEDS_GENERALIZATION) { return Ok(t); }
                        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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:570",
                                                                            "rustc_infer::infer::relate::generalize",
                                                                            ::tracing::Level::DEBUG,
                                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                                            ::tracing_core::__macro_support::Option::Some(570u32),
                                                                            ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:588",
                                                                    "rustc_infer::infer::relate::generalize",
                                                                    ::tracing::Level::DEBUG,
                                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                                    ::tracing_core::__macro_support::Option::Some(588u32),
                                                                    ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:492",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(492u32),
                        ::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)]
493    fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
494        assert_eq!(t, t2); // we are misusing TypeRelation here; both LHS and RHS ought to be ==
495
496        if !t.has_type_flags(NEEDS_GENERALIZATION) {
497            return Ok(t);
498        }
499
500        if let Some(&result) = self.cache.get(&(t, self.ambient_variance, self.in_alias)) {
501            return Ok(result);
502        }
503
504        // Check to see whether the type we are generalizing references
505        // any other type variable related to `vid` via
506        // subtyping. This is basically our "occurs check", preventing
507        // us from creating infinitely sized types.
508        let g = match *t.kind() {
509            ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
510                bug!("unexpected infer type: {t}")
511            }
512
513            ty::Infer(ty::TyVar(vid)) => {
514                let mut inner = self.infcx.inner.borrow_mut();
515                let vid = inner.type_variables().root_var(vid);
516                if TermVid::Ty(vid) == self.root_vid {
517                    // If sub-roots are equal, then `root_vid` and
518                    // `vid` are related via subtyping.
519                    Err(self.cyclic_term_error())
520                } else {
521                    let probe = inner.type_variables().probe(vid);
522                    match probe {
523                        TypeVariableValue::Known { value: u } => {
524                            drop(inner);
525                            self.relate(u, u)
526                        }
527                        TypeVariableValue::Unknown { universe } => {
528                            match self.ambient_variance {
529                                // Invariant: no need to make a fresh type variable
530                                // if we can name the universe.
531                                ty::Invariant => {
532                                    if self.for_universe.can_name(universe) {
533                                        return Ok(t);
534                                    }
535                                }
536
537                                // We do need a fresh type variable otherwise.
538                                ty::Bivariant | ty::Covariant | ty::Contravariant => (),
539                            }
540
541                            let origin = inner.type_variables().var_origin(vid);
542                            let new_var_id =
543                                inner.type_variables().new_var(self.for_universe, origin);
544                            // Record that `vid` and `new_var_id` have to be subtypes
545                            // of each other. This is currently only used for diagnostics.
546                            // To see why, see the docs in the `type_variables` module.
547                            inner.type_variables().sub_unify(vid, new_var_id);
548                            // If we're in the new solver and create a new inference
549                            // variable inside of an alias we eagerly constrain that
550                            // inference variable to prevent unexpected ambiguity errors.
551                            //
552                            // This is incomplete as it pulls down the universe of the
553                            // original inference variable, even though the alias could
554                            // normalize to a type which does not refer to that type at
555                            // all. I don't expect this to cause unexpected errors in
556                            // practice.
557                            //
558                            // We only need to do so for type and const variables, as
559                            // region variables do not impact normalization, and will get
560                            // correctly constrained by `AliasRelate` later on.
561                            //
562                            // cc trait-system-refactor-initiative#108
563                            if self.infcx.next_trait_solver()
564                                && !self.infcx.typing_mode_raw().is_coherence()
565                                && self.in_alias
566                            {
567                                inner.type_variables().equate(vid, new_var_id);
568                            }
569
570                            debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
571                            Ok(Ty::new_var(self.cx(), new_var_id))
572                        }
573                    }
574                }
575            }
576
577            ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) => {
578                // No matter what mode we are in,
579                // integer/floating-point types must be equal to be
580                // relatable.
581                Ok(t)
582            }
583
584            ty::Placeholder(placeholder) => {
585                if self.for_universe.can_name(placeholder.universe) {
586                    Ok(t)
587                } else {
588                    debug!(
589                        "root universe {:?} cannot name placeholder in universe {:?}",
590                        self.for_universe, placeholder.universe
591                    );
592                    Err(TypeError::Mismatch)
593                }
594            }
595
596            // We only need to be careful with potentially normalizeable
597            // aliases here. See `generalize_alias_term` for more information.
598            ty::Alias(ty::IsRigid::No, data) => {
599                self.generalize_alias_term(data.into()).map(|v| v.expect_type())
600            }
601
602            _ => relate::structurally_relate_tys(self, t, t),
603        }?;
604
605        self.cache.insert((t, self.ambient_variance, self.in_alias), g);
606        Ok(g)
607    }
608
609    {}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(609u32),
                                ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:609",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(609u32),
                        ::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)]
610    fn regions(
611        &mut self,
612        r: ty::Region<'tcx>,
613        r2: ty::Region<'tcx>,
614    ) -> RelateResult<'tcx, ty::Region<'tcx>> {
615        assert_eq!(r, r2); // we are misusing TypeRelation here; both LHS and RHS ought to be ==
616
617        match r.kind() {
618            // Never make variables for regions bound within the type itself,
619            // nor for erased regions.
620            ty::ReBound(..) | ty::ReErased => {
621                return Ok(r);
622            }
623
624            // It doesn't really matter for correctness if we generalize ReError,
625            // since we're already on a doomed compilation path.
626            ty::ReError(_) => {
627                return Ok(r);
628            }
629
630            ty::RePlaceholder(..)
631            | ty::ReVar(..)
632            | ty::ReStatic
633            | ty::ReEarlyParam(..)
634            | ty::ReLateParam(..) => {
635                // see common code below
636            }
637        }
638
639        // If we are in an invariant context, we can re-use the region
640        // as is, unless it happens to be in some universe that we
641        // can't name.
642        if let ty::Invariant = self.ambient_variance {
643            let r_universe = self.infcx.universe_of_region(r);
644            if self.for_universe.can_name(r_universe) {
645                return Ok(r);
646            }
647        }
648
649        Ok(self
650            .infcx
651            .next_region_var_in_universe(RegionVariableOrigin::Misc(self.span), self.for_universe))
652    }
653
654    {}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(654u32),
                                ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:739",
                                                            "rustc_infer::infer::relate::generalize",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(739u32),
                                                            ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:654",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(654u32),
                        ::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)]
655    fn consts(
656        &mut self,
657        c: ty::Const<'tcx>,
658        c2: ty::Const<'tcx>,
659    ) -> RelateResult<'tcx, ty::Const<'tcx>> {
660        let tcx = self.cx();
661        assert_eq!(c, c2); // we are misusing TypeRelation here; both LHS and RHS ought to be ==
662
663        match c.kind() {
664            ty::ConstKind::Infer(InferConst::Var(vid)) => {
665                // If root const vids are equal, then `root_vid` and
666                // `vid` are related and we'd be inferring an infinitely
667                // deep const.
668                if TermVid::Const(
669                    self.infcx.inner.borrow_mut().const_unification_table().find(vid).vid,
670                ) == self.root_vid
671                {
672                    return Err(self.cyclic_term_error());
673                }
674
675                let mut inner = self.infcx.inner.borrow_mut();
676                let variable_table = &mut inner.const_unification_table();
677                match variable_table.probe_value(vid) {
678                    ConstVariableValue::Known { value: u } => {
679                        drop(inner);
680                        self.relate(u, u)
681                    }
682                    ConstVariableValue::Unknown { origin, universe } => {
683                        if self.for_universe.can_name(universe) {
684                            Ok(c)
685                        } else {
686                            let new_var_id = variable_table
687                                .new_key(ConstVariableValue::Unknown {
688                                    origin,
689                                    universe: self.for_universe,
690                                })
691                                .vid;
692
693                            // See the comment for type inference variables
694                            // for more details.
695                            if self.infcx.next_trait_solver()
696                                && !self.infcx.typing_mode_raw().is_coherence()
697                                && self.in_alias
698                            {
699                                variable_table.union(vid, new_var_id);
700                            }
701                            Ok(ty::Const::new_var(tcx, new_var_id))
702                        }
703                    }
704                }
705            }
706            // FIXME: Alias consts are also not rigid, so the current
707            // approach of always relating them structurally is incomplete.
708            //
709            // FIXME: replace the `else` branch with
710            // `structurally_relate_consts` once it is fully structural.
711            //
712            // We only need to be careful with potentially normalizeable
713            // aliases here. See `generalize_alias_term` for more information.
714            ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
715                // Hack: Fall back to old behavior if GCE is enabled (it used to just be the Yes
716                // path), as doing this new No path breaks some GCE things. I expect GCE to be
717                // ripped out soon so this shouldn't matter soon.
718                if self.infcx.next_trait_solver() || !tcx.features().generic_const_exprs() {
719                    self.generalize_alias_term(alias_const.into()).map(|v| v.expect_const())
720                } else {
721                    let ty::AliasConst { kind, args, .. } = alias_const;
722                    let args = self.relate_with_variance(
723                        ty::Invariant,
724                        ty::VarianceDiagInfo::default(),
725                        args,
726                        args,
727                    )?;
728                    Ok(ty::Const::new_alias(
729                        tcx,
730                        ty::IsRigid::No,
731                        ty::AliasConst::new(tcx, kind, args),
732                    ))
733                }
734            }
735            ty::ConstKind::Placeholder(placeholder) => {
736                if self.for_universe.can_name(placeholder.universe) {
737                    Ok(c)
738                } else {
739                    debug!(
740                        "root universe {:?} cannot name placeholder in universe {:?}",
741                        self.for_universe, placeholder.universe
742                    );
743                    Err(TypeError::Mismatch)
744                }
745            }
746            _ => relate::structurally_relate_consts(self, c, c),
747        }
748    }
749
750    {}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                                ::tracing_core::__macro_support::Option::Some(750u32),
                                ::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs:750",
                        "rustc_infer::infer::relate::generalize",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_infer/src/infer/relate/generalize.rs"),
                        ::tracing_core::__macro_support::Option::Some(750u32),
                        ::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)]
751    fn binders<T>(
752        &mut self,
753        a: ty::Binder<'tcx, T>,
754        _: ty::Binder<'tcx, T>,
755    ) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
756    where
757        T: Relate<TyCtxt<'tcx>>,
758    {
759        let result = self.relate(a.skip_binder(), a.skip_binder())?;
760        Ok(a.rebind(result))
761    }
762}
763
764/// Result from a generalization operation. This includes
765/// not only the generalized type, but also a bool flag
766/// indicating whether further WF checks are needed.
767#[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)]
768struct Generalization<T> {
769    /// When generalizing `<?0 as Trait>::Assoc` or
770    /// `<T as Bar<<?0 as Foo>::Assoc>>::Assoc`
771    /// for `?0` generalization returns an inference
772    /// variable.
773    ///
774    /// This has to be handled with care as it can
775    /// otherwise very easily result in infinite
776    /// recursion.
777    pub value_may_be_infer: T,
778}