1use rustc_macros::{HashStable, TyDecodable, TyEncodable};
11use tracing::{debug, instrument};
12
13use crate::traits::query::NoSolution;
14use crate::ty::{
15 self, EarlyBinder, FallibleTypeFolder, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeFolder,
16 TypeVisitableExt, Unnormalized,
17};
18
19#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for NormalizationError<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
NormalizationError::Type(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
NormalizationError::Const(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for NormalizationError<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for NormalizationError<'tcx> {
#[inline]
fn clone(&self) -> NormalizationError<'tcx> {
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ty::Const<'tcx>>;
*self
}
}Clone, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for NormalizationError<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
NormalizationError::Type(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
NormalizationError::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for NormalizationError<'tcx> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
NormalizationError::Type(ref __binding_0) => { 0usize }
NormalizationError::Const(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
NormalizationError::Type(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
NormalizationError::Const(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for NormalizationError<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
NormalizationError::Type(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
NormalizationError::Const(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `NormalizationError`, expected 0..2, actual {0}",
n));
}
}
}
}
};TyDecodable)]
20pub enum NormalizationError<'tcx> {
21 Type(Ty<'tcx>),
22 Const(ty::Const<'tcx>),
23}
24
25impl<'tcx> NormalizationError<'tcx> {
26 pub fn get_type_for_failure(&self) -> String {
27 match self {
28 NormalizationError::Type(t) => ::alloc::__export::must_use({ ::alloc::fmt::format(format_args!("{0}", t)) })format!("{t}"),
29 NormalizationError::Const(c) => ::alloc::__export::must_use({ ::alloc::fmt::format(format_args!("{0}", c)) })format!("{c}"),
30 }
31 }
32}
33
34impl<'tcx> TyCtxt<'tcx> {
35 x;#[tracing::instrument(level = "debug", skip(self, typing_env), ret)]
41 pub fn normalize_erasing_regions<T>(
42 self,
43 typing_env: ty::TypingEnv<'tcx>,
44 value: Unnormalized<'tcx, T>,
45 ) -> T
46 where
47 T: TypeFoldable<TyCtxt<'tcx>>,
48 {
49 let value = value.skip_normalization();
50 debug!(
51 "normalize_erasing_regions::<{}>(value={:?}, typing_env={:?})",
52 std::any::type_name::<T>(),
53 value,
54 typing_env,
55 );
56
57 let value = self.erase_and_anonymize_regions(value);
60 debug!(?value);
61
62 if !value.has_aliases() {
63 value
64 } else {
65 value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, typing_env })
66 }
67 }
68
69 pub fn try_normalize_erasing_regions<T>(
75 self,
76 typing_env: ty::TypingEnv<'tcx>,
77 value: Unnormalized<'tcx, T>,
78 ) -> Result<T, NormalizationError<'tcx>>
79 where
80 T: TypeFoldable<TyCtxt<'tcx>>,
81 {
82 let value = value.skip_normalization();
83 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:83",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(83u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_normalize_erasing_regions::<{0}>(value={1:?}, typing_env={2:?})",
std::any::type_name::<T>(), value, typing_env) as
&dyn Value))])
});
} else { ; }
};debug!(
84 "try_normalize_erasing_regions::<{}>(value={:?}, typing_env={:?})",
85 std::any::type_name::<T>(),
86 value,
87 typing_env,
88 );
89
90 let value = self.erase_and_anonymize_regions(value);
93 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:93",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(93u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&["value"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&value) as
&dyn Value))])
});
} else { ; }
};debug!(?value);
94
95 if !value.has_aliases() {
96 Ok(value)
97 } else {
98 let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, typing_env);
99 value.try_fold_with(&mut folder)
100 }
101 }
102
103 #[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("normalize_erasing_late_bound_regions",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(114u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&["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::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(&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: T = loop {};
return __tracing_attr_fake_return;
}
{
let value = self.instantiate_bound_regions_with_erased(value);
self.normalize_erasing_regions(typing_env,
Unnormalized::new_wip(value))
}
}
}#[tracing::instrument(level = "debug", skip(self, typing_env))]
115 pub fn normalize_erasing_late_bound_regions<T>(
116 self,
117 typing_env: ty::TypingEnv<'tcx>,
118 value: ty::Binder<'tcx, T>,
119 ) -> T
120 where
121 T: TypeFoldable<TyCtxt<'tcx>>,
122 {
123 let value = self.instantiate_bound_regions_with_erased(value);
124 self.normalize_erasing_regions(typing_env, Unnormalized::new_wip(value))
125 }
126
127 #[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_and_normalize_erasing_regions",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(132u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&["param_args",
"typing_env", "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::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(¶m_args)
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(&typing_env)
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: T = loop {};
return __tracing_attr_fake_return;
}
{
let instantiated = value.instantiate(self, param_args);
self.normalize_erasing_regions(typing_env, instantiated)
}
}
}#[instrument(level = "debug", skip(self))]
133 pub fn instantiate_and_normalize_erasing_regions<T>(
134 self,
135 param_args: GenericArgsRef<'tcx>,
136 typing_env: ty::TypingEnv<'tcx>,
137 value: EarlyBinder<'tcx, T>,
138 ) -> T
139 where
140 T: TypeFoldable<TyCtxt<'tcx>>,
141 {
142 let instantiated = value.instantiate(self, param_args);
143 self.normalize_erasing_regions(typing_env, instantiated)
144 }
145
146 #[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("try_instantiate_and_normalize_erasing_regions",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(150u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&["param_args",
"typing_env", "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::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(¶m_args)
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(&typing_env)
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:
Result<T, NormalizationError<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
let instantiated = value.instantiate(self, param_args);
self.try_normalize_erasing_regions(typing_env, instantiated)
}
}
}#[instrument(level = "debug", skip(self))]
151 pub fn try_instantiate_and_normalize_erasing_regions<T>(
152 self,
153 param_args: GenericArgsRef<'tcx>,
154 typing_env: ty::TypingEnv<'tcx>,
155 value: EarlyBinder<'tcx, T>,
156 ) -> Result<T, NormalizationError<'tcx>>
157 where
158 T: TypeFoldable<TyCtxt<'tcx>>,
159 {
160 let instantiated = value.instantiate(self, param_args);
161 self.try_normalize_erasing_regions(typing_env, instantiated)
162 }
163}
164
165struct NormalizeAfterErasingRegionsFolder<'tcx> {
166 tcx: TyCtxt<'tcx>,
167 typing_env: ty::TypingEnv<'tcx>,
168}
169
170impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
171 fn normalize_generic_arg_after_erasing_regions(
172 &self,
173 arg: ty::GenericArg<'tcx>,
174 ) -> ty::GenericArg<'tcx> {
175 let arg = self.typing_env.as_query_input(arg);
176 self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| {
177 crate::util::bug::bug_fmt(format_args!("Failed to normalize {0:?} in typing_env={1:?}, maybe try to call `try_normalize_erasing_regions` instead",
arg.value, self.typing_env))bug!(
178 "Failed to normalize {:?} in typing_env={:?}, \
179 maybe try to call `try_normalize_erasing_regions` instead",
180 arg.value,
181 self.typing_env,
182 )
183 })
184 }
185}
186
187impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> {
188 fn cx(&self) -> TyCtxt<'tcx> {
189 self.tcx
190 }
191
192 fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
193 self.normalize_generic_arg_after_erasing_regions(ty.into()).expect_ty()
194 }
195
196 fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
197 self.normalize_generic_arg_after_erasing_regions(c.into()).expect_const()
198 }
199}
200
201struct TryNormalizeAfterErasingRegionsFolder<'tcx> {
202 tcx: TyCtxt<'tcx>,
203 typing_env: ty::TypingEnv<'tcx>,
204}
205
206impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
207 fn new(tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> Self {
208 TryNormalizeAfterErasingRegionsFolder { tcx, typing_env }
209 }
210
211 #[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("try_normalize_generic_arg_after_erasing_regions",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(211u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&["arg"],
::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(&arg)
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:
Result<ty::GenericArg<'tcx>, NoSolution> = loop {};
return __tracing_attr_fake_return;
}
{
let input = self.typing_env.as_query_input(arg);
self.tcx.try_normalize_generic_arg_after_erasing_regions(input)
}
}
}#[instrument(skip(self), level = "debug")]
212 fn try_normalize_generic_arg_after_erasing_regions(
213 &self,
214 arg: ty::GenericArg<'tcx>,
215 ) -> Result<ty::GenericArg<'tcx>, NoSolution> {
216 let input = self.typing_env.as_query_input(arg);
217 self.tcx.try_normalize_generic_arg_after_erasing_regions(input)
218 }
219}
220
221impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
222 type Error = NormalizationError<'tcx>;
223
224 fn cx(&self) -> TyCtxt<'tcx> {
225 self.tcx
226 }
227
228 fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
229 match self.try_normalize_generic_arg_after_erasing_regions(ty.into()) {
230 Ok(t) => Ok(t.expect_ty()),
231 Err(_) => Err(NormalizationError::Type(ty)),
232 }
233 }
234
235 fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
236 match self.try_normalize_generic_arg_after_erasing_regions(c.into()) {
237 Ok(t) => Ok(t.expect_const()),
238 Err(_) => Err(NormalizationError::Const(c)),
239 }
240 }
241}