1use rustc_data_structures::fx::FxHashSet;
4use rustc_hir::def_id::DefId;
5use rustc_hir::find_attr;
6use rustc_middle::bug;
7use rustc_middle::query::Providers;
8use rustc_middle::ty::util::{AlwaysRequiresDrop, needs_drop_components};
9use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt, Unnormalized};
10use rustc_structures::Limit;
11use tracing::{debug, instrument};
12
13use crate::diagnostics::NeedsDropOverflow;
14
15type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>;
16
17fn needs_drop_raw<'tcx>(
18 tcx: TyCtxt<'tcx>,
19 query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
20) -> bool {
21 let adt_has_dtor =
25 |adt_def: ty::AdtDef<'tcx>| adt_def.destructor(tcx).map(|_| DtorType::Significant);
26 let res = drop_tys_helper(
27 tcx,
28 query.value,
29 query.typing_env,
30 adt_has_dtor,
31 DropTysOptions::default(),
32 )
33 .filter(filter_array_elements(tcx, query.typing_env))
34 .next()
35 .is_some();
36
37 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:37",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(37u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("needs_drop_raw({0:?}) = {1:?}",
query, res) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("needs_drop_raw({:?}) = {:?}", query, res);
38 res
39}
40
41fn needs_async_drop_raw<'tcx>(
42 tcx: TyCtxt<'tcx>,
43 query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
44) -> bool {
45 let adt_has_async_dtor =
49 |adt_def: ty::AdtDef<'tcx>| adt_def.async_destructor(tcx).map(|_| DtorType::Significant);
50 let res = drop_tys_helper(
51 tcx,
52 query.value,
53 query.typing_env,
54 adt_has_async_dtor,
55 DropTysOptions::default().recurse_into_box_for_async_drop(),
56 )
57 .filter(filter_array_elements_async(tcx, query.typing_env))
58 .next()
59 .is_some();
60
61 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:61",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(61u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("needs_async_drop_raw({0:?}) = {1:?}",
query, res) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("needs_async_drop_raw({:?}) = {:?}", query, res);
62 res
63}
64
65fn filter_array_elements<'tcx>(
70 tcx: TyCtxt<'tcx>,
71 typing_env: ty::TypingEnv<'tcx>,
72) -> impl Fn(&Result<Ty<'tcx>, AlwaysRequiresDrop>) -> bool {
73 move |ty| match ty {
74 Ok(ty) => match *ty.kind() {
75 ty::Array(elem, _) => tcx.needs_drop_raw(typing_env.as_query_input(elem)),
76 _ => true,
77 },
78 Err(AlwaysRequiresDrop) => true,
79 }
80}
81fn filter_array_elements_async<'tcx>(
82 tcx: TyCtxt<'tcx>,
83 typing_env: ty::TypingEnv<'tcx>,
84) -> impl Fn(&Result<Ty<'tcx>, AlwaysRequiresDrop>) -> bool {
85 move |ty| match ty {
86 Ok(ty) => match *ty.kind() {
87 ty::Array(elem, _) => tcx.needs_async_drop_raw(typing_env.as_query_input(elem)),
88 _ => true,
89 },
90 Err(AlwaysRequiresDrop) => true,
91 }
92}
93
94fn has_significant_drop_raw<'tcx>(
95 tcx: TyCtxt<'tcx>,
96 query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
97) -> bool {
98 let res = drop_tys_helper(
99 tcx,
100 query.value,
101 query.typing_env,
102 adt_consider_insignificant_dtor(tcx),
103 DropTysOptions::default().only_significant(),
104 )
105 .filter(filter_array_elements(tcx, query.typing_env))
106 .next()
107 .is_some();
108 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:108",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(108u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("has_significant_drop_raw({0:?}) = {1:?}",
query, res) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("has_significant_drop_raw({:?}) = {:?}", query, res);
109 res
110}
111
112struct NeedsDropTypes<'tcx, F> {
113 tcx: TyCtxt<'tcx>,
114 typing_env: ty::TypingEnv<'tcx>,
115 query_ty: Ty<'tcx>,
116 seen_tys: FxHashSet<Ty<'tcx>>,
117 unchecked_tys: Vec<(Ty<'tcx>, usize)>,
122 recursion_limit: Limit,
123 adt_components: F,
124 exhaustive: bool,
136}
137
138impl<'tcx, F> NeedsDropTypes<'tcx, F> {
139 fn new(
140 tcx: TyCtxt<'tcx>,
141 typing_env: ty::TypingEnv<'tcx>,
142 ty: Ty<'tcx>,
143 exhaustive: bool,
144 adt_components: F,
145 ) -> Self {
146 let mut seen_tys = FxHashSet::default();
147 seen_tys.insert(ty);
148 Self {
149 tcx,
150 typing_env,
151 seen_tys,
152 query_ty: ty,
153 unchecked_tys: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(ty, 0)]))vec![(ty, 0)],
154 recursion_limit: tcx.recursion_limit(),
155 adt_components,
156 exhaustive,
157 }
158 }
159
160 fn always_drop_component(&self, ty: Ty<'tcx>) -> NeedsDropResult<Ty<'tcx>> {
164 if self.exhaustive { Ok(ty) } else { Err(AlwaysRequiresDrop) }
165 }
166}
167
168impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
169where
170 F: Fn(ty::AdtDef<'tcx>, GenericArgsRef<'tcx>) -> NeedsDropResult<I>,
171 I: Iterator<Item = Ty<'tcx>>,
172{
173 type Item = NeedsDropResult<Ty<'tcx>>;
174
175 {}
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("next",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(175u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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::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,
&{ meta.fields().value_set_all(&[]) })
} 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:
Option<NeedsDropResult<Ty<'tcx>>> = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx;
while let Some((ty, level)) = self.unchecked_tys.pop() {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:180",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(180u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("ty")
}> =
::tracing::__macro_support::FieldName::new("ty");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("needs_drop_components: inspect")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if !self.recursion_limit.value_within_limit(level) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:184",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(184u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("needs_drop_components: recursion limit exceeded")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
tcx.dcx().emit_err(NeedsDropOverflow {
query_ty: self.query_ty,
});
return Some(self.always_drop_component(ty));
}
let components =
match needs_drop_components(tcx, ty) {
Err(AlwaysRequiresDrop) =>
return Some(self.always_drop_component(ty)),
Ok(components) => components,
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:193",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(193u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("needs_drop_components({0:?}) = {1:?}",
ty, components) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let queue_type =
move |this: &mut Self, component: Ty<'tcx>|
{
if this.seen_tys.insert(component) {
this.unchecked_tys.push((component, level + 1));
}
};
for component in components {
match *component.kind() {
ty::Coroutine(def_id, args) => {
if self.exhaustive {
for upvar in args.as_coroutine().upvar_tys() {
queue_type(self, upvar);
}
queue_type(self, args.as_coroutine().resume_ty());
if let Some(witness) = tcx.mir_coroutine_witnesses(def_id) {
for field_ty in &witness.field_tys {
queue_type(self,
EarlyBinder::bind(tcx,
field_ty.ty).instantiate(tcx, args).skip_norm_wip());
}
}
} else { return Some(self.always_drop_component(ty)); }
}
ty::CoroutineWitness(..) => {
{
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("witness should be handled in parent")));
};
}
ty::UnsafeBinder(bound_ty) => {
let ty =
self.tcx.instantiate_bound_regions_with_erased(bound_ty.into());
queue_type(self, ty);
}
_ if
tcx.type_is_copy_modulo_regions(self.typing_env, component)
=> {}
ty::Closure(_, args) => {
for upvar in args.as_closure().upvar_tys() {
queue_type(self, upvar);
}
}
ty::CoroutineClosure(_, args) => {
for upvar in args.as_coroutine_closure().upvar_tys() {
queue_type(self, upvar);
}
}
ty::Adt(adt_def, args) => {
let tys =
match (self.adt_components)(adt_def, args) {
Err(AlwaysRequiresDrop) => {
return Some(self.always_drop_component(ty));
}
Ok(tys) => tys,
};
for required_ty in tys {
let required =
tcx.try_normalize_erasing_regions(self.typing_env,
Unnormalized::new_wip(required_ty)).unwrap_or(required_ty);
queue_type(self, required);
}
}
ty::Alias(..) | ty::Array(..) | ty::Placeholder(_) |
ty::Param(_) => {
if ty == component {
return Some(Ok(component));
} else { queue_type(self, component); }
}
ty::Foreign(_) | ty::Dynamic(..) => {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:293",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(293u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("needs_drop_components: foreign or dynamic")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
return Some(self.always_drop_component(ty));
}
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) |
ty::Float(_) | ty::Str | ty::Slice(_) | ty::Ref(..) |
ty::RawPtr(..) | ty::FnDef(..) | ty::Pat(..) | ty::FnPtr(..)
| ty::Tuple(_) | ty::Bound(..) | ty::Never | ty::Infer(_) |
ty::Error(_) => {
::rustc_middle::util::bug::bug_fmt(format_args!("unexpected type returned by `needs_drop_components`: {0}",
component))
}
}
}
}
None
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:175",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(175u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
176 fn next(&mut self) -> Option<NeedsDropResult<Ty<'tcx>>> {
177 let tcx = self.tcx;
178
179 while let Some((ty, level)) = self.unchecked_tys.pop() {
180 debug!(?ty, "needs_drop_components: inspect");
181 if !self.recursion_limit.value_within_limit(level) {
182 debug!("needs_drop_components: recursion limit exceeded");
185 tcx.dcx().emit_err(NeedsDropOverflow { query_ty: self.query_ty });
186 return Some(self.always_drop_component(ty));
187 }
188
189 let components = match needs_drop_components(tcx, ty) {
190 Err(AlwaysRequiresDrop) => return Some(self.always_drop_component(ty)),
191 Ok(components) => components,
192 };
193 debug!("needs_drop_components({:?}) = {:?}", ty, components);
194
195 let queue_type = move |this: &mut Self, component: Ty<'tcx>| {
196 if this.seen_tys.insert(component) {
197 this.unchecked_tys.push((component, level + 1));
198 }
199 };
200
201 for component in components {
202 match *component.kind() {
203 ty::Coroutine(def_id, args) => {
215 if self.exhaustive {
217 for upvar in args.as_coroutine().upvar_tys() {
218 queue_type(self, upvar);
219 }
220 queue_type(self, args.as_coroutine().resume_ty());
221 if let Some(witness) = tcx.mir_coroutine_witnesses(def_id) {
222 for field_ty in &witness.field_tys {
223 queue_type(
224 self,
225 EarlyBinder::bind(tcx, field_ty.ty)
226 .instantiate(tcx, args)
227 .skip_norm_wip(),
228 );
229 }
230 }
231 } else {
232 return Some(self.always_drop_component(ty));
233 }
234 }
235 ty::CoroutineWitness(..) => {
236 unreachable!("witness should be handled in parent");
237 }
238
239 ty::UnsafeBinder(bound_ty) => {
240 let ty = self.tcx.instantiate_bound_regions_with_erased(bound_ty.into());
241 queue_type(self, ty);
242 }
243
244 _ if tcx.type_is_copy_modulo_regions(self.typing_env, component) => {}
245
246 ty::Closure(_, args) => {
247 for upvar in args.as_closure().upvar_tys() {
248 queue_type(self, upvar);
249 }
250 }
251
252 ty::CoroutineClosure(_, args) => {
253 for upvar in args.as_coroutine_closure().upvar_tys() {
254 queue_type(self, upvar);
255 }
256 }
257
258 ty::Adt(adt_def, args) => {
262 let tys = match (self.adt_components)(adt_def, args) {
263 Err(AlwaysRequiresDrop) => {
264 return Some(self.always_drop_component(ty));
265 }
266 Ok(tys) => tys,
267 };
268 for required_ty in tys {
269 let required = tcx
270 .try_normalize_erasing_regions(
271 self.typing_env,
272 Unnormalized::new_wip(required_ty),
273 )
274 .unwrap_or(required_ty);
275
276 queue_type(self, required);
277 }
278 }
279 ty::Alias(..) | ty::Array(..) | ty::Placeholder(_) | ty::Param(_) => {
280 if ty == component {
281 return Some(Ok(component));
284 } else {
285 queue_type(self, component);
289 }
290 }
291
292 ty::Foreign(_) | ty::Dynamic(..) => {
293 debug!("needs_drop_components: foreign or dynamic");
294 return Some(self.always_drop_component(ty));
295 }
296
297 ty::Bool
298 | ty::Char
299 | ty::Int(_)
300 | ty::Uint(_)
301 | ty::Float(_)
302 | ty::Str
303 | ty::Slice(_)
304 | ty::Ref(..)
305 | ty::RawPtr(..)
306 | ty::FnDef(..)
307 | ty::Pat(..)
308 | ty::FnPtr(..)
309 | ty::Tuple(_)
310 | ty::Bound(..)
311 | ty::Never
312 | ty::Infer(_)
313 | ty::Error(_) => {
314 bug!("unexpected type returned by `needs_drop_components`: {component}")
315 }
316 }
317 }
318 }
319
320 None
321 }
322}
323
324enum DtorType {
325 Insignificant,
329
330 Significant,
332}
333
334#[derive(#[automatically_derived]
impl ::core::marker::Copy for DropTysOptions { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DropTysOptions { }
#[automatically_derived]
impl ::core::clone::Clone for DropTysOptions {
#[inline]
fn clone(&self) -> DropTysOptions {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::default::Default for DropTysOptions {
#[inline]
fn default() -> DropTysOptions {
DropTysOptions {
only_significant: ::core::default::Default::default(),
exhaustive: ::core::default::Default::default(),
async_drop_recurses_into_box: ::core::default::Default::default(),
}
}
}Default)]
335struct DropTysOptions {
336 only_significant: bool,
337 exhaustive: bool,
338 async_drop_recurses_into_box: bool,
339}
340
341impl DropTysOptions {
342 fn only_significant(mut self) -> Self {
343 self.only_significant = true;
344 self
345 }
346
347 fn exhaustive(mut self) -> Self {
348 self.exhaustive = true;
349 self
350 }
351
352 fn recurse_into_box_for_async_drop(mut self) -> Self {
353 self.async_drop_recurses_into_box = true;
354 self
355 }
356}
357
358fn drop_tys_helper<'tcx>(
363 tcx: TyCtxt<'tcx>,
364 ty: Ty<'tcx>,
365 typing_env: ty::TypingEnv<'tcx>,
366 adt_has_dtor: impl Fn(ty::AdtDef<'tcx>) -> Option<DtorType>,
367 options: DropTysOptions,
368) -> impl Iterator<Item = NeedsDropResult<Ty<'tcx>>> {
369 fn with_query_cache<'tcx>(
370 tcx: TyCtxt<'tcx>,
371 iter: impl IntoIterator<Item = Ty<'tcx>>,
372 ) -> NeedsDropResult<Vec<Ty<'tcx>>> {
373 iter.into_iter().try_fold(Vec::new(), |mut vec, subty| {
374 match subty.kind() {
375 ty::Adt(adt_id, args) => {
376 for subty in tcx.adt_drop_tys(adt_id.did())? {
377 vec.push(
378 EarlyBinder::bind(tcx, subty).instantiate(tcx, args).skip_norm_wip(),
379 );
380 }
381 }
382 _ => vec.push(subty),
383 };
384 Ok(vec)
385 })
386 }
387
388 let adt_components = move |adt_def: ty::AdtDef<'tcx>, args: GenericArgsRef<'tcx>| {
389 if adt_def.is_manually_drop() {
390 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:390",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(390u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("drop_tys_helper: `{0:?}` is manually drop",
adt_def) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("drop_tys_helper: `{:?}` is manually drop", adt_def);
391 Ok(Vec::new())
392 } else if options.async_drop_recurses_into_box && adt_def.is_box() {
393 let box_components = match args.as_slice() {
394 [boxed_ty, allocator_ty] => {
395 let boxed_ty = boxed_ty.expect_ty();
396 let allocator_ty = allocator_ty.expect_ty();
397 match boxed_ty.kind() {
398 ty::Dynamic(..) | ty::Error(_) => ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[allocator_ty]))vec![allocator_ty],
402 _ => ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[boxed_ty, allocator_ty]))vec![boxed_ty, allocator_ty],
403 }
404 }
405 _ => {
406 ::rustc_middle::util::bug::bug_fmt(format_args!("drop_tys_helper: `Box` has unexpected generic args: {0:?}",
args));bug!("drop_tys_helper: `Box` has unexpected generic args: {args:?}");
407 }
408 };
409 Ok(box_components)
410 } else if let Some(dtor_info) = adt_has_dtor(adt_def) {
411 match dtor_info {
412 DtorType::Significant => {
413 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:413",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(413u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("drop_tys_helper: `{0:?}` implements `Drop`",
adt_def) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("drop_tys_helper: `{:?}` implements `Drop`", adt_def);
414 Err(AlwaysRequiresDrop)
415 }
416 DtorType::Insignificant => {
417 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:417",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(417u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("drop_tys_helper: `{0:?}` drop is insignificant",
adt_def) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("drop_tys_helper: `{:?}` drop is insignificant", adt_def);
418
419 Ok(args.types().collect())
423 }
424 }
425 } else if adt_def.is_union() {
426 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:426",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(426u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("drop_tys_helper: `{0:?}` is a union",
adt_def) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("drop_tys_helper: `{:?}` is a union", adt_def);
427 Ok(Vec::new())
428 } else {
429 let field_tys = adt_def.all_fields().map(|field| {
430 let r = tcx.type_of(field.did).instantiate(tcx, args).skip_norm_wip();
431 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:431",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(431u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::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!("drop_tys_helper: Instantiate into {0:?} with {1:?} getting {2:?}",
field, args, r) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
432 "drop_tys_helper: Instantiate into {:?} with {:?} getting {:?}",
433 field, args, r
434 );
435 r
436 });
437 if options.only_significant {
438 Ok(field_tys.collect())
440 } else {
441 with_query_cache(tcx, field_tys)
446 }
447 }
448 .map(|v| v.into_iter())
449 };
450
451 NeedsDropTypes::new(tcx, typing_env, ty, options.exhaustive, adt_components)
452}
453
454fn adt_consider_insignificant_dtor<'tcx>(
455 tcx: TyCtxt<'tcx>,
456) -> impl Fn(ty::AdtDef<'tcx>) -> Option<DtorType> {
457 move |adt_def: ty::AdtDef<'tcx>| {
458 if {
{
'done:
{
for i in
::rustc_attr_ir::HasAttrs::get_attrs(adt_def.did(), &tcx) {
#[allow(unused_imports)]
use ::rustc_attr_ir::AttributeKind::*;
let i: &::rustc_attr_ir::Attribute = i;
match i {
::rustc_attr_ir::Attribute::Parsed(RustcInsignificantDtor)
=> {
break 'done Some(());
}
::rustc_attr_ir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}.is_some()find_attr!(tcx, adt_def.did(), RustcInsignificantDtor) {
459 Some(DtorType::Insignificant)
464 } else if adt_def.destructor(tcx).is_some() {
465 Some(DtorType::Significant)
468 } else {
469 None
472 }
473 }
474}
475
476fn adt_drop_tys<'tcx>(
477 tcx: TyCtxt<'tcx>,
478 def_id: DefId,
479) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
480 let adt_has_dtor =
483 |adt_def: ty::AdtDef<'tcx>| adt_def.destructor(tcx).map(|_| DtorType::Significant);
484 drop_tys_helper(
486 tcx,
487 tcx.type_of(def_id).instantiate_identity().skip_norm_wip(),
488 ty::TypingEnv::non_body_analysis(tcx, def_id),
489 adt_has_dtor,
490 DropTysOptions::default(),
491 )
492 .collect::<Result<Vec<_>, _>>()
493 .map(|components| tcx.mk_type_list(&components))
494}
495
496fn adt_async_drop_tys<'tcx>(
497 tcx: TyCtxt<'tcx>,
498 def_id: DefId,
499) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
500 let adt_has_dtor =
502 |adt_def: ty::AdtDef<'tcx>| adt_def.async_destructor(tcx).map(|_| DtorType::Significant);
503 drop_tys_helper(
505 tcx,
506 tcx.type_of(def_id).instantiate_identity().skip_norm_wip(),
507 ty::TypingEnv::non_body_analysis(tcx, def_id),
508 adt_has_dtor,
509 DropTysOptions::default().recurse_into_box_for_async_drop(),
510 )
511 .collect::<Result<Vec<_>, _>>()
512 .map(|components| tcx.mk_type_list(&components))
513}
514
515fn adt_significant_drop_tys(
519 tcx: TyCtxt<'_>,
520 def_id: DefId,
521) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
522 drop_tys_helper(
523 tcx,
524 tcx.type_of(def_id).instantiate_identity().skip_norm_wip(), ty::TypingEnv::non_body_analysis(tcx, def_id),
526 adt_consider_insignificant_dtor(tcx),
527 DropTysOptions::default().only_significant(),
528 )
529 .collect::<Result<Vec<_>, _>>()
530 .map(|components| tcx.mk_type_list(&components))
531}
532
533{}
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("list_significant_drop_tys",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(533u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("key")
}> =
::tracing::__macro_support::FieldName::new("key");
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(&key)
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: &'tcx ty::List<Ty<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
tcx.mk_type_list(&drop_tys_helper(tcx, key.value,
key.typing_env, adt_consider_insignificant_dtor(tcx),
DropTysOptions::default().only_significant().exhaustive()).filter_map(|res|
res.ok()).collect::<Vec<_>>())
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_ty_utils/src/needs_drop.rs:533",
"rustc_ty_utils::needs_drop", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_ty_utils/src/needs_drop.rs"),
::tracing_core::__macro_support::Option::Some(533u32),
::tracing_core::__macro_support::Option::Some("rustc_ty_utils::needs_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(tcx), ret)]
534fn list_significant_drop_tys<'tcx>(
535 tcx: TyCtxt<'tcx>,
536 key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
537) -> &'tcx ty::List<Ty<'tcx>> {
538 tcx.mk_type_list(
539 &drop_tys_helper(
540 tcx,
541 key.value,
542 key.typing_env,
543 adt_consider_insignificant_dtor(tcx),
544 DropTysOptions::default().only_significant().exhaustive(),
545 )
546 .filter_map(|res| res.ok())
547 .collect::<Vec<_>>(),
548 )
549}
550
551pub(crate) fn provide(providers: &mut Providers) {
552 *providers = Providers {
553 needs_drop_raw,
554 needs_async_drop_raw,
555 has_significant_drop_raw,
556 adt_drop_tys,
557 adt_async_drop_tys,
558 adt_significant_drop_tys,
559 list_significant_drop_tys,
560 ..*providers
561 };
562}