Skip to main content

rustc_infer/infer/outlives/
test_type_match.rs

1use std::collections::hash_map::Entry;
2
3use rustc_data_structures::fx::FxHashMap;
4use rustc_hir::def_id::DefId;
5use rustc_middle::ty::error::TypeError;
6use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
7use rustc_type_ir::relate::relate_args_with_variances;
8use tracing::instrument;
9
10use crate::infer::region_constraints::VerifyIfEq;
11use crate::infer::relate::{self as relate, Relate, RelateResult, TypeRelation};
12
13/// Given a "verify-if-eq" type test like:
14///
15/// ```rust,ignore (pseudo-Rust)
16/// exists<'a...> {
17///     verify_if_eq(some_type, bound_region)
18/// }
19/// ```
20///
21/// and the type `test_ty` that the type test is being tested against,
22/// returns:
23///
24/// * `None` if `some_type` cannot be made equal to `test_ty`,
25///   no matter the values of the variables in `exists`.
26/// * `Some(r)` with a suitable bound (typically the value of `bound_region`, modulo
27///   any bound existential variables, which will be instantiated) for the
28///   type under test.
29///
30/// NB: This function uses a simplistic, syntactic version of type equality.
31/// In other words, it may spuriously return `None` even if the type-under-test
32/// is in fact equal to `some_type`. In practice, though, this is used on types
33/// that are either projections like `T::Item` or `T` and it works fine, but it
34/// could have trouble when complex types with higher-ranked binders and the
35/// like are used. This is a particular challenge since this function is invoked
36/// very late in inference and hence cannot make use of the normal inference
37/// machinery.
38#[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("extract_verify_if_eq",
                                    "rustc_infer::infer::outlives::test_type_match",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(38u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["verify_if_eq_b",
                                                    "test_ty"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&verify_if_eq_b)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&test_ty)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Option<ty::Region<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !!verify_if_eq_b.has_escaping_bound_vars() {
                ::core::panicking::panic("assertion failed: !verify_if_eq_b.has_escaping_bound_vars()")
            };
            let mut m = MatchAgainstHigherRankedOutlives::new(tcx);
            let verify_if_eq = verify_if_eq_b.skip_binder();
            let (verify_ty, test_ty) =
                ty::set_aliases_to_non_rigid(tcx,
                        (verify_if_eq.ty, test_ty)).skip_norm_wip();
            m.relate(verify_ty, test_ty).ok()?;
            if let ty::RegionKind::ReBound(index_kind, br) =
                    verify_if_eq.bound.kind() {
                if !#[allow(non_exhaustive_omitted_patterns)] match index_kind
                            {
                            ty::BoundVarIndexKind::Bound(ty::INNERMOST) => true,
                            _ => false,
                        } {
                    ::core::panicking::panic("assertion failed: matches!(index_kind, ty::BoundVarIndexKind::Bound(ty::INNERMOST))")
                };
                match m.map.get(&br) {
                    Some(&r) => Some(r),
                    None => { Some(tcx.lifetimes.re_static) }
                }
            } else { Some(verify_if_eq.bound) }
        }
    }
}#[instrument(level = "debug", skip(tcx))]
39pub fn extract_verify_if_eq<'tcx>(
40    tcx: TyCtxt<'tcx>,
41    verify_if_eq_b: &ty::Binder<'tcx, VerifyIfEq<'tcx>>,
42    test_ty: Ty<'tcx>,
43) -> Option<ty::Region<'tcx>> {
44    assert!(!verify_if_eq_b.has_escaping_bound_vars());
45    let mut m = MatchAgainstHigherRankedOutlives::new(tcx);
46    let verify_if_eq = verify_if_eq_b.skip_binder();
47    // FIXME(#155345): Region handling should generally only
48    // deal with rigid aliases, making sure we do so correctly
49    // everywhere is effort, so we're just using `No` everywhere
50    // for now. This should change soon.
51    let (verify_ty, test_ty) =
52        ty::set_aliases_to_non_rigid(tcx, (verify_if_eq.ty, test_ty)).skip_norm_wip();
53    m.relate(verify_ty, test_ty).ok()?;
54
55    if let ty::RegionKind::ReBound(index_kind, br) = verify_if_eq.bound.kind() {
56        assert!(matches!(index_kind, ty::BoundVarIndexKind::Bound(ty::INNERMOST)));
57        match m.map.get(&br) {
58            Some(&r) => Some(r),
59            None => {
60                // If there is no mapping, then this region is unconstrained.
61                // In that case, we escalate to `'static`.
62                Some(tcx.lifetimes.re_static)
63            }
64        }
65    } else {
66        // The region does not contain any bound variables, so we don't need
67        // to do any instantiation.
68        //
69        // Example:
70        //
71        // for<'a> <T as Foo<'a>>::Item: 'b
72        //
73        // In this case, we've now matched and found a value for
74        // `'a`, but it doesn't affect the bound `'b`.
75        Some(verify_if_eq.bound)
76    }
77}
78
79/// True if a (potentially higher-ranked) outlives
80#[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("can_match_erased_ty",
                                    "rustc_infer::infer::outlives::test_type_match",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(80u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["outlives_predicate",
                                                    "erased_ty"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&outlives_predicate)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&erased_ty)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: bool = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !!outlives_predicate.has_escaping_bound_vars() {
                ::core::panicking::panic("assertion failed: !outlives_predicate.has_escaping_bound_vars()")
            };
            let erased_outlives_predicate =
                tcx.erase_and_anonymize_regions(outlives_predicate);
            let outlives_ty = erased_outlives_predicate.skip_binder().0;
            let outlives_ty =
                ty::set_aliases_to_non_rigid(tcx,
                        outlives_ty).skip_normalization();
            if outlives_ty == erased_ty {
                true
            } else {
                MatchAgainstHigherRankedOutlives::new(tcx).relate(outlives_ty,
                        erased_ty).is_ok()
            }
        }
    }
}#[instrument(level = "debug", skip(tcx))]
81pub(super) fn can_match_erased_ty<'tcx>(
82    tcx: TyCtxt<'tcx>,
83    outlives_predicate: ty::Binder<'tcx, ty::TypeOutlivesPredicate<'tcx>>,
84    erased_ty: Ty<'tcx>,
85) -> bool {
86    assert!(!outlives_predicate.has_escaping_bound_vars());
87    let erased_outlives_predicate = tcx.erase_and_anonymize_regions(outlives_predicate);
88    let outlives_ty = erased_outlives_predicate.skip_binder().0;
89    // FIXME(#155345): Region handling should generally only
90    // deal with rigid aliases, making sure we do so correctly
91    // everywhere is effort, so we're just using `No` everywhere
92    // for now. This should change soon.
93    let outlives_ty = ty::set_aliases_to_non_rigid(tcx, outlives_ty).skip_normalization();
94    if outlives_ty == erased_ty {
95        // pointless micro-optimization
96        true
97    } else {
98        MatchAgainstHigherRankedOutlives::new(tcx).relate(outlives_ty, erased_ty).is_ok()
99    }
100}
101
102struct MatchAgainstHigherRankedOutlives<'tcx> {
103    tcx: TyCtxt<'tcx>,
104    pattern_depth: ty::DebruijnIndex,
105    map: FxHashMap<ty::BoundRegion<'tcx>, ty::Region<'tcx>>,
106}
107
108impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
109    fn new(tcx: TyCtxt<'tcx>) -> MatchAgainstHigherRankedOutlives<'tcx> {
110        MatchAgainstHigherRankedOutlives {
111            tcx,
112            pattern_depth: ty::INNERMOST,
113            map: FxHashMap::default(),
114        }
115    }
116}
117
118impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
119    /// Creates the "Error" variant that signals "no match".
120    fn no_match<T>(&self) -> RelateResult<'tcx, T> {
121        Err(TypeError::Mismatch)
122    }
123
124    /// Binds the pattern variable `br` to `value`; returns an `Err` if the pattern
125    /// is already bound to a different value.
126    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("bind",
                                    "rustc_infer::infer::outlives::test_type_match",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(126u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["br", "value"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&br)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    RelateResult<'tcx, ty::Region<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match self.map.entry(br) {
                Entry::Occupied(entry) => {
                    if *entry.get() == value {
                        Ok(value)
                    } else { self.no_match() }
                }
                Entry::Vacant(entry) => { entry.insert(value); Ok(value) }
            }
        }
    }
}#[instrument(level = "trace", skip(self))]
127    fn bind(
128        &mut self,
129        br: ty::BoundRegion<'tcx>,
130        value: ty::Region<'tcx>,
131    ) -> RelateResult<'tcx, ty::Region<'tcx>> {
132        match self.map.entry(br) {
133            Entry::Occupied(entry) => {
134                if *entry.get() == value {
135                    Ok(value)
136                } else {
137                    self.no_match()
138                }
139            }
140            Entry::Vacant(entry) => {
141                entry.insert(value);
142                Ok(value)
143            }
144        }
145    }
146}
147
148impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx> {
149    fn cx(&self) -> TyCtxt<'tcx> {
150        self.tcx
151    }
152
153    fn relate_ty_args(
154        &mut self,
155        a_ty: Ty<'tcx>,
156        _: Ty<'tcx>,
157        def_id: DefId,
158        a_args: ty::GenericArgsRef<'tcx>,
159        b_args: ty::GenericArgsRef<'tcx>,
160        _: impl FnOnce(ty::GenericArgsRef<'tcx>) -> Ty<'tcx>,
161    ) -> RelateResult<'tcx, Ty<'tcx>> {
162        let variances = self.cx().variances_of(def_id);
163        relate_args_with_variances(self, variances, a_args, b_args)?;
164        Ok(a_ty)
165    }
166
167    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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::outlives::test_type_match",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(167u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["variance", "a",
                                                    "b"], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&variance)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&a)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&b)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: RelateResult<'tcx, T> = loop {};
            return __tracing_attr_fake_return;
        }
        { if variance != ty::Bivariant { self.relate(a, b) } else { Ok(a) } }
    }
}#[instrument(level = "trace", skip(self))]
168    fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
169        &mut self,
170        variance: ty::Variance,
171        _: ty::VarianceDiagInfo<TyCtxt<'tcx>>,
172        a: T,
173        b: T,
174    ) -> RelateResult<'tcx, T> {
175        // FIXME(@lcnr): This is weird. We are ignoring the ambient variance
176        // here, effectively treating everything as being in either a covariant
177        // or contravariant context.
178        //
179        // Opaque types args have lifetime parameters.
180        // We must not check them to be equal, as we never insert anything to make them so.
181        if variance != ty::Bivariant { self.relate(a, b) } else { Ok(a) }
182    }
183
184    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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::outlives::test_type_match",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(184u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["pattern", "value"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pattern)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    RelateResult<'tcx, ty::Region<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if let ty::RegionKind::ReBound(ty::BoundVarIndexKind::Bound(depth),
                        br) = pattern.kind() && depth == self.pattern_depth {
                self.bind(br, value)
            } else if pattern == value {
                Ok(pattern)
            } else { self.no_match() }
        }
    }
}#[instrument(skip(self), level = "trace")]
185    fn regions(
186        &mut self,
187        pattern: ty::Region<'tcx>,
188        value: ty::Region<'tcx>,
189    ) -> RelateResult<'tcx, ty::Region<'tcx>> {
190        if let ty::RegionKind::ReBound(ty::BoundVarIndexKind::Bound(depth), br) = pattern.kind()
191            && depth == self.pattern_depth
192        {
193            self.bind(br, value)
194        } else if pattern == value {
195            Ok(pattern)
196        } else {
197            self.no_match()
198        }
199    }
200
201    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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::outlives::test_type_match",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(201u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["pattern", "value"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pattern)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: RelateResult<'tcx, Ty<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            if #[allow(non_exhaustive_omitted_patterns)] match pattern.kind()
                    {
                    ty::Error(_) | ty::Bound(..) => true,
                    _ => false,
                } {
                self.no_match()
            } else if pattern == value {
                Ok(pattern)
            } else { relate::structurally_relate_tys(self, pattern, value) }
        }
    }
}#[instrument(skip(self), level = "trace")]
202    fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
203        // FIXME(non_lifetime_binders): What to do here?
204        if matches!(pattern.kind(), ty::Error(_) | ty::Bound(..)) {
205            // Unlike normal `TypeRelation` rules, `ty::Error` does not equal any type.
206            self.no_match()
207        } else if pattern == value {
208            Ok(pattern)
209        } else {
210            relate::structurally_relate_tys(self, pattern, value)
211        }
212    }
213
214    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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::outlives::test_type_match",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(214u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["pattern", "value"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pattern)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    RelateResult<'tcx, ty::Const<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if pattern == value {
                Ok(pattern)
            } else {
                relate::structurally_relate_consts(self, pattern, value)
            }
        }
    }
}#[instrument(skip(self), level = "trace")]
215    fn consts(
216        &mut self,
217        pattern: ty::Const<'tcx>,
218        value: ty::Const<'tcx>,
219    ) -> RelateResult<'tcx, ty::Const<'tcx>> {
220        if pattern == value {
221            Ok(pattern)
222        } else {
223            relate::structurally_relate_consts(self, pattern, value)
224        }
225    }
226
227    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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::outlives::test_type_match",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/test_type_match.rs"),
                                    ::tracing_core::__macro_support::Option::Some(227u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::test_type_match"),
                                    ::tracing_core::field::FieldSet::new(&["pattern", "value"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pattern)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    RelateResult<'tcx, ty::Binder<'tcx, T>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            self.pattern_depth.shift_in(1);
            let result =
                Ok(pattern.rebind(self.relate(pattern.skip_binder(),
                                value.skip_binder())?));
            self.pattern_depth.shift_out(1);
            result
        }
    }
}#[instrument(skip(self), level = "trace")]
228    fn binders<T>(
229        &mut self,
230        pattern: ty::Binder<'tcx, T>,
231        value: ty::Binder<'tcx, T>,
232    ) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
233    where
234        T: Relate<TyCtxt<'tcx>>,
235    {
236        self.pattern_depth.shift_in(1);
237        let result = Ok(pattern.rebind(self.relate(pattern.skip_binder(), value.skip_binder())?));
238        self.pattern_depth.shift_out(1);
239        result
240    }
241}