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,
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_query_system::ich::StableHashingContext<'__ctx>>
for NormalizationError<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx:
&mut ::rustc_query_system::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>(self, typing_env: ty::TypingEnv<'tcx>, value: T) -> T
42 where
43 T: TypeFoldable<TyCtxt<'tcx>>,
44 {
45 debug!(
46 "normalize_erasing_regions::<{}>(value={:?}, typing_env={:?})",
47 std::any::type_name::<T>(),
48 value,
49 typing_env,
50 );
51
52 let value = self.erase_and_anonymize_regions(value);
55 debug!(?value);
56
57 if !value.has_aliases() {
58 value
59 } else {
60 value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, typing_env })
61 }
62 }
63
64 pub fn try_normalize_erasing_regions<T>(
70 self,
71 typing_env: ty::TypingEnv<'tcx>,
72 value: T,
73 ) -> Result<T, NormalizationError<'tcx>>
74 where
75 T: TypeFoldable<TyCtxt<'tcx>>,
76 {
77 {
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:77",
"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(77u32),
::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!(
78 "try_normalize_erasing_regions::<{}>(value={:?}, typing_env={:?})",
79 std::any::type_name::<T>(),
80 value,
81 typing_env,
82 );
83
84 let value = self.erase_and_anonymize_regions(value);
87 {
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:87",
"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(87u32),
::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);
88
89 if !value.has_aliases() {
90 Ok(value)
91 } else {
92 let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, typing_env);
93 value.try_fold_with(&mut folder)
94 }
95 }
96
97 #[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(108u32),
::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, value)
}
}
}#[tracing::instrument(level = "debug", skip(self, typing_env))]
109 pub fn normalize_erasing_late_bound_regions<T>(
110 self,
111 typing_env: ty::TypingEnv<'tcx>,
112 value: ty::Binder<'tcx, T>,
113 ) -> T
114 where
115 T: TypeFoldable<TyCtxt<'tcx>>,
116 {
117 let value = self.instantiate_bound_regions_with_erased(value);
118 self.normalize_erasing_regions(typing_env, value)
119 }
120
121 #[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(126u32),
::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))]
127 pub fn instantiate_and_normalize_erasing_regions<T>(
128 self,
129 param_args: GenericArgsRef<'tcx>,
130 typing_env: ty::TypingEnv<'tcx>,
131 value: EarlyBinder<'tcx, T>,
132 ) -> T
133 where
134 T: TypeFoldable<TyCtxt<'tcx>>,
135 {
136 let instantiated = value.instantiate(self, param_args);
137 self.normalize_erasing_regions(typing_env, instantiated)
138 }
139
140 #[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(144u32),
::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))]
145 pub fn try_instantiate_and_normalize_erasing_regions<T>(
146 self,
147 param_args: GenericArgsRef<'tcx>,
148 typing_env: ty::TypingEnv<'tcx>,
149 value: EarlyBinder<'tcx, T>,
150 ) -> Result<T, NormalizationError<'tcx>>
151 where
152 T: TypeFoldable<TyCtxt<'tcx>>,
153 {
154 let instantiated = value.instantiate(self, param_args);
155 self.try_normalize_erasing_regions(typing_env, instantiated)
156 }
157}
158
159struct NormalizeAfterErasingRegionsFolder<'tcx> {
160 tcx: TyCtxt<'tcx>,
161 typing_env: ty::TypingEnv<'tcx>,
162}
163
164impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
165 fn normalize_generic_arg_after_erasing_regions(
166 &self,
167 arg: ty::GenericArg<'tcx>,
168 ) -> ty::GenericArg<'tcx> {
169 let arg = self.typing_env.as_query_input(arg);
170 self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| {
171 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!(
172 "Failed to normalize {:?} in typing_env={:?}, \
173 maybe try to call `try_normalize_erasing_regions` instead",
174 arg.value,
175 self.typing_env,
176 )
177 })
178 }
179}
180
181impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> {
182 fn cx(&self) -> TyCtxt<'tcx> {
183 self.tcx
184 }
185
186 fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
187 self.normalize_generic_arg_after_erasing_regions(ty.into()).expect_ty()
188 }
189
190 fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
191 self.normalize_generic_arg_after_erasing_regions(c.into()).expect_const()
192 }
193}
194
195struct TryNormalizeAfterErasingRegionsFolder<'tcx> {
196 tcx: TyCtxt<'tcx>,
197 typing_env: ty::TypingEnv<'tcx>,
198}
199
200impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
201 fn new(tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> Self {
202 TryNormalizeAfterErasingRegionsFolder { tcx, typing_env }
203 }
204
205 #[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(205u32),
::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")]
206 fn try_normalize_generic_arg_after_erasing_regions(
207 &self,
208 arg: ty::GenericArg<'tcx>,
209 ) -> Result<ty::GenericArg<'tcx>, NoSolution> {
210 let input = self.typing_env.as_query_input(arg);
211 self.tcx.try_normalize_generic_arg_after_erasing_regions(input)
212 }
213}
214
215impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
216 type Error = NormalizationError<'tcx>;
217
218 fn cx(&self) -> TyCtxt<'tcx> {
219 self.tcx
220 }
221
222 fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
223 match self.try_normalize_generic_arg_after_erasing_regions(ty.into()) {
224 Ok(t) => Ok(t.expect_ty()),
225 Err(_) => Err(NormalizationError::Type(ty)),
226 }
227 }
228
229 fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
230 match self.try_normalize_generic_arg_after_erasing_regions(c.into()) {
231 Ok(t) => Ok(t.expect_const()),
232 Err(_) => Err(NormalizationError::Const(c)),
233 }
234 }
235}