1use std::mem;
2
3use rustc_data_structures::sso::SsoHashMap;
4use rustc_hir::def_id::DefId;
5use rustc_middle::ty::error::TypeError;
6use rustc_middle::ty::{self, InferConst, Term, Ty, TyCtxt, TypeVisitableExt};
7use rustc_span::{Span, bug};
8use tracing::{debug, instrument, warn};
9
10use super::{PredicateEmittingRelation, Relate, RelateResult, TypeRelation};
11use crate::infer::type_variable::TypeVariableValue;
12use crate::infer::unify_key::ConstVariableValue;
13use crate::infer::{InferCtxt, RegionVariableOrigin, relate};
14
15#[derive(#[automatically_derived]
impl ::core::marker::Copy for TermVid { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for TermVid { }
#[automatically_derived]
impl ::core::clone::Clone for TermVid {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<ty::TyVid>;
let _: ::core::clone::AssertParamIsClone<ty::ConstVid>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::Eq for TermVid {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<ty::TyVid>;
let _: ::core::cmp::AssertParamIsEq<ty::ConstVid>;
}
}Eq, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for TermVid { }
#[automatically_derived]
impl ::core::cmp::PartialEq for TermVid {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Ty(__self_0), Self::Ty(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Const(__self_0), Self::Const(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for TermVid {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Ty(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
&__self_0),
Self::Const(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
}
}
}Debug)]
16enum TermVid {
17 Ty(ty::TyVid),
18 Const(ty::ConstVid),
19}
20
21impl From<ty::TyVid> for TermVid {
22 fn from(value: ty::TyVid) -> Self {
23 TermVid::Ty(value)
24 }
25}
26
27impl From<ty::ConstVid> for TermVid {
28 fn from(value: ty::ConstVid) -> Self {
29 TermVid::Const(value)
30 }
31}
32
33impl<'tcx> InferCtxt<'tcx> {
34 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("instantiate_ty_var",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(46u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target_is_expected")
}> =
::tracing::__macro_support::FieldName::new("target_is_expected");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target_vid")
}> =
::tracing::__macro_support::FieldName::new("target_vid");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("instantiation_variance")
}> =
::tracing::__macro_support::FieldName::new("instantiation_variance");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("source_ty")
}> =
::tracing::__macro_support::FieldName::new("source_ty");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&target_is_expected
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target_vid)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instantiation_variance)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source_ty)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RelateResult<'tcx, ()> = loop {};
return __tracing_attr_fake_return;
}
{
if true {
if !self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown()
{
::core::panicking::panic("assertion failed: self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown()")
};
};
self.instantiate_var(relation, target_is_expected,
target_vid.into(), instantiation_variance, source_ty.into())
}
}
}#[instrument(level = "debug", skip(self, relation))]
47 pub fn instantiate_ty_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
48 &self,
49 relation: &mut R,
50 target_is_expected: bool,
51 target_vid: ty::TyVid,
52 instantiation_variance: ty::Variance,
53 source_ty: Ty<'tcx>,
54 ) -> RelateResult<'tcx, ()> {
55 debug_assert!(self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown());
56
57 self.instantiate_var(
58 relation,
59 target_is_expected,
60 target_vid.into(),
61 instantiation_variance,
62 source_ty.into(),
63 )
64 }
65
66 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("instantiate_const_var",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(100u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target_is_expected")
}> =
::tracing::__macro_support::FieldName::new("target_is_expected");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target_vid")
}> =
::tracing::__macro_support::FieldName::new("target_vid");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("source_ct")
}> =
::tracing::__macro_support::FieldName::new("source_ct");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&target_is_expected
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target_vid)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source_ct)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RelateResult<'tcx, ()> = loop {};
return __tracing_attr_fake_return;
}
{
if true {
if !self.inner.borrow_mut().const_unification_table().probe_value(target_vid).is_unknown()
{
::core::panicking::panic("assertion failed: self.inner.borrow_mut().const_unification_table().probe_value(target_vid).is_unknown()")
};
};
self.instantiate_var(relation, target_is_expected,
target_vid.into(), ty::Invariant, source_ct.into())
}
}
}#[instrument(level = "debug", skip(self, relation))]
101 pub(crate) fn instantiate_const_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
102 &self,
103 relation: &mut R,
104 target_is_expected: bool,
105 target_vid: ty::ConstVid,
106 source_ct: ty::Const<'tcx>,
107 ) -> RelateResult<'tcx, ()> {
108 debug_assert!(
111 self.inner.borrow_mut().const_unification_table().probe_value(target_vid).is_unknown()
112 );
113
114 self.instantiate_var(
115 relation,
116 target_is_expected,
117 target_vid.into(),
118 ty::Invariant,
119 source_ct.into(),
120 )
121 }
122
123 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("instantiate_var",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(123u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target_is_expected")
}> =
::tracing::__macro_support::FieldName::new("target_is_expected");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target_vid")
}> =
::tracing::__macro_support::FieldName::new("target_vid");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("instantiation_variance")
}> =
::tracing::__macro_support::FieldName::new("instantiation_variance");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("source_term")
}> =
::tracing::__macro_support::FieldName::new("source_term");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&target_is_expected
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target_vid)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instantiation_variance)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source_term)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RelateResult<'tcx, ()> = loop {};
return __tracing_attr_fake_return;
}
{
let Generalization { value_may_be_infer: generalized_term } =
self.generalize(relation.span(), target_vid,
instantiation_variance, source_term)?;
self.union_var_term(target_vid, generalized_term);
if generalized_term.is_infer() {
let Some(source_alias) =
source_term.to_alias_term() else {
::rustc_span::macros::bug_impl(None,
format_args!("generalized `{0:?} to infer, not an alias",
source_term), Location::caller());
};
if !!self.next_trait_solver() {
{
::core::panicking::panic_fmt(format_args!("nonrigid aliases should be handled in relations, not here"));
}
};
match source_alias.kind {
ty::AliasTermKind::ProjectionTy { .. } |
ty::AliasTermKind::ProjectionConst { .. } => {
relation.register_predicates([ty::ProjectionClause {
projection_term: source_alias,
term: generalized_term,
}]);
}
ty::AliasTermKind::InherentTy { .. } |
ty::AliasTermKind::FreeTy { .. } |
ty::AliasTermKind::OpaqueTy { .. } => {
return Err(TypeError::CyclicTy(source_term.expect_type()));
}
ty::AliasTermKind::InherentConstSelf { .. } |
ty::AliasTermKind::InherentConstImpl { .. } |
ty::AliasTermKind::FreeConst { .. } |
ty::AliasTermKind::AnonConst { .. } => {
return Err(TypeError::CyclicConst(source_term.expect_const()));
}
}
} else {
match generalized_term.kind() {
ty::TermKind::Ty(_) => {
if target_is_expected {
relation.relate(generalized_term, source_term)?;
} else {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:214",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(214u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("flip relation")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
relation.relate(source_term, generalized_term)?;
}
}
ty::TermKind::Const(_) => {
if target_is_expected {
relation.relate_with_variance(ty::Invariant,
ty::VarianceDiagInfo::default(), generalized_term,
source_term)?;
} else {
relation.relate_with_variance(ty::Invariant,
ty::VarianceDiagInfo::default(), source_term,
generalized_term)?;
}
}
}
}
Ok(())
}
}
}#[instrument(level = "debug", skip(self, relation))]
124 fn instantiate_var<R: PredicateEmittingRelation<Self>>(
125 &self,
126 relation: &mut R,
127 target_is_expected: bool,
128 target_vid: TermVid,
129 instantiation_variance: ty::Variance,
130 source_term: Term<'tcx>,
131 ) -> RelateResult<'tcx, ()> {
132 let Generalization { value_may_be_infer: generalized_term } =
142 self.generalize(relation.span(), target_vid, instantiation_variance, source_term)?;
143
144 self.union_var_term(target_vid, generalized_term);
146
147 if generalized_term.is_infer() {
154 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 relation.register_predicates([ty::ProjectionClause {
174 projection_term: source_alias,
175 term: generalized_term,
176 }]);
177 }
178 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 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 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 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 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 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
314struct Generalizer<'me, 'tcx> {
328 infcx: &'me InferCtxt<'tcx>,
329
330 span: Span,
331
332 root_vid: TermVid,
336
337 for_universe: ty::UniverseIndex,
341
342 root_term: Term<'tcx>,
344
345 ambient_variance: ty::Variance,
348
349 in_alias: bool,
355
356 cache: SsoHashMap<(Ty<'tcx>, ty::Variance, bool), Ty<'tcx>>,
357}
358
359impl<'tcx> Generalizer<'_, 'tcx> {
360 fn cyclic_term_error(&self) -> TypeError<'tcx> {
362 match self.root_term.kind() {
363 ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty),
364 ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
365 }
366 }
367
368 fn next_var_for_alias_of_kind(&self, alias: ty::AliasTerm<'tcx>) -> ty::Term<'tcx> {
371 if alias.kind.is_type() {
372 self.infcx.next_ty_var_in_universe(self.span, self.for_universe).into()
373 } else {
374 self.infcx.next_const_var_in_universe(self.span, self.for_universe).into()
375 }
376 }
377
378 fn generalize_alias_term(
400 &mut self,
401 alias: ty::AliasTerm<'tcx>,
402 ) -> Result<Term<'tcx>, TypeError<'tcx>> {
403 if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() && !self.in_alias {
410 return Ok(self.next_var_for_alias_of_kind(alias));
411 }
412
413 let is_nested_alias = mem::replace(&mut self.in_alias, true);
414 let result = match self.relate(alias, alias) {
415 Ok(alias) => Ok(alias.to_term(self.cx(), ty::IsRigid::No)),
416 Err(e) => {
417 if is_nested_alias {
418 return Err(e);
419 } else {
420 let alias_max_universe = ty::max_universe_of_placeholders(self.infcx, alias);
421 let infer_replacement_is_complete =
422 self.for_universe.can_name(alias_max_universe)
423 && !alias.has_escaping_bound_vars();
424 if !infer_replacement_is_complete {
425 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:425",
"rustc_infer::infer::relate::generalize",
::tracing::Level::WARN,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(425u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::WARN <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::WARN <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("may incompletely handle alias type: {0:?}",
alias) as &dyn ::tracing::field::Value))])
});
} else { ; }
};warn!("may incompletely handle alias type: {alias:?}");
426 }
427
428 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:428",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(428u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("generalization failure in alias")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("generalization failure in alias");
429 Ok(self.next_var_for_alias_of_kind(alias))
430 }
431 }
432 };
433 self.in_alias = is_nested_alias;
434 result
435 }
436}
437
438impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
439 fn cx(&self) -> TyCtxt<'tcx> {
440 self.infcx.tcx
441 }
442
443 fn relate_ty_args(
444 &mut self,
445 a_ty: Ty<'tcx>,
446 _: Ty<'tcx>,
447 def_id: DefId,
448 a_args: ty::GenericArgsRef<'tcx>,
449 b_args: ty::GenericArgsRef<'tcx>,
450 mk: impl FnOnce(ty::GenericArgsRef<'tcx>) -> Ty<'tcx>,
451 ) -> RelateResult<'tcx, Ty<'tcx>> {
452 let args = if self.ambient_variance == ty::Invariant {
453 relate::relate_args_invariantly(self, a_args, b_args)
457 } else {
458 let tcx = self.cx();
459 let variances = tcx.variances_of(def_id);
460 relate::relate_args_with_variances(self, variances, a_args, b_args)
461 }?;
462 if args == a_args { Ok(a_ty) } else { Ok(mk(args)) }
463 }
464
465 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("relate_with_variance",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(465u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("_info")
}> =
::tracing::__macro_support::FieldName::new("_info");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("a")
}> =
::tracing::__macro_support::FieldName::new("a");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&_info)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&a)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RelateResult<'tcx, T> =
loop {};
return __tracing_attr_fake_return;
}
{
let old_ambient_variance = self.ambient_variance;
self.ambient_variance =
self.ambient_variance.xform(variance);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:475",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(475u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self.ambient_variance")
}> =
::tracing::__macro_support::FieldName::new("self.ambient_variance");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("new ambient variance")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self.ambient_variance)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let r = self.relate(a, b);
self.ambient_variance = old_ambient_variance;
r
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:465",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(465u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self, variance, b), ret)]
466 fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
467 &mut self,
468 variance: ty::Variance,
469 _info: ty::VarianceDiagInfo<TyCtxt<'tcx>>,
470 a: T,
471 b: T,
472 ) -> RelateResult<'tcx, T> {
473 let old_ambient_variance = self.ambient_variance;
474 self.ambient_variance = self.ambient_variance.xform(variance);
475 debug!(?self.ambient_variance, "new ambient variance");
476 let r = self.relate(a, b);
479 self.ambient_variance = old_ambient_variance;
480 r
481 }
482
483 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("tys",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(483u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("t")
}> =
::tracing::__macro_support::FieldName::new("t");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&t)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
RelateResult<'tcx, Ty<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
{
match (&t, &t2) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
if let Some(&result) =
self.cache.get(&(t, self.ambient_variance, self.in_alias)) {
return Ok(result);
}
let g =
match *t.kind() {
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) |
ty::FreshFloatTy(_)) => {
::rustc_span::macros::bug_impl(None,
format_args!("unexpected infer type: {0}", t),
Location::caller())
}
ty::Infer(ty::TyVar(vid)) => {
let mut inner = self.infcx.inner.borrow_mut();
let vid = inner.type_variables().root_var(vid);
if TermVid::Ty(vid) == self.root_vid {
Err(self.cyclic_term_error())
} else {
let probe = inner.type_variables().probe(vid);
match probe {
TypeVariableValue::Known { value: u } => {
drop(inner);
self.relate(u, u)
}
TypeVariableValue::Unknown { universe } => {
match self.ambient_variance {
ty::Invariant => {
if self.for_universe.can_name(universe) { return Ok(t); }
}
ty::Bivariant | ty::Covariant | ty::Contravariant => (),
}
let origin = inner.type_variables().var_origin(vid);
let new_var_id =
inner.type_variables().new_var(self.for_universe, origin);
inner.type_variables().sub_unify(vid, new_var_id);
if self.infcx.next_trait_solver() &&
!self.infcx.typing_mode_raw().is_coherence() &&
self.in_alias {
inner.type_variables().equate(vid, new_var_id);
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:557",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(557u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("replacing original vid={0:?} with new={1:?}",
vid, new_var_id) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
Ok(Ty::new_var(self.cx(), new_var_id))
}
}
}
}
ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) => { Ok(t) }
ty::Placeholder(placeholder) => {
if self.for_universe.can_name(placeholder.universe) {
Ok(t)
} else {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:575",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(575u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("root universe {0:?} cannot name placeholder in universe {1:?}",
self.for_universe, placeholder.universe) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};
Err(TypeError::Mismatch)
}
}
ty::Alias(ty::IsRigid::No, data) => {
self.generalize_alias_term(data.into()).map(|v|
v.expect_type())
}
_ => relate::structurally_relate_tys(self, t, t),
}?;
self.cache.insert((t, self.ambient_variance, self.in_alias),
g);
Ok(g)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:483",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(483u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self, t2), ret)]
484 fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
485 assert_eq!(t, t2); if let Some(&result) = self.cache.get(&(t, self.ambient_variance, self.in_alias)) {
488 return Ok(result);
489 }
490
491 let g = match *t.kind() {
496 ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
497 bug!("unexpected infer type: {t}")
498 }
499
500 ty::Infer(ty::TyVar(vid)) => {
501 let mut inner = self.infcx.inner.borrow_mut();
502 let vid = inner.type_variables().root_var(vid);
503 if TermVid::Ty(vid) == self.root_vid {
504 Err(self.cyclic_term_error())
507 } else {
508 let probe = inner.type_variables().probe(vid);
509 match probe {
510 TypeVariableValue::Known { value: u } => {
511 drop(inner);
512 self.relate(u, u)
513 }
514 TypeVariableValue::Unknown { universe } => {
515 match self.ambient_variance {
516 ty::Invariant => {
519 if self.for_universe.can_name(universe) {
520 return Ok(t);
521 }
522 }
523
524 ty::Bivariant | ty::Covariant | ty::Contravariant => (),
526 }
527
528 let origin = inner.type_variables().var_origin(vid);
529 let new_var_id =
530 inner.type_variables().new_var(self.for_universe, origin);
531 inner.type_variables().sub_unify(vid, new_var_id);
535 if self.infcx.next_trait_solver()
551 && !self.infcx.typing_mode_raw().is_coherence()
552 && self.in_alias
553 {
554 inner.type_variables().equate(vid, new_var_id);
555 }
556
557 debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
558 Ok(Ty::new_var(self.cx(), new_var_id))
559 }
560 }
561 }
562 }
563
564 ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) => {
565 Ok(t)
569 }
570
571 ty::Placeholder(placeholder) => {
572 if self.for_universe.can_name(placeholder.universe) {
573 Ok(t)
574 } else {
575 debug!(
576 "root universe {:?} cannot name placeholder in universe {:?}",
577 self.for_universe, placeholder.universe
578 );
579 Err(TypeError::Mismatch)
580 }
581 }
582
583 ty::Alias(ty::IsRigid::No, data) => {
586 self.generalize_alias_term(data.into()).map(|v| v.expect_type())
587 }
588
589 _ => relate::structurally_relate_tys(self, t, t),
590 }?;
591
592 self.cache.insert((t, self.ambient_variance, self.in_alias), g);
593 Ok(g)
594 }
595
596 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("regions",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(596u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("r")
}> =
::tracing::__macro_support::FieldName::new("r");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&r)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
RelateResult<'tcx, ty::Region<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
{
match (&r, &r2) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
match r.kind() {
ty::ReBound(..) | ty::ReErased => { return Ok(r); }
ty::ReError(_) => { return Ok(r); }
ty::RePlaceholder(..) | ty::ReVar(..) | ty::ReStatic |
ty::ReEarlyParam(..) | ty::ReLateParam(..) => {}
}
if let ty::Invariant = self.ambient_variance {
let r_universe = self.infcx.universe_of_region(r);
if self.for_universe.can_name(r_universe) { return Ok(r); }
}
Ok(self.infcx.next_region_var_in_universe(RegionVariableOrigin::Misc(self.span),
self.for_universe))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:596",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(596u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self, r2), ret)]
597 fn regions(
598 &mut self,
599 r: ty::Region<'tcx>,
600 r2: ty::Region<'tcx>,
601 ) -> RelateResult<'tcx, ty::Region<'tcx>> {
602 assert_eq!(r, r2); match r.kind() {
605 ty::ReBound(..) | ty::ReErased => {
608 return Ok(r);
609 }
610
611 ty::ReError(_) => {
614 return Ok(r);
615 }
616
617 ty::RePlaceholder(..)
618 | ty::ReVar(..)
619 | ty::ReStatic
620 | ty::ReEarlyParam(..)
621 | ty::ReLateParam(..) => {
622 }
624 }
625
626 if let ty::Invariant = self.ambient_variance {
630 let r_universe = self.infcx.universe_of_region(r);
631 if self.for_universe.can_name(r_universe) {
632 return Ok(r);
633 }
634 }
635
636 Ok(self
637 .infcx
638 .next_region_var_in_universe(RegionVariableOrigin::Misc(self.span), self.for_universe))
639 }
640
641 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("consts",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(641u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("c")
}> =
::tracing::__macro_support::FieldName::new("c");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&c)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
RelateResult<'tcx, ty::Const<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.cx();
{
match (&c, &c2) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
match c.kind() {
ty::ConstKind::Infer(InferConst::Var(vid)) => {
if TermVid::Const(self.infcx.inner.borrow_mut().const_unification_table().find(vid).vid)
== self.root_vid {
return Err(self.cyclic_term_error());
}
let mut inner = self.infcx.inner.borrow_mut();
let variable_table = &mut inner.const_unification_table();
match variable_table.probe_value(vid) {
ConstVariableValue::Known { value: u } => {
drop(inner);
self.relate(u, u)
}
ConstVariableValue::Unknown { origin, universe } => {
if self.for_universe.can_name(universe) {
Ok(c)
} else {
let new_var_id =
variable_table.new_key(ConstVariableValue::Unknown {
origin,
universe: self.for_universe,
}).vid;
if self.infcx.next_trait_solver() &&
!self.infcx.typing_mode_raw().is_coherence() &&
self.in_alias {
variable_table.union(vid, new_var_id);
}
Ok(ty::Const::new_var(tcx, new_var_id))
}
}
}
}
ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
if self.infcx.next_trait_solver() ||
!tcx.features().generic_const_exprs() {
self.generalize_alias_term(alias_const.into()).map(|v|
v.expect_const())
} else {
let ty::AliasConst { kind, args, .. } = alias_const;
let args =
self.relate_with_variance(ty::Invariant,
ty::VarianceDiagInfo::default(), args, args)?;
Ok(ty::Const::new_alias(tcx, ty::IsRigid::No,
ty::AliasConst::new(tcx, kind, args)))
}
}
ty::ConstKind::Placeholder(placeholder) => {
if self.for_universe.can_name(placeholder.universe) {
Ok(c)
} else {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:726",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(726u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("root universe {0:?} cannot name placeholder in universe {1:?}",
self.for_universe, placeholder.universe) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};
Err(TypeError::Mismatch)
}
}
_ => relate::structurally_relate_consts(self, c, c),
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:641",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(641u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self, c2), ret)]
642 fn consts(
643 &mut self,
644 c: ty::Const<'tcx>,
645 c2: ty::Const<'tcx>,
646 ) -> RelateResult<'tcx, ty::Const<'tcx>> {
647 let tcx = self.cx();
648 assert_eq!(c, c2); match c.kind() {
651 ty::ConstKind::Infer(InferConst::Var(vid)) => {
652 if TermVid::Const(
656 self.infcx.inner.borrow_mut().const_unification_table().find(vid).vid,
657 ) == self.root_vid
658 {
659 return Err(self.cyclic_term_error());
660 }
661
662 let mut inner = self.infcx.inner.borrow_mut();
663 let variable_table = &mut inner.const_unification_table();
664 match variable_table.probe_value(vid) {
665 ConstVariableValue::Known { value: u } => {
666 drop(inner);
667 self.relate(u, u)
668 }
669 ConstVariableValue::Unknown { origin, universe } => {
670 if self.for_universe.can_name(universe) {
671 Ok(c)
672 } else {
673 let new_var_id = variable_table
674 .new_key(ConstVariableValue::Unknown {
675 origin,
676 universe: self.for_universe,
677 })
678 .vid;
679
680 if self.infcx.next_trait_solver()
683 && !self.infcx.typing_mode_raw().is_coherence()
684 && self.in_alias
685 {
686 variable_table.union(vid, new_var_id);
687 }
688 Ok(ty::Const::new_var(tcx, new_var_id))
689 }
690 }
691 }
692 }
693 ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
702 if self.infcx.next_trait_solver() || !tcx.features().generic_const_exprs() {
706 self.generalize_alias_term(alias_const.into()).map(|v| v.expect_const())
707 } else {
708 let ty::AliasConst { kind, args, .. } = alias_const;
709 let args = self.relate_with_variance(
710 ty::Invariant,
711 ty::VarianceDiagInfo::default(),
712 args,
713 args,
714 )?;
715 Ok(ty::Const::new_alias(
716 tcx,
717 ty::IsRigid::No,
718 ty::AliasConst::new(tcx, kind, args),
719 ))
720 }
721 }
722 ty::ConstKind::Placeholder(placeholder) => {
723 if self.for_universe.can_name(placeholder.universe) {
724 Ok(c)
725 } else {
726 debug!(
727 "root universe {:?} cannot name placeholder in universe {:?}",
728 self.for_universe, placeholder.universe
729 );
730 Err(TypeError::Mismatch)
731 }
732 }
733 _ => relate::structurally_relate_consts(self, c, c),
734 }
735 }
736
737 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("binders",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(737u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("a")
}> =
::tracing::__macro_support::FieldName::new("a");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&a)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
RelateResult<'tcx, ty::Binder<'tcx, T>> = loop {};
return __tracing_attr_fake_return;
}
{
let result = self.relate(a.skip_binder(), a.skip_binder())?;
Ok(a.rebind(result))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs:737",
"rustc_infer::infer::relate::generalize",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_infer/src/infer/relate/generalize.rs"),
::tracing_core::__macro_support::Option::Some(737u32),
::tracing_core::__macro_support::Option::Some("rustc_infer::infer::relate::generalize"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
738 fn binders<T>(
739 &mut self,
740 a: ty::Binder<'tcx, T>,
741 _: ty::Binder<'tcx, T>,
742 ) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
743 where
744 T: Relate<TyCtxt<'tcx>>,
745 {
746 let result = self.relate(a.skip_binder(), a.skip_binder())?;
747 Ok(a.rebind(result))
748 }
749}
750
751#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for Generalization<T> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Generalization", "value_may_be_infer", &&self.value_may_be_infer)
}
}Debug)]
755struct Generalization<T> {
756 pub value_may_be_infer: T,
765}