1use rustc_macros::{StableHash, TyDecodable, TyEncodable};
11use rustc_span::bug;
12use tracing::{debug, instrument};
13
14use crate::traits::query::NoSolution;
15use crate::ty::{
16 self, EarlyBinder, FallibleTypeFolder, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeFolder,
17 TypeVisitableExt, Unnormalized,
18};
19
20#[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 {
Self::Type(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
Self::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]
#[doc(hidden)]
unsafe impl<'tcx> ::core::clone::TrivialClone for NormalizationError<'tcx> { }
#[automatically_derived]
impl<'tcx> ::core::clone::Clone for NormalizationError<'tcx> {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ty::Const<'tcx>>;
*self
}
}Clone, const _: () =
{
impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
NormalizationError<'tcx> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
NormalizationError::Type(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
NormalizationError::Const(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, 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)]
21pub enum NormalizationError<'tcx> {
22 Type(Ty<'tcx>),
23 Const(ty::Const<'tcx>),
24}
25
26impl<'tcx> NormalizationError<'tcx> {
27 pub fn get_type_for_failure(&self) -> String {
28 match self {
29 NormalizationError::Type(t) => ::alloc::__export::must_use({ ::alloc::fmt::format(format_args!("{0}", t)) })format!("{t}"),
30 NormalizationError::Const(c) => ::alloc::__export::must_use({ ::alloc::fmt::format(format_args!("{0}", c)) })format!("{c}"),
31 }
32 }
33}
34
35impl<'tcx> TyCtxt<'tcx> {
36 {}
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_regions",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(41u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(&value)
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: T = loop {};
return __tracing_attr_fake_return;
}
{
let value = value.skip_normalization();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:51",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(51u32),
::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};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("normalize_erasing_regions::<{0}>(value={1:?}, typing_env={2:?})",
std::any::type_name::<T>(), value, typing_env) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};
let value = self.erase_and_anonymize_regions(value);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:61",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(61u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(&value)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if !value.has_aliases() {
value
} else {
value.fold_with(&mut NormalizeAfterErasingRegionsFolder {
tcx: self,
typing_env,
})
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:41",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(41u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::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;#[tracing::instrument(level = "debug", skip(self, typing_env), ret)]
42 pub fn normalize_erasing_regions<T>(
43 self,
44 typing_env: ty::TypingEnv<'tcx>,
45 value: Unnormalized<'tcx, T>,
46 ) -> T
47 where
48 T: TypeFoldable<TyCtxt<'tcx>>,
49 {
50 let value = value.skip_normalization();
51 debug!(
52 "normalize_erasing_regions::<{}>(value={:?}, typing_env={:?})",
53 std::any::type_name::<T>(),
54 value,
55 typing_env,
56 );
57
58 let value = self.erase_and_anonymize_regions(value);
61 debug!(?value);
62
63 if !value.has_aliases() {
64 value
65 } else {
66 value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, typing_env })
67 }
68 }
69
70 pub fn assert_fully_normalized(
71 self,
72 typing_env: ty::TypingEnv<'tcx>,
73 value: impl TypeFoldable<TyCtxt<'tcx>> + Eq,
74 ) {
75 let value = self.erase_and_anonymize_regions(value);
76 if value.has_aliases() {
77 {
match (&value.clone(),
&value.fold_with(&mut NormalizeAfterErasingRegionsFolder {
tcx: self,
typing_env,
})) {
(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);
}
}
}
}assert_eq!(
78 value.clone(),
79 value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, typing_env })
80 )
81 }
82 }
83
84 pub fn debug_assert_fully_normalized(
85 self,
86 typing_env: ty::TypingEnv<'tcx>,
87 value: impl TypeFoldable<TyCtxt<'tcx>> + Eq,
88 ) {
89 if truecfg!(debug_assertions) {
90 self.assert_fully_normalized(typing_env, value);
91 }
92 }
93
94 pub fn try_normalize_erasing_regions<T>(
100 self,
101 typing_env: ty::TypingEnv<'tcx>,
102 value: Unnormalized<'tcx, T>,
103 ) -> Result<T, NormalizationError<'tcx>>
104 where
105 T: TypeFoldable<TyCtxt<'tcx>>,
106 {
107 let value = value.skip_normalization();
108 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:108",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/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(&["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!("try_normalize_erasing_regions::<{0}>(value={1:?}, typing_env={2:?})",
std::any::type_name::<T>(), value, typing_env) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
109 "try_normalize_erasing_regions::<{}>(value={:?}, typing_env={:?})",
110 std::any::type_name::<T>(),
111 value,
112 typing_env,
113 );
114
115 let value = self.erase_and_anonymize_regions(value);
118 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:118",
"rustc_middle::ty::normalize_erasing_regions",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(118u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(&value)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?value);
119
120 if !value.has_aliases() {
121 Ok(value)
122 } else {
123 let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, typing_env);
124 value.try_fold_with(&mut folder)
125 }
126 }
127
128 {}
#[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("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(139u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(&value)
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: 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))]
140 pub fn normalize_erasing_late_bound_regions<T>(
141 self,
142 typing_env: ty::TypingEnv<'tcx>,
143 value: ty::Binder<'tcx, T>,
144 ) -> T
145 where
146 T: TypeFoldable<TyCtxt<'tcx>>,
147 {
148 let value = self.instantiate_bound_regions_with_erased(value);
149 self.normalize_erasing_regions(typing_env, Unnormalized::new_wip(value))
150 }
151
152 {}
#[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("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(157u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("param_args")
}> =
::tracing::__macro_support::FieldName::new("param_args");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("typing_env")
}> =
::tracing::__macro_support::FieldName::new("typing_env");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(¶m_args)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&typing_env)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
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: 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))]
158 pub fn instantiate_and_normalize_erasing_regions<T>(
159 self,
160 param_args: GenericArgsRef<'tcx>,
161 typing_env: ty::TypingEnv<'tcx>,
162 value: EarlyBinder<'tcx, T>,
163 ) -> T
164 where
165 T: TypeFoldable<TyCtxt<'tcx>>,
166 {
167 let instantiated = value.instantiate(self, param_args);
168 self.normalize_erasing_regions(typing_env, instantiated)
169 }
170
171 {}
#[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("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(175u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("param_args")
}> =
::tracing::__macro_support::FieldName::new("param_args");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("typing_env")
}> =
::tracing::__macro_support::FieldName::new("typing_env");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(¶m_args)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&typing_env)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&value)
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:
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))]
176 pub fn try_instantiate_and_normalize_erasing_regions<T>(
177 self,
178 param_args: GenericArgsRef<'tcx>,
179 typing_env: ty::TypingEnv<'tcx>,
180 value: EarlyBinder<'tcx, T>,
181 ) -> Result<T, NormalizationError<'tcx>>
182 where
183 T: TypeFoldable<TyCtxt<'tcx>>,
184 {
185 let instantiated = value.instantiate(self, param_args);
186 self.try_normalize_erasing_regions(typing_env, instantiated)
187 }
188}
189
190struct NormalizeAfterErasingRegionsFolder<'tcx> {
191 tcx: TyCtxt<'tcx>,
192 typing_env: ty::TypingEnv<'tcx>,
193}
194
195impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
196 fn normalize_generic_arg_after_erasing_regions(
197 &self,
198 arg: ty::GenericArg<'tcx>,
199 ) -> ty::GenericArg<'tcx> {
200 let arg = self.typing_env.as_query_input(arg);
201 self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| {
202 ::rustc_span::macros::bug_impl(None,
format_args!("Failed to normalize {0:?} in typing_env={1:?}, maybe try to call `try_normalize_erasing_regions` instead",
arg.value, self.typing_env), Location::caller())bug!(
203 "Failed to normalize {:?} in typing_env={:?}, \
204 maybe try to call `try_normalize_erasing_regions` instead",
205 arg.value,
206 self.typing_env,
207 )
208 })
209 }
210}
211
212impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> {
213 fn cx(&self) -> TyCtxt<'tcx> {
214 self.tcx
215 }
216
217 fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
218 self.normalize_generic_arg_after_erasing_regions(ty.into()).expect_ty()
219 }
220
221 fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
222 self.normalize_generic_arg_after_erasing_regions(c.into()).expect_const()
223 }
224}
225
226struct TryNormalizeAfterErasingRegionsFolder<'tcx> {
227 tcx: TyCtxt<'tcx>,
228 typing_env: ty::TypingEnv<'tcx>,
229}
230
231impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
232 fn new(tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> Self {
233 TryNormalizeAfterErasingRegionsFolder { tcx, typing_env }
234 }
235
236 {}
#[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("/rustc-dev/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs"),
::tracing_core::__macro_support::Option::Some(236u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty::normalize_erasing_regions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("arg")
}> =
::tracing::__macro_support::FieldName::new("arg");
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(&arg)
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:
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")]
237 fn try_normalize_generic_arg_after_erasing_regions(
238 &self,
239 arg: ty::GenericArg<'tcx>,
240 ) -> Result<ty::GenericArg<'tcx>, NoSolution> {
241 let input = self.typing_env.as_query_input(arg);
242 self.tcx.try_normalize_generic_arg_after_erasing_regions(input)
243 }
244}
245
246impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
247 type Error = NormalizationError<'tcx>;
248
249 fn cx(&self) -> TyCtxt<'tcx> {
250 self.tcx
251 }
252
253 fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
254 match self.try_normalize_generic_arg_after_erasing_regions(ty.into()) {
255 Ok(t) => Ok(t.expect_ty()),
256 Err(_) => Err(NormalizationError::Type(ty)),
257 }
258 }
259
260 fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
261 match self.try_normalize_generic_arg_after_erasing_regions(c.into()) {
262 Ok(t) => Ok(t.expect_const()),
263 Err(_) => Err(NormalizationError::Const(c)),
264 }
265 }
266}