1use rustc_data_structures::fx::FxHashSet;
2use rustc_hir::def::DefKind;
3use rustc_hir::def_id::LocalDefId;
4use rustc_hir::intravisit;
5use rustc_hir::intravisit::Visitor;
6use rustc_middle::query::Providers;
7use rustc_middle::ty::util::{CheckRegions, NotUniqueParam};
8use rustc_middle::ty::{
9 self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, Unnormalized,
10};
11use rustc_span::{Span, bug, span_bug};
12use tracing::{instrument, trace};
13
14use crate::diagnostics::{DuplicateArg, NotParam};
15
16struct OpaqueTypeCollector<'tcx> {
17 tcx: TyCtxt<'tcx>,
18 opaques: Vec<LocalDefId>,
19 item: LocalDefId,
21
22 seen: FxHashSet<LocalDefId>,
24
25 span: Option<Span>,
26
27 mode: CollectionMode,
28}
29
30enum CollectionMode {
31 ImplTraitInAssocTypes,
34 Taits,
36 RpitAndAsyncFnOnly,
38}
39
40impl<'tcx> OpaqueTypeCollector<'tcx> {
41 fn new(tcx: TyCtxt<'tcx>, item: LocalDefId) -> Self {
42 let mode = match tcx.def_kind(item) {
43 DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => {
44 CollectionMode::ImplTraitInAssocTypes
45 }
46 DefKind::TyAlias => CollectionMode::Taits,
47 _ => CollectionMode::RpitAndAsyncFnOnly,
48 };
49 Self { tcx, opaques: Vec::new(), item, seen: Default::default(), span: None, mode }
50 }
51
52 fn span(&self) -> Span {
53 self.span.unwrap_or_else(|| {
54 self.tcx.def_ident_span(self.item).unwrap_or_else(|| self.tcx.def_span(self.item))
55 })
56 }
57
58 fn visit_spanned(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) {
59 let old = self.span;
60 self.span = Some(span);
61 value.visit_with(self);
62 self.span = old;
63 }
64
65 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("collect_taits_declared_in_body",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(65u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set_all(&[]) })
} 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: () = loop {};
return __tracing_attr_fake_return;
}
{
let Some(body) =
self.tcx.hir_maybe_body_owned_by(self.item) else { return; };
let body = &body.value;
struct TaitInBodyFinder<'a, 'tcx> {
collector: &'a mut OpaqueTypeCollector<'tcx>,
}
impl<'v> intravisit::Visitor<'v> for TaitInBodyFinder<'_, '_> {
fn visit_nested_item(&mut self, id: rustc_hir::ItemId) {
{}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("visit_nested_item",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(75u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("id")
}> =
::tracing::__macro_support::FieldName::new("id");
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::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id)
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: () = loop {};
return __tracing_attr_fake_return;
}
{
let id = id.owner_id.def_id;
if let DefKind::TyAlias = self.collector.tcx.def_kind(id) {
let items = self.collector.tcx.opaque_types_defined_by(id);
self.collector.opaques.extend(items);
}
}
}
}
}
fn visit_nested_body(&mut self, id: rustc_hir::BodyId) {
{}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("visit_nested_body",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(83u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("id")
}> =
::tracing::__macro_support::FieldName::new("id");
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::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id)
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: () = loop {};
return __tracing_attr_fake_return;
}
{
let body = self.collector.tcx.hir_body(id);
self.visit_body(body);
}
}
}
}
}
TaitInBodyFinder { collector: self }.visit_expr(body);
}
}
}#[instrument(level = "trace", skip(self))]
66 fn collect_taits_declared_in_body(&mut self) {
67 let Some(body) = self.tcx.hir_maybe_body_owned_by(self.item) else {
68 return;
69 };
70 let body = &body.value;
71 struct TaitInBodyFinder<'a, 'tcx> {
72 collector: &'a mut OpaqueTypeCollector<'tcx>,
73 }
74 impl<'v> intravisit::Visitor<'v> for TaitInBodyFinder<'_, '_> {
75 #[instrument(level = "trace", skip(self))]
76 fn visit_nested_item(&mut self, id: rustc_hir::ItemId) {
77 let id = id.owner_id.def_id;
78 if let DefKind::TyAlias = self.collector.tcx.def_kind(id) {
79 let items = self.collector.tcx.opaque_types_defined_by(id);
80 self.collector.opaques.extend(items);
81 }
82 }
83 #[instrument(level = "trace", skip(self))]
84 fn visit_nested_body(&mut self, id: rustc_hir::BodyId) {
86 let body = self.collector.tcx.hir_body(id);
87 self.visit_body(body);
88 }
89 }
90 TaitInBodyFinder { collector: self }.visit_expr(body);
91 }
92
93 {}
#[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("visit_opaque_ty",
"rustc_ty_utils::opaque_types", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(93u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("alias_ty")
}> =
::tracing::__macro_support::FieldName::new("alias_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(&::tracing::field::debug(&alias_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: () = loop {};
return __tracing_attr_fake_return;
}
{
let ty::Opaque { def_id } =
alias_ty.kind else {
::rustc_span::macros::bug_impl(None,
format_args!("{0:?}", alias_ty), Location::caller())
};
if !self.seen.insert(def_id.expect_local()) { return; }
match self.tcx.local_opaque_ty_origin(def_id.expect_local()) {
rustc_hir::OpaqueTyOrigin::FnReturn { .. } |
rustc_hir::OpaqueTyOrigin::AsyncFn { .. } => {}
rustc_hir::OpaqueTyOrigin::TyAlias { in_assoc_ty, .. } =>
match self.mode {
CollectionMode::ImplTraitInAssocTypes => {
if !in_assoc_ty { return; }
}
CollectionMode::Taits => { if in_assoc_ty { return; } }
CollectionMode::RpitAndAsyncFnOnly => return,
},
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:126",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(126u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("alias_ty")
}> =
::tracing::__macro_support::FieldName::new("alias_ty");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::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!("adding")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&alias_ty)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.opaques.push(def_id.expect_local());
let parent_count = self.tcx.generics_of(def_id).parent_count;
match self.tcx.uses_unique_generic_params(&alias_ty.args[..parent_count],
CheckRegions::FromFunction) {
Ok(()) => {
for (pred, span) in
self.tcx.explicit_item_bounds(def_id).iter_identity_copied().map(Unnormalized::skip_norm_wip)
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:151",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(151u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("pred")
}> =
::tracing::__macro_support::FieldName::new("pred");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::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(&pred)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.visit_spanned(span, pred);
}
}
Err(NotUniqueParam::NotParam(arg)) => {
self.tcx.dcx().emit_err(NotParam {
arg,
span: self.span(),
opaque_span: self.tcx.def_span(def_id),
});
}
Err(NotUniqueParam::DuplicateParam(arg)) => {
self.tcx.dcx().emit_err(DuplicateArg {
arg,
span: self.span(),
opaque_span: self.tcx.def_span(def_id),
});
}
}
}
}
}#[instrument(level = "debug", skip(self))]
94 fn visit_opaque_ty(&mut self, alias_ty: ty::AliasTy<'tcx>) {
95 let ty::Opaque { def_id } = alias_ty.kind else { bug!("{alias_ty:?}") };
96
97 if !self.seen.insert(def_id.expect_local()) {
98 return;
99 }
100
101 match self.tcx.local_opaque_ty_origin(def_id.expect_local()) {
103 rustc_hir::OpaqueTyOrigin::FnReturn { .. }
104 | rustc_hir::OpaqueTyOrigin::AsyncFn { .. } => {}
105 rustc_hir::OpaqueTyOrigin::TyAlias { in_assoc_ty, .. } => match self.mode {
106 CollectionMode::ImplTraitInAssocTypes => {
110 if !in_assoc_ty {
111 return;
112 }
113 }
114 CollectionMode::Taits => {
118 if in_assoc_ty {
119 return;
120 }
121 }
122 CollectionMode::RpitAndAsyncFnOnly => return,
123 },
124 }
125
126 trace!(?alias_ty, "adding");
127 self.opaques.push(def_id.expect_local());
128
129 let parent_count = self.tcx.generics_of(def_id).parent_count;
130 match self
134 .tcx
135 .uses_unique_generic_params(&alias_ty.args[..parent_count], CheckRegions::FromFunction)
136 {
137 Ok(()) => {
138 for (pred, span) in self
146 .tcx
147 .explicit_item_bounds(def_id)
148 .iter_identity_copied()
149 .map(Unnormalized::skip_norm_wip)
150 {
151 trace!(?pred);
152 self.visit_spanned(span, pred);
153 }
154 }
155 Err(NotUniqueParam::NotParam(arg)) => {
156 self.tcx.dcx().emit_err(NotParam {
157 arg,
158 span: self.span(),
159 opaque_span: self.tcx.def_span(def_id),
160 });
161 }
162 Err(NotUniqueParam::DuplicateParam(arg)) => {
163 self.tcx.dcx().emit_err(DuplicateArg {
164 arg,
165 span: self.span(),
166 opaque_span: self.tcx.def_span(def_id),
167 });
168 }
169 }
170 }
171
172 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("collect_taits_from_defines_attr",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(174u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set_all(&[]) })
} 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: () = loop {};
return __tracing_attr_fake_return;
}
{
let hir_id = self.tcx.local_def_id_to_hir_id(self.item);
if !hir_id.is_owner() { return; }
let Some(defines) =
self.tcx.hir_attr_map(hir_id.owner).define_opaque else {
return;
};
for &(span, define) in defines {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:184",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(184u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("define")
}> =
::tracing::__macro_support::FieldName::new("define");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::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(&define)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let mode =
std::mem::replace(&mut self.mode, CollectionMode::Taits);
let n = self.opaques.len();
rustc_ty_walk::walk_types(self.tcx, define, self);
if n == self.opaques.len() {
self.tcx.dcx().span_err(span,
"item does not contain any opaque types");
}
self.mode = mode;
}
self.mode = CollectionMode::RpitAndAsyncFnOnly;
}
}
}#[instrument(level = "trace", skip(self))]
175 fn collect_taits_from_defines_attr(&mut self) {
176 let hir_id = self.tcx.local_def_id_to_hir_id(self.item);
177 if !hir_id.is_owner() {
178 return;
179 }
180 let Some(defines) = self.tcx.hir_attr_map(hir_id.owner).define_opaque else {
181 return;
182 };
183 for &(span, define) in defines {
184 trace!(?define);
185 let mode = std::mem::replace(&mut self.mode, CollectionMode::Taits);
186 let n = self.opaques.len();
187 rustc_ty_walk::walk_types(self.tcx, define, self);
188 if n == self.opaques.len() {
189 self.tcx.dcx().span_err(span, "item does not contain any opaque types");
190 }
191 self.mode = mode;
192 }
193 self.mode = CollectionMode::RpitAndAsyncFnOnly;
196 }
197}
198
199impl<'tcx> rustc_ty_walk::SpannedTypeVisitor<'tcx> for OpaqueTypeCollector<'tcx> {
200 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("visit",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(200u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("span")
}> =
::tracing::__macro_support::FieldName::new("span");
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::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
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();
}
#[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: () = loop {};
return __tracing_attr_fake_return;
}
{ self.visit_spanned(span, 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/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:200",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(200u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::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(skip(self), ret, level = "trace")]
201 fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) {
202 self.visit_spanned(span, value);
203 }
204}
205
206impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
207 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("visit_ty",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(207u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::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::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
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: () = loop {};
return __tracing_attr_fake_return;
}
{
t.super_visit_with(self);
match *t.kind() {
ty::Alias(_, alias_ty @ ty::AliasTy {
kind: ty::Opaque { def_id }, .. }) if def_id.is_local() => {
self.visit_opaque_ty(alias_ty);
}
ty::Alias(_, ty::AliasTy { kind: ty::Free { def_id }, args,
.. }) if let Some(def_id) = def_id.as_local() => {
if !self.seen.insert(def_id) { return; }
self.tcx.type_of(def_id).instantiate(self.tcx,
args).skip_norm_wip().visit_with(self);
}
ty::Alias(_, alias_ty @ ty::AliasTy {
kind: ty::Projection { def_id: alias_def_id }, .. }) => {
if let Some(parent) =
self.tcx.trait_impl_of_assoc(self.item.to_def_id()) {
let impl_trait_ref =
self.tcx.impl_trait_ref(parent).instantiate_identity().skip_norm_wip();
if alias_ty.trait_ref(self.tcx) == impl_trait_ref {
for &assoc in
self.tcx.associated_items(parent).in_definition_order() {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:245",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(245u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assoc")
}> =
::tracing::__macro_support::FieldName::new("assoc");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::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(&assoc)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if assoc.expect_trait_impl() != Ok(alias_def_id) {
continue;
}
if !assoc.defaultness(self.tcx).is_final() { continue; }
if !self.seen.insert(assoc.def_id.expect_local()) {
return;
}
let alias_args =
alias_ty.args.rebase_onto(self.tcx, impl_trait_ref.def_id,
ty::GenericArgs::identity_for_item(self.tcx, parent));
if self.tcx.check_args_compatible(assoc.def_id, alias_args)
{
self.tcx.type_of(assoc.def_id).instantiate(self.tcx,
alias_args).skip_norm_wip().visit_with(self);
return;
} else {
self.tcx.dcx().span_delayed_bug(self.tcx.def_span(assoc.def_id),
"item had incorrect args");
}
}
}
} else if let Some(ty::ImplTraitInTraitData::Trait {
fn_def_id, .. }) = self.tcx.opt_rpitit_info(alias_def_id) &&
fn_def_id == self.item.into() {
let ty =
self.tcx.type_of(alias_def_id).instantiate(self.tcx,
alias_ty.args).skip_norm_wip();
let ty::Alias(_, alias_ty @ ty::AliasTy {
kind: ty::Opaque { .. }, .. }) =
*ty.kind() else {
::rustc_span::macros::bug_impl(None,
format_args!("{0:?}", ty), Location::caller())
};
self.visit_opaque_ty(alias_ty);
}
}
_ => {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:309",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(309u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("kind")
}> =
::tracing::__macro_support::FieldName::new("kind");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::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(&t.kind())
as &dyn ::tracing::field::Value))])
});
} 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/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:207",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(207u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::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(skip(self), ret, level = "trace")]
208 fn visit_ty(&mut self, t: Ty<'tcx>) {
209 t.super_visit_with(self);
210 match *t.kind() {
211 ty::Alias(_, alias_ty @ ty::AliasTy { kind: ty::Opaque { def_id }, .. })
212 if def_id.is_local() =>
213 {
214 self.visit_opaque_ty(alias_ty);
215 }
216 ty::Alias(_, ty::AliasTy { kind: ty::Free { def_id }, args, .. })
219 if let Some(def_id) = def_id.as_local() =>
220 {
221 if !self.seen.insert(def_id) {
222 return;
223 }
224 self.tcx
225 .type_of(def_id)
226 .instantiate(self.tcx, args)
227 .skip_norm_wip()
228 .visit_with(self);
229 }
230 ty::Alias(
231 _,
232 alias_ty @ ty::AliasTy { kind: ty::Projection { def_id: alias_def_id }, .. },
233 ) => {
234 if let Some(parent) = self.tcx.trait_impl_of_assoc(self.item.to_def_id()) {
238 let impl_trait_ref =
239 self.tcx.impl_trait_ref(parent).instantiate_identity().skip_norm_wip();
240 if alias_ty.trait_ref(self.tcx) == impl_trait_ref {
244 for &assoc in self.tcx.associated_items(parent).in_definition_order() {
245 trace!(?assoc);
246 if assoc.expect_trait_impl() != Ok(alias_def_id) {
247 continue;
248 }
249
250 if !assoc.defaultness(self.tcx).is_final() {
253 continue;
254 }
255
256 if !self.seen.insert(assoc.def_id.expect_local()) {
257 return;
258 }
259
260 let alias_args = alias_ty.args.rebase_onto(
261 self.tcx,
262 impl_trait_ref.def_id,
263 ty::GenericArgs::identity_for_item(self.tcx, parent),
264 );
265
266 if self.tcx.check_args_compatible(assoc.def_id, alias_args) {
267 self.tcx
268 .type_of(assoc.def_id)
269 .instantiate(self.tcx, alias_args)
270 .skip_norm_wip()
271 .visit_with(self);
272 return;
273 } else {
274 self.tcx.dcx().span_delayed_bug(
275 self.tcx.def_span(assoc.def_id),
276 "item had incorrect args",
277 );
278 }
279 }
280 }
281 } else if let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) =
282 self.tcx.opt_rpitit_info(alias_def_id)
283 && fn_def_id == self.item.into()
284 {
285 let ty = self
297 .tcx
298 .type_of(alias_def_id)
299 .instantiate(self.tcx, alias_ty.args)
300 .skip_norm_wip();
301 let ty::Alias(_, alias_ty @ ty::AliasTy { kind: ty::Opaque { .. }, .. }) =
302 *ty.kind()
303 else {
304 bug!("{ty:?}")
305 };
306 self.visit_opaque_ty(alias_ty);
307 }
308 }
309 _ => trace!(kind=?t.kind()),
310 }
311 }
312}
313
314fn opaque_types_defined_by<'tcx>(
315 tcx: TyCtxt<'tcx>,
316 item: LocalDefId,
317) -> &'tcx ty::List<LocalDefId> {
318 if tcx.is_typeck_child(item.to_def_id()) {
323 return tcx.opaque_types_defined_by(tcx.local_parent(item));
324 }
325
326 if tcx.hir_opt_delegation_sig_id(item).is_some() {
328 return tcx.mk_local_def_ids(&[]);
329 }
330
331 let kind = tcx.def_kind(item);
332 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs:332",
"rustc_ty_utils::opaque_types", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_ty_utils/src/opaque_types.rs"),
::tracing_core::__macro_support::Option::Some(332u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::opaque_types"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("kind")
}> =
::tracing::__macro_support::FieldName::new("kind");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::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(&kind)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};trace!(?kind);
333 let mut collector = OpaqueTypeCollector::new(tcx, item);
334 collector.collect_taits_from_defines_attr();
335 rustc_ty_walk::walk_types(tcx, item, &mut collector);
336
337 match kind {
338 DefKind::AssocFn
339 | DefKind::Fn
340 | DefKind::Static { .. }
341 | DefKind::Const
342 | DefKind::AssocConst
343 | DefKind::AnonConst => {
344 if true {
if !(kind != DefKind::AnonConst ||
tcx.anon_const_kind(item) !=
ty::AnonConstKind::NonTypeSystemInline) {
::core::panicking::panic("assertion failed: kind != DefKind::AnonConst ||\n tcx.anon_const_kind(item) != ty::AnonConstKind::NonTypeSystemInline")
};
};debug_assert!(
346 kind != DefKind::AnonConst
347 || tcx.anon_const_kind(item) != ty::AnonConstKind::NonTypeSystemInline
348 );
349
350 collector.collect_taits_declared_in_body();
351 }
352 DefKind::AssocTy | DefKind::TyAlias | DefKind::GlobalAsm => {}
353 DefKind::OpaqueTy
354 | DefKind::Mod
355 | DefKind::Struct
356 | DefKind::Union
357 | DefKind::Enum
358 | DefKind::Variant
359 | DefKind::Trait
360 | DefKind::ForeignTy
361 | DefKind::TraitAlias
362 | DefKind::Closure
363 | DefKind::SyntheticCoroutineBody
364 | DefKind::TyParam
365 | DefKind::ConstParam
366 | DefKind::Ctor(_, _)
367 | DefKind::Macro(_)
368 | DefKind::ExternCrate
369 | DefKind::Use
370 | DefKind::ForeignMod
371 | DefKind::Field
372 | DefKind::LifetimeParam
373 | DefKind::Impl { .. }
374 | DefKind::TestBinderConstraints => {
375 ::rustc_span::macros::bug_impl(Some(tcx.def_span(item)),
format_args!("`opaque_types_defined_by` not defined for {0} `{1:?}`",
kind.descr(item.to_def_id()), item), Location::caller());span_bug!(
376 tcx.def_span(item),
377 "`opaque_types_defined_by` not defined for {} `{item:?}`",
378 kind.descr(item.to_def_id())
379 );
380 }
381 }
382 tcx.mk_local_def_ids(&collector.opaques)
383}
384
385pub(super) fn provide(providers: &mut Providers) {
386 *providers = Providers { opaque_types_defined_by, ..*providers };
387}