1use std::{fmt, iter, mem};
2
3use itertools::Itertools;
4use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
5use rustc_attr_ir::lang_items::LangItem;
6use rustc_data_structures::thin_vec::{ThinVec, thin_vec};
7use rustc_hir::{CoroutineDesugaring, CoroutineKind};
8use rustc_index::Idx;
9use rustc_middle::mir::*;
10use rustc_middle::ty::adjustment::PointerCoercion;
11use rustc_middle::ty::util::{Discr, IntTypeExt};
12use rustc_middle::ty::{self, GenericArgs, Ty, TyCtxt};
13use rustc_mir_dataflow::DropFlagState;
14use rustc_span::{DUMMY_SP, bug, dummy_spanned, span_bug};
15use tracing::{debug, instrument};
16
17use crate::coroutine::CTX_ARG;
18use crate::patch::MirPatch;
19
20#[derive(#[automatically_derived]impl ::core::fmt::Debug for DropStyle {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DropStyle::Dead => "Dead",
DropStyle::Static => "Static",
DropStyle::Conditional => "Conditional",
DropStyle::Open => "Open",
})
}
}Debug)]
22pub(crate) enum DropStyle {
23 Dead,
25
26 Static,
29
30 Conditional,
32
33 Open,
39}
40
41#[derive(#[automatically_derived]impl ::core::fmt::Debug for DropFlagMode {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DropFlagMode::Shallow => "Shallow",
DropFlagMode::Deep => "Deep",
})
}
}Debug)]
43pub(crate) enum DropFlagMode {
44 Shallow,
46 Deep,
48}
49
50#[derive(#[automatically_derived]impl ::core::marker::Copy for Unwind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Unwind {
}
#[automatically_derived]impl ::core::clone::Clone for Unwind {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<BasicBlock>;
*self
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Unwind {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::To(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "To",
&__self_0),
Self::InCleanup =>
::core::fmt::Formatter::write_str(f, "InCleanup"),
}
}
}Debug)]
52pub(crate) enum Unwind {
53 To(BasicBlock),
55 InCleanup,
57}
58
59impl Unwind {
60 fn is_cleanup(self) -> bool {
61 match self {
62 Unwind::To(..) => false,
63 Unwind::InCleanup => true,
64 }
65 }
66
67 fn into_action(self) -> UnwindAction {
68 match self {
69 Unwind::To(bb) => UnwindAction::Cleanup(bb),
70 Unwind::InCleanup => UnwindAction::Terminate(UnwindTerminateReason::InCleanup),
71 }
72 }
73
74 fn map<F>(self, f: F) -> Self
75 where
76 F: FnOnce(BasicBlock) -> BasicBlock,
77 {
78 match self {
79 Unwind::To(bb) => Unwind::To(f(bb)),
80 Unwind::InCleanup => Unwind::InCleanup,
81 }
82 }
83}
84
85pub(crate) trait DropElaborator<'a, 'tcx>: fmt::Debug {
86 type Path: Copy + fmt::Debug;
92
93 fn patch_ref(&self) -> &MirPatch<'tcx>;
96 fn patch(&mut self) -> &mut MirPatch<'tcx>;
97 fn body(&self) -> &'a Body<'tcx>;
98 fn tcx(&self) -> TyCtxt<'tcx>;
99 fn typing_env(&self) -> ty::TypingEnv<'tcx>;
100 fn allow_async_drops(&self) -> bool;
101
102 fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle;
106
107 fn get_drop_flag(&mut self, path: Self::Path) -> Option<Operand<'tcx>>;
109
110 fn drop_flags_for(&mut self, path: Self::Path, mode: DropFlagMode) -> Vec<Place<'tcx>>;
114
115 fn field_subpath(&self, path: Self::Path, field: FieldIdx) -> Option<Self::Path>;
121
122 fn deref_subpath(&self, path: Self::Path) -> Option<Self::Path>;
128
129 fn downcast_subpath(&self, path: Self::Path, variant: VariantIdx) -> Option<Self::Path>;
133
134 fn array_subpath(&self, path: Self::Path, index: u64, size: u64) -> Option<Self::Path>;
140}
141
142#[derive(#[automatically_derived]impl<'a, 'b, 'tcx, D: ::core::fmt::Debug>
::core::fmt::Debug for DropCtxt<'a, 'b, 'tcx, D> where
D: DropElaborator<'b, 'tcx>, D::Path: ::core::fmt::Debug {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_fields_finish(f,
"DropCtxt elaborator source_info place path succ unwind dropline",
&[&self.elaborator, &self.source_info, &self.place, &self.path,
&self.succ, &self.unwind, &&self.dropline])
}
}Debug)]
143struct DropCtxt<'a, 'b, 'tcx, D>
144where
145 D: DropElaborator<'b, 'tcx>,
146{
147 elaborator: &'a mut D,
148
149 source_info: SourceInfo,
150
151 place: Place<'tcx>,
152 path: D::Path,
153 succ: BasicBlock,
154 unwind: Unwind,
155 dropline: Option<BasicBlock>,
156}
157
158pub(crate) fn elaborate_drop<'b, 'tcx, D>(
167 elaborator: &mut D,
168 source_info: SourceInfo,
169 place: Place<'tcx>,
170 path: D::Path,
171 succ: BasicBlock,
172 unwind: Unwind,
173 bb: BasicBlock,
174 dropline: Option<BasicBlock>,
175) where
176 D: DropElaborator<'b, 'tcx>,
177 'tcx: 'b,
178{
179 DropCtxt { elaborator, source_info, place, path, succ, unwind, dropline }.elaborate_drop(bb)
180}
181
182impl<'a, 'b, 'tcx, D> DropCtxt<'a, 'b, 'tcx, D>
183where
184 D: DropElaborator<'b, 'tcx>,
185 'tcx: 'b,
186{
187 {}
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("place_ty",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(187u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("place")
}> =
::tracing::__macro_support::FieldName::new("place");
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(&place)
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: Ty<'tcx> = loop {};
return __tracing_attr_fake_return;
}
{
if place.local <
self.elaborator.body().local_decls.next_index() {
place.ty(self.elaborator.body(), self.tcx()).ty
} else {
PlaceTy::from_ty(self.elaborator.patch_ref().local_ty(place.local)).multi_projection_ty(self.elaborator.tcx(),
place.projection).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/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:187",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(187u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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::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(level = "trace", skip(self), ret)]
188 fn place_ty(&self, place: Place<'tcx>) -> Ty<'tcx> {
189 if place.local < self.elaborator.body().local_decls.next_index() {
190 place.ty(self.elaborator.body(), self.tcx()).ty
191 } else {
192 PlaceTy::from_ty(self.elaborator.patch_ref().local_ty(place.local))
194 .multi_projection_ty(self.elaborator.tcx(), place.projection)
195 .ty
196 }
197 }
198
199 fn tcx(&self) -> TyCtxt<'tcx> {
200 self.elaborator.tcx()
201 }
202
203 {}
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("build_async_drop",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(227u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("place")
}> =
::tracing::__macro_support::FieldName::new("place");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("drop_ty")
}> =
::tracing::__macro_support::FieldName::new("drop_ty");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dropline")
}> =
::tracing::__macro_support::FieldName::new("dropline");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("call_destructor_only")
}> =
::tracing::__macro_support::FieldName::new("call_destructor_only");
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(&place)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&drop_ty)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dropline)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&call_destructor_only
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx();
let span = self.source_info.span;
let obj_ref_ty =
Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, drop_ty);
let async_drop_fn_def_id =
if call_destructor_only {
let async_drop_trait =
tcx.require_lang_item(LangItem::AsyncDrop, span);
tcx.associated_item_def_ids(async_drop_trait)[0]
} else {
tcx.require_lang_item(LangItem::AsyncDropInPlace, span)
};
let fut_ty =
tcx.instantiate_bound_regions_with_erased(tcx.fn_sig(async_drop_fn_def_id).instantiate(tcx,
&[drop_ty.into()]).skip_norm_wip()).output();
let fut = self.new_temp(fut_ty);
let succ_with_dead =
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.storage_dead(fut));
vec
}, TerminatorKind::goto(succ));
let dropline_with_dead =
dropline.map(|target|
{
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.storage_dead(fut));
vec
}, TerminatorKind::goto(target))
});
let unwind_with_dead =
unwind.map(|target|
{
self.new_block_with_statements(Unwind::InCleanup,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.storage_dead(fut));
vec
}, TerminatorKind::goto(target))
});
let coroutine_kind =
self.elaborator.body().coroutine_kind().unwrap();
let yield_value =
match coroutine_kind {
CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)
=> {
let full_yield_ty =
self.elaborator.body().yield_ty().unwrap();
let ty::Adt(_poll_adt, args) =
*full_yield_ty.kind() else {
::rustc_span::macros::bug_impl(None,
format_args!("impossible case reached"), Location::caller())
};
let ty::Adt(_option_adt, args) =
*args.type_at(0).kind() else {
::rustc_span::macros::bug_impl(None,
format_args!("impossible case reached"), Location::caller())
};
let yield_ty = args.type_at(0);
Operand::unevaluated_constant(tcx,
tcx.require_lang_item(LangItem::AsyncGenPending, span),
tcx.mk_args(&[yield_ty.into()]), span)
}
CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
Operand::zero_sized_constant(tcx.types.unit, span)
}
_ => {
::core::panicking::panic_fmt(format_args!("unexpected coroutine for async drop {0:?}",
coroutine_kind));
}
};
let panic_bb =
self.build_resumed_after_drop_abort_block(unwind_with_dead,
coroutine_kind);
let (drop_pin_bb, drop_resume_bb, drop_drop_bb) =
self.build_pin_poll_yield_loop(CTX_ARG.into(), fut.into(),
yield_value.clone(),
dropline_with_dead.unwrap_or(succ_with_dead),
unwind_with_dead);
self.elaborator.patch().patch_terminator(drop_resume_bb,
TerminatorKind::goto(panic_bb));
self.elaborator.patch().patch_terminator(drop_drop_bb,
TerminatorKind::goto(drop_pin_bb));
let succ_yield_loop =
if dropline_with_dead.is_some() {
let (pin_bb, resume_bb, drop_bb) =
self.build_pin_poll_yield_loop(CTX_ARG.into(), fut.into(),
yield_value, succ_with_dead, unwind_with_dead);
self.elaborator.patch().patch_terminator(resume_bb,
TerminatorKind::goto(pin_bb));
self.elaborator.patch().patch_terminator(drop_bb,
TerminatorKind::goto(drop_pin_bb));
pin_bb
} else { drop_pin_bb };
let pin_adt_def =
tcx.adt_def(tcx.require_lang_item(LangItem::Pin, span));
let pin_obj_ty =
Ty::new_adt(tcx, pin_adt_def,
tcx.mk_args(&[obj_ref_ty.into()]));
let pin_obj_local = self.new_temp(pin_obj_ty);
let drop_arg =
if call_destructor_only {
Operand::Move(pin_obj_local.into())
} else {
Operand::Copy(tcx.mk_place_field(pin_obj_local.into(),
FieldIdx::ZERO, obj_ref_ty))
};
let call_drop_bb =
self.new_block_with_statements(unwind_with_dead,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.storage_live(fut));
vec
},
TerminatorKind::Call {
func: Operand::function_handle(tcx, async_drop_fn_def_id,
&[drop_ty.into()], span),
args: [dummy_spanned(drop_arg)].into(),
destination: fut.into(),
target: Some(succ_yield_loop),
unwind: unwind_with_dead.into_action(),
call_source: CallSource::Misc,
fn_span: self.source_info.span,
});
let obj_ref_place = Place::from(self.new_temp(obj_ref_ty));
let pin_obj_new_unchecked_fn =
tcx.require_lang_item(LangItem::PinNewUnchecked, span);
let assign_obj_ref_place =
self.assign(obj_ref_place,
Rvalue::Ref(tcx.lifetimes.re_erased,
BorrowKind::Mut { kind: MutBorrowKind::Default }, place));
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(assign_obj_ref_place);
vec
},
TerminatorKind::Call {
func: Operand::function_handle(tcx,
pin_obj_new_unchecked_fn, &[obj_ref_ty.into()], span),
args: [dummy_spanned(Operand::Move(obj_ref_place))].into(),
destination: pin_obj_local.into(),
target: Some(call_drop_bb),
unwind: unwind.into_action(),
call_source: CallSource::Misc,
fn_span: span,
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:227",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(227u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
228 fn build_async_drop(
229 &mut self,
230 place: Place<'tcx>,
231 drop_ty: Ty<'tcx>,
232 succ: BasicBlock,
233 unwind: Unwind,
234 dropline: Option<BasicBlock>,
235 call_destructor_only: bool,
236 ) -> BasicBlock {
237 let tcx = self.tcx();
238 let span = self.source_info.span;
239 let obj_ref_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, drop_ty);
240
241 let async_drop_fn_def_id = if call_destructor_only {
242 let async_drop_trait = tcx.require_lang_item(LangItem::AsyncDrop, span);
244 tcx.associated_item_def_ids(async_drop_trait)[0]
245 } else {
246 tcx.require_lang_item(LangItem::AsyncDropInPlace, span)
248 };
249
250 let fut_ty = tcx
251 .instantiate_bound_regions_with_erased(
252 tcx.fn_sig(async_drop_fn_def_id)
253 .instantiate(tcx, &[drop_ty.into()])
254 .skip_norm_wip(),
255 )
256 .output();
257 let fut = self.new_temp(fut_ty);
258
259 let succ_with_dead = self.new_block_with_statements(
263 unwind,
264 thin_vec![self.storage_dead(fut)],
265 TerminatorKind::goto(succ),
266 );
267 let dropline_with_dead = dropline.map(|target| {
268 self.new_block_with_statements(
269 unwind,
270 thin_vec![self.storage_dead(fut)],
271 TerminatorKind::goto(target),
272 )
273 });
274 let unwind_with_dead = unwind.map(|target| {
275 self.new_block_with_statements(
276 Unwind::InCleanup,
277 thin_vec![self.storage_dead(fut)],
278 TerminatorKind::goto(target),
279 )
280 });
281
282 let coroutine_kind = self.elaborator.body().coroutine_kind().unwrap();
284 let yield_value = match coroutine_kind {
285 CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => {
287 let full_yield_ty = self.elaborator.body().yield_ty().unwrap();
288 let ty::Adt(_poll_adt, args) = *full_yield_ty.kind() else { bug!() };
289 let ty::Adt(_option_adt, args) = *args.type_at(0).kind() else { bug!() };
290 let yield_ty = args.type_at(0);
291 Operand::unevaluated_constant(
292 tcx,
293 tcx.require_lang_item(LangItem::AsyncGenPending, span),
294 tcx.mk_args(&[yield_ty.into()]),
295 span,
296 )
297 }
298 CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
300 Operand::zero_sized_constant(tcx.types.unit, span)
301 }
302 _ => panic!("unexpected coroutine for async drop {coroutine_kind:?}"),
304 };
305
306 let panic_bb = self.build_resumed_after_drop_abort_block(unwind_with_dead, coroutine_kind);
315 let (drop_pin_bb, drop_resume_bb, drop_drop_bb) = self.build_pin_poll_yield_loop(
316 CTX_ARG.into(),
317 fut.into(),
318 yield_value.clone(),
319 dropline_with_dead.unwrap_or(succ_with_dead),
322 unwind_with_dead,
323 );
324 self.elaborator.patch().patch_terminator(drop_resume_bb, TerminatorKind::goto(panic_bb));
325 self.elaborator.patch().patch_terminator(drop_drop_bb, TerminatorKind::goto(drop_pin_bb));
326
327 let succ_yield_loop = if dropline_with_dead.is_some() {
334 let (pin_bb, resume_bb, drop_bb) = self.build_pin_poll_yield_loop(
335 CTX_ARG.into(),
336 fut.into(),
337 yield_value,
338 succ_with_dead,
340 unwind_with_dead,
341 );
342 self.elaborator.patch().patch_terminator(resume_bb, TerminatorKind::goto(pin_bb));
343 self.elaborator.patch().patch_terminator(drop_bb, TerminatorKind::goto(drop_pin_bb));
344 pin_bb
345 } else {
346 drop_pin_bb
348 };
349
350 let pin_adt_def = tcx.adt_def(tcx.require_lang_item(LangItem::Pin, span));
354 let pin_obj_ty = Ty::new_adt(tcx, pin_adt_def, tcx.mk_args(&[obj_ref_ty.into()]));
355 let pin_obj_local = self.new_temp(pin_obj_ty);
357 let drop_arg = if call_destructor_only {
358 Operand::Move(pin_obj_local.into())
360 } else {
361 Operand::Copy(tcx.mk_place_field(pin_obj_local.into(), FieldIdx::ZERO, obj_ref_ty))
363 };
364 let call_drop_bb = self.new_block_with_statements(
365 unwind_with_dead,
366 thin_vec![self.storage_live(fut)],
367 TerminatorKind::Call {
368 func: Operand::function_handle(tcx, async_drop_fn_def_id, &[drop_ty.into()], span),
369 args: [dummy_spanned(drop_arg)].into(),
370 destination: fut.into(),
371 target: Some(succ_yield_loop),
372 unwind: unwind_with_dead.into_action(),
373 call_source: CallSource::Misc,
374 fn_span: self.source_info.span,
375 },
376 );
377
378 let obj_ref_place = Place::from(self.new_temp(obj_ref_ty));
380 let pin_obj_new_unchecked_fn = tcx.require_lang_item(LangItem::PinNewUnchecked, span);
381 let assign_obj_ref_place = self.assign(
382 obj_ref_place,
383 Rvalue::Ref(
384 tcx.lifetimes.re_erased,
385 BorrowKind::Mut { kind: MutBorrowKind::Default },
386 place,
387 ),
388 );
389 self.new_block_with_statements(
390 unwind,
391 thin_vec![assign_obj_ref_place],
392 TerminatorKind::Call {
393 func: Operand::function_handle(
394 tcx,
395 pin_obj_new_unchecked_fn,
396 &[obj_ref_ty.into()],
397 span,
398 ),
399 args: [dummy_spanned(Operand::Move(obj_ref_place))].into(),
400 destination: pin_obj_local.into(),
401 target: Some(call_drop_bb),
402 unwind: unwind.into_action(),
403 call_source: CallSource::Misc,
404 fn_span: span,
405 },
406 )
407 }
408
409 fn build_resumed_after_drop_abort_block(
410 &mut self,
411 unwind: Unwind,
412 coroutine_kind: CoroutineKind,
413 ) -> BasicBlock {
414 let tcx = self.tcx();
415 let panic_bb = self.new_block(unwind, TerminatorKind::Unreachable);
416 let msg = AssertMessage::ResumedAfterDrop(coroutine_kind);
417 let false_op = Operand::Constant(Box::new(ConstOperand {
418 span: self.source_info.span,
419 user_ty: None,
420 const_: Const::from_bool(tcx, false),
421 }));
422 self.elaborator.patch().patch_terminator(
423 panic_bb,
424 TerminatorKind::Assert {
425 cond: false_op,
426 expected: true,
427 msg: Box::new(msg),
428 target: panic_bb,
429 unwind: unwind.into_action(),
430 },
431 );
432 panic_bb
433 }
434
435 {}
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("build_pin_poll_yield_loop",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(450u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("resume_place")
}> =
::tracing::__macro_support::FieldName::new("resume_place");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fut_place")
}> =
::tracing::__macro_support::FieldName::new("fut_place");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("yield_value")
}> =
::tracing::__macro_support::FieldName::new("yield_value");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
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(&resume_place)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fut_place)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&yield_value)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
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:
(BasicBlock, BasicBlock, BasicBlock) = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx();
let source_info = self.source_info;
let resume_arg_ty =
resume_place.ty(self.elaborator.body(), tcx).ty;
let context_ref_ty = Ty::new_task_context(tcx);
let poll_adt_def =
tcx.adt_def(tcx.require_lang_item(LangItem::Poll,
source_info.span));
let poll_enum =
Ty::new_adt(tcx, poll_adt_def,
tcx.mk_args(&[tcx.types.unit.into()]));
let fut_ty =
self.elaborator.patch_ref().local_ty(fut_place.local);
let fut_ref_ty =
Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, fut_ty);
let pin_adt_def =
tcx.adt_def(tcx.require_lang_item(LangItem::Pin,
source_info.span));
let fut_pin_ty =
Ty::new_adt(tcx, pin_adt_def,
tcx.mk_args(&[fut_ref_ty.into()]));
let yield_resume_local = self.new_temp(resume_arg_ty);
let resume_bb =
self.new_block_with_statements(unwind,
{
let len = [(), ()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(resume_place,
Rvalue::Use(Operand::Move(yield_resume_local.into()),
WithRetag::Yes)));
vec.push(self.storage_dead(yield_resume_local));
vec
}, TerminatorKind::Unreachable);
let dropline_bb =
self.new_block_with_statements(unwind,
{
let len = [(), ()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(resume_place,
Rvalue::Use(Operand::Move(yield_resume_local.into()),
WithRetag::Yes)));
vec.push(self.storage_dead(yield_resume_local));
vec
}, TerminatorKind::Unreachable);
let yield_bb =
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.storage_live(yield_resume_local));
vec
},
TerminatorKind::Yield {
value: yield_value,
resume: resume_bb,
resume_arg: yield_resume_local.into(),
drop: Some(dropline_bb),
});
let poll_unit_local = self.new_temp(poll_enum);
let switch_bb =
{
let poll_ready_variant =
tcx.require_lang_item(LangItem::PollReady,
self.source_info.span);
let poll_ready_variant_idx =
poll_adt_def.variant_index_with_id(poll_ready_variant);
let poll_pending_variant =
tcx.require_lang_item(LangItem::PollPending,
self.source_info.span);
let poll_pending_variant_idx =
poll_adt_def.variant_index_with_id(poll_pending_variant);
let Discr { val: poll_ready_discr, ty: poll_discr_ty } =
poll_enum.discriminant_for_variant(tcx,
poll_ready_variant_idx).unwrap();
let Discr { val: poll_pending_discr, ty: _ } =
poll_enum.discriminant_for_variant(tcx,
poll_pending_variant_idx).unwrap();
let poll_discr_local = self.new_temp(poll_discr_ty);
let otherwise_bb =
self.elaborator.patch().unreachable_no_cleanup_block();
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(poll_discr_local.into(),
Rvalue::Discriminant(poll_unit_local.into())));
vec
},
TerminatorKind::SwitchInt {
discr: Operand::Move(poll_discr_local.into()),
targets: SwitchTargets::new([(poll_ready_discr, succ),
(poll_pending_discr, yield_bb)].into_iter(), otherwise_bb),
})
};
let fut_pin_local = self.new_temp(fut_pin_ty);
let context_ref_local = self.new_temp(context_ref_ty);
let poll_fn =
tcx.require_lang_item(LangItem::FuturePoll,
source_info.span);
let poll_bb =
self.new_block_with_statements(unwind, ThinVec::new(),
TerminatorKind::Call {
func: Operand::function_handle(tcx, poll_fn,
&[fut_ty.into()], source_info.span),
args: [dummy_spanned(Operand::Move(fut_pin_local.into())),
dummy_spanned(Operand::Move(context_ref_local.into()))].into(),
destination: poll_unit_local.into(),
target: Some(switch_bb),
unwind: unwind.into_action(),
call_source: CallSource::Misc,
fn_span: source_info.span,
});
let get_context_fn =
tcx.require_lang_item(LangItem::GetContext,
source_info.span);
let get_context_bb =
{
let entry_resume_local = self.new_temp(resume_arg_ty);
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(entry_resume_local.into(),
Rvalue::Use(Operand::Move(resume_place), WithRetag::Yes)));
vec
},
TerminatorKind::Call {
func: Operand::function_handle(tcx, get_context_fn,
&[tcx.lifetimes.re_erased.into(),
tcx.lifetimes.re_erased.into()], source_info.span),
args: [dummy_spanned(Operand::Move(entry_resume_local.into()))].into(),
destination: context_ref_local.into(),
target: Some(poll_bb),
unwind: unwind.into_action(),
call_source: CallSource::Misc,
fn_span: source_info.span,
})
};
let fut_ref_local = self.new_temp(fut_ref_ty);
let fut_pin_new_unchecked_fn =
tcx.require_lang_item(LangItem::PinNewUnchecked,
source_info.span);
let pin_bb =
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(fut_ref_local.into(),
Rvalue::Ref(tcx.lifetimes.re_erased,
BorrowKind::Mut { kind: MutBorrowKind::Default },
fut_place)));
vec
},
TerminatorKind::Call {
func: Operand::function_handle(tcx,
fut_pin_new_unchecked_fn, &[fut_ref_ty.into()],
source_info.span),
args: [dummy_spanned(Operand::Move(fut_ref_local.into()))].into(),
destination: fut_pin_local.into(),
target: Some(get_context_bb),
unwind: unwind.into_action(),
call_source: CallSource::Misc,
fn_span: source_info.span,
});
(pin_bb, resume_bb, dropline_bb)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:450",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(450u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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::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(level = "trace", skip(self), ret)]
451 fn build_pin_poll_yield_loop(
452 &mut self,
453 resume_place: Place<'tcx>,
454 fut_place: Place<'tcx>,
455 yield_value: Operand<'tcx>,
456 succ: BasicBlock,
457 unwind: Unwind,
458 ) -> (BasicBlock, BasicBlock, BasicBlock) {
459 let tcx = self.tcx();
460 let source_info = self.source_info;
461
462 let resume_arg_ty = resume_place.ty(self.elaborator.body(), tcx).ty;
463 let context_ref_ty = Ty::new_task_context(tcx);
464
465 let poll_adt_def = tcx.adt_def(tcx.require_lang_item(LangItem::Poll, source_info.span));
466 let poll_enum = Ty::new_adt(tcx, poll_adt_def, tcx.mk_args(&[tcx.types.unit.into()]));
467
468 let fut_ty = self.elaborator.patch_ref().local_ty(fut_place.local);
469 let fut_ref_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, fut_ty);
470
471 let pin_adt_def = tcx.adt_def(tcx.require_lang_item(LangItem::Pin, source_info.span));
472 let fut_pin_ty = Ty::new_adt(tcx, pin_adt_def, tcx.mk_args(&[fut_ref_ty.into()]));
473
474 let yield_resume_local = self.new_temp(resume_arg_ty);
477 let resume_bb = self.new_block_with_statements(
478 unwind,
479 thin_vec![
480 self.assign(
481 resume_place,
482 Rvalue::Use(Operand::Move(yield_resume_local.into()), WithRetag::Yes),
483 ),
484 self.storage_dead(yield_resume_local),
485 ],
486 TerminatorKind::Unreachable,
488 );
489 let dropline_bb = self.new_block_with_statements(
490 unwind,
491 thin_vec![
492 self.assign(
493 resume_place,
494 Rvalue::Use(Operand::Move(yield_resume_local.into()), WithRetag::Yes),
495 ),
496 self.storage_dead(yield_resume_local),
497 ],
498 TerminatorKind::Unreachable,
500 );
501 let yield_bb = self.new_block_with_statements(
502 unwind,
503 thin_vec![self.storage_live(yield_resume_local)],
504 TerminatorKind::Yield {
505 value: yield_value,
506 resume: resume_bb,
507 resume_arg: yield_resume_local.into(),
508 drop: Some(dropline_bb),
509 },
510 );
511
512 let poll_unit_local = self.new_temp(poll_enum);
513 let switch_bb = {
514 let poll_ready_variant =
515 tcx.require_lang_item(LangItem::PollReady, self.source_info.span);
516 let poll_ready_variant_idx = poll_adt_def.variant_index_with_id(poll_ready_variant);
517 let poll_pending_variant =
518 tcx.require_lang_item(LangItem::PollPending, self.source_info.span);
519 let poll_pending_variant_idx = poll_adt_def.variant_index_with_id(poll_pending_variant);
520
521 let Discr { val: poll_ready_discr, ty: poll_discr_ty } =
522 poll_enum.discriminant_for_variant(tcx, poll_ready_variant_idx).unwrap();
523 let Discr { val: poll_pending_discr, ty: _ } =
524 poll_enum.discriminant_for_variant(tcx, poll_pending_variant_idx).unwrap();
525
526 let poll_discr_local = self.new_temp(poll_discr_ty);
527 let otherwise_bb = self.elaborator.patch().unreachable_no_cleanup_block();
528 self.new_block_with_statements(
529 unwind,
530 thin_vec![
531 self.assign(
532 poll_discr_local.into(),
533 Rvalue::Discriminant(poll_unit_local.into()),
534 ),
535 ],
536 TerminatorKind::SwitchInt {
537 discr: Operand::Move(poll_discr_local.into()),
538 targets: SwitchTargets::new(
539 [
540 (poll_ready_discr, succ),
542 (poll_pending_discr, yield_bb),
544 ]
545 .into_iter(),
546 otherwise_bb,
548 ),
549 },
550 )
551 };
552
553 let fut_pin_local = self.new_temp(fut_pin_ty);
554 let context_ref_local = self.new_temp(context_ref_ty);
555
556 let poll_fn = tcx.require_lang_item(LangItem::FuturePoll, source_info.span);
557 let poll_bb = self.new_block_with_statements(
558 unwind,
559 ThinVec::new(),
560 TerminatorKind::Call {
561 func: Operand::function_handle(tcx, poll_fn, &[fut_ty.into()], source_info.span),
562 args: [
563 dummy_spanned(Operand::Move(fut_pin_local.into())),
564 dummy_spanned(Operand::Move(context_ref_local.into())),
565 ]
566 .into(),
567 destination: poll_unit_local.into(),
568 target: Some(switch_bb),
569 unwind: unwind.into_action(),
570 call_source: CallSource::Misc,
571 fn_span: source_info.span,
572 },
573 );
574
575 let get_context_fn = tcx.require_lang_item(LangItem::GetContext, source_info.span);
576 let get_context_bb = {
577 let entry_resume_local = self.new_temp(resume_arg_ty);
580 self.new_block_with_statements(
581 unwind,
582 thin_vec![self.assign(
583 entry_resume_local.into(),
584 Rvalue::Use(Operand::Move(resume_place), WithRetag::Yes),
585 )],
586 TerminatorKind::Call {
587 func: Operand::function_handle(
588 tcx,
589 get_context_fn,
590 &[tcx.lifetimes.re_erased.into(), tcx.lifetimes.re_erased.into()],
591 source_info.span,
592 ),
593 args: [dummy_spanned(Operand::Move(entry_resume_local.into()))].into(),
594 destination: context_ref_local.into(),
595 target: Some(poll_bb),
596 unwind: unwind.into_action(),
597 call_source: CallSource::Misc,
598 fn_span: source_info.span,
599 },
600 )
601 };
602
603 let fut_ref_local = self.new_temp(fut_ref_ty);
604 let fut_pin_new_unchecked_fn =
605 tcx.require_lang_item(LangItem::PinNewUnchecked, source_info.span);
606 let pin_bb = self.new_block_with_statements(
607 unwind,
608 thin_vec![self.assign(
609 fut_ref_local.into(),
610 Rvalue::Ref(
611 tcx.lifetimes.re_erased,
612 BorrowKind::Mut { kind: MutBorrowKind::Default },
613 fut_place,
614 ),
615 )],
616 TerminatorKind::Call {
617 func: Operand::function_handle(
618 tcx,
619 fut_pin_new_unchecked_fn,
620 &[fut_ref_ty.into()],
621 source_info.span,
622 ),
623 args: [dummy_spanned(Operand::Move(fut_ref_local.into()))].into(),
624 destination: fut_pin_local.into(),
625 target: Some(get_context_bb),
626 unwind: unwind.into_action(),
627 call_source: CallSource::Misc,
628 fn_span: source_info.span,
629 },
630 );
631
632 (pin_bb, resume_bb, dropline_bb)
633 }
634
635 fn build_drop(&mut self, bb: BasicBlock) {
636 let drop_ty = self.place_ty(self.place);
637 if !self.elaborator.patch_ref().block(self.elaborator.body(), bb).is_cleanup
638 && self.check_if_can_async_drop(drop_ty, false)
639 {
640 let async_drop_bb = self.build_async_drop(
641 self.place,
642 drop_ty,
643 self.succ,
644 self.unwind,
645 self.dropline,
646 false,
647 );
648 self.elaborator.patch().patch_terminator(bb, TerminatorKind::goto(async_drop_bb));
649 } else {
650 self.elaborator.patch().patch_terminator(
651 bb,
652 TerminatorKind::Drop {
653 place: self.place,
654 target: self.succ,
655 unwind: self.unwind.into_action(),
656 replace: false,
657 drop: None,
658 },
659 );
660 }
661 }
662
663 fn check_if_can_async_drop(&mut self, drop_ty: Ty<'tcx>, call_destructor_only: bool) -> bool {
665 if !self.elaborator.allow_async_drops()
666 || !self
667 .elaborator
668 .body()
669 .coroutine
670 .as_ref()
671 .is_some_and(|ck| ck.coroutine_kind.is_async_desugaring())
672 {
673 return false;
674 }
675
676 if drop_ty == self.place_ty(Local::arg(0).into()) {
677 return false;
678 }
679
680 let is_async_drop_feature_enabled = if self.tcx().features().async_drop() {
681 true
682 } else {
683 if let ty::Adt(adt_def, _) = drop_ty.kind() {
685 !adt_def.did().is_local() && adt_def.async_destructor(self.tcx()).is_some()
686 } else {
687 false
688 }
689 };
690
691 if !is_async_drop_feature_enabled {
695 return false;
696 }
697
698 let needs_async_drop = if call_destructor_only {
699 drop_ty.is_async_drop(self.tcx(), self.elaborator.typing_env())
700 } else {
701 drop_ty.needs_async_drop(self.tcx(), self.elaborator.typing_env())
702 };
703
704 if needs_async_drop && self.tcx().features().staged_api() {
706 ::rustc_span::macros::bug_impl(Some(self.source_info.span),
format_args!("don\'t use async drop in libstd, it becomes insta-stable"),
Location::caller());span_bug!(
707 self.source_info.span,
708 "don't use async drop in libstd, it becomes insta-stable"
709 );
710 }
711
712 needs_async_drop
713 }
714
715 {}
#[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("elaborate_drop",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(733u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self")
}> =
::tracing::__macro_support::FieldName::new("self");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("bb")
}> =
::tracing::__macro_support::FieldName::new("bb");
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(&self)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bb)
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;
}
{
match self.elaborator.drop_style(self.path, DropFlagMode::Deep) {
DropStyle::Dead => {
self.elaborator.patch().patch_terminator(bb,
TerminatorKind::goto(self.succ));
}
DropStyle::Static => { self.build_drop(bb); }
DropStyle::Conditional => {
let drop_bb = self.complete_drop(self.succ, self.unwind);
self.elaborator.patch().patch_terminator(bb,
TerminatorKind::goto(drop_bb));
}
DropStyle::Open => {
let drop_bb = self.open_drop();
self.elaborator.patch().patch_terminator(bb,
TerminatorKind::goto(drop_bb));
}
}
}
}
}#[instrument(level = "debug")]
734 fn elaborate_drop(&mut self, bb: BasicBlock) {
735 match self.elaborator.drop_style(self.path, DropFlagMode::Deep) {
736 DropStyle::Dead => {
737 self.elaborator.patch().patch_terminator(bb, TerminatorKind::goto(self.succ));
738 }
739 DropStyle::Static => {
740 self.build_drop(bb);
741 }
742 DropStyle::Conditional => {
743 let drop_bb = self.complete_drop(self.succ, self.unwind);
744 self.elaborator.patch().patch_terminator(bb, TerminatorKind::goto(drop_bb));
745 }
746 DropStyle::Open => {
747 let drop_bb = self.open_drop();
748 self.elaborator.patch().patch_terminator(bb, TerminatorKind::goto(drop_bb));
749 }
750 }
751 }
752
753 fn move_paths_for_fields(
756 &self,
757 base_place: Place<'tcx>,
758 variant_path: D::Path,
759 variant: &'tcx ty::VariantDef,
760 args: GenericArgs<'tcx>,
761 ) -> Vec<(Place<'tcx>, Option<D::Path>)> {
762 variant
763 .fields
764 .iter_enumerated()
765 .map(|(field_idx, field)| {
766 let subpath = self.elaborator.field_subpath(variant_path, field_idx);
767 let tcx = self.tcx();
768
769 match self.elaborator.typing_env().typing_mode().assert_not_erased() {
770 ty::TypingMode::PostAnalysis | ty::TypingMode::Codegen => {}
771 ty::TypingMode::Coherence
772 | ty::TypingMode::Reflection
773 | ty::TypingMode::Typeck { .. }
774 | ty::TypingMode::PostTypeckThroughBorrowck { .. }
775 | ty::TypingMode::PostBorrowck { .. } => {
776 ::rustc_span::macros::bug_impl(None, format_args!("impossible case reached"),
Location::caller())bug!()
777 }
778 }
779
780 let field_ty = field.ty(tcx, args);
781 let field_ty = tcx
784 .try_normalize_erasing_regions(self.elaborator.typing_env(), field_ty)
785 .unwrap_or(field_ty.skip_norm_wip());
786
787 (tcx.mk_place_field(base_place, field_idx, field_ty), subpath)
788 })
789 .filter(|path| self.should_retain_for_ladder(path))
790 .collect()
791 }
792
793 {}
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("drop_subpath",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(793u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("place")
}> =
::tracing::__macro_support::FieldName::new("place");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("path")
}> =
::tracing::__macro_support::FieldName::new("path");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dropline")
}> =
::tracing::__macro_support::FieldName::new("dropline");
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(&place)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dropline)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
if let Some(path) = path {
DropCtxt {
elaborator: self.elaborator,
source_info: self.source_info,
path,
place,
succ,
unwind,
dropline,
}.elaborated_drop_block()
} else {
DropCtxt {
elaborator: self.elaborator,
source_info: self.source_info,
place,
succ,
unwind,
dropline,
path: self.path,
}.complete_drop(succ, unwind)
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:793",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(793u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
794 fn drop_subpath(
795 &mut self,
796 place: Place<'tcx>,
797 path: Option<D::Path>,
798 succ: BasicBlock,
799 unwind: Unwind,
800 dropline: Option<BasicBlock>,
801 ) -> BasicBlock {
802 if let Some(path) = path {
803 DropCtxt {
804 elaborator: self.elaborator,
805 source_info: self.source_info,
806 path,
807 place,
808 succ,
809 unwind,
810 dropline,
811 }
812 .elaborated_drop_block()
813 } else {
814 DropCtxt {
815 elaborator: self.elaborator,
816 source_info: self.source_info,
817 place,
818 succ,
819 unwind,
820 dropline,
821 path: self.path,
823 }
824 .complete_drop(succ, unwind)
825 }
826 }
827
828 {}
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("drop_halfladder",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(838u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind_ladder")
}> =
::tracing::__macro_support::FieldName::new("unwind_ladder");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dropline_ladder")
}> =
::tracing::__macro_support::FieldName::new("dropline_ladder");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fields")
}> =
::tracing::__macro_support::FieldName::new("fields");
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(&unwind_ladder)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dropline_ladder)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fields)
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: Vec<BasicBlock> = loop {};
return __tracing_attr_fake_return;
}
{
iter::once(succ).chain(::itertools::__std_iter::Iterator::map(::itertools::__std_iter::Iterator::zip(::itertools::__std_iter::IntoIterator::into_iter(fields.iter().rev()),
::itertools::__std_iter::Iterator::zip(::itertools::__std_iter::IntoIterator::into_iter(unwind_ladder),
::itertools::__std_iter::IntoIterator::into_iter(dropline_ladder))),
|(b, (b, a))|
(b, b,
a)).map(|(&(place, path), &unwind_succ, &dropline_to)|
{
succ =
self.drop_subpath(place, path, succ, unwind_succ,
dropline_to);
succ
})).collect()
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:838",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(838u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
839 fn drop_halfladder(
840 &mut self,
841 unwind_ladder: &[Unwind],
842 dropline_ladder: &[Option<BasicBlock>],
843 mut succ: BasicBlock,
844 fields: &[(Place<'tcx>, Option<D::Path>)],
845 ) -> Vec<BasicBlock> {
846 iter::once(succ)
847 .chain(itertools::izip!(fields.iter().rev(), unwind_ladder, dropline_ladder).map(
848 |(&(place, path), &unwind_succ, &dropline_to)| {
849 succ = self.drop_subpath(place, path, succ, unwind_succ, dropline_to);
850 succ
851 },
852 ))
853 .collect()
854 }
855
856 fn drop_ladder_bottom(&mut self) -> (BasicBlock, Unwind, Option<BasicBlock>) {
857 (
861 self.drop_flag_reset_block(DropFlagMode::Shallow, self.succ, self.unwind),
862 self.unwind,
863 self.dropline,
864 )
865 }
866
867 fn should_retain_for_ladder(&self, (place, subpath): &(Place<'tcx>, Option<D::Path>)) -> bool {
869 if !self.place_ty(*place).needs_drop(self.tcx(), self.elaborator.typing_env()) {
870 return false;
871 }
872 if let Some(subpath) = subpath
873 && let DropStyle::Dead = self.elaborator.drop_style(*subpath, DropFlagMode::Deep)
874 {
875 return false;
876 }
877 true
878 }
879
880 {}
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("drop_ladder",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(917u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fields")
}> =
::tracing::__macro_support::FieldName::new("fields");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dropline")
}> =
::tracing::__macro_support::FieldName::new("dropline");
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(&fields)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dropline)
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:
(BasicBlock, Unwind, Option<BasicBlock>) = loop {};
return __tracing_attr_fake_return;
}
{
if !if unwind.is_cleanup() {
dropline.is_none()
} else { true } {
{
::core::panicking::panic_fmt(format_args!("Dropline is set for cleanup drop ladder"));
}
};
fields.retain(|path| self.should_retain_for_ladder(path));
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:932",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(932u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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_ladder - fields needing drop: {0:?}",
fields) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let dropline_ladder: Vec<Option<BasicBlock>> =
::alloc::vec::from_elem_global(None, fields.len() + 1);
let unwind_ladder =
::alloc::vec::from_elem_global(Unwind::InCleanup,
fields.len() + 1);
let unwind_ladder: Vec<_> =
if let Unwind::To(succ) = unwind {
let halfladder =
self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ,
&fields);
halfladder.into_iter().map(Unwind::To).collect()
} else { unwind_ladder };
let dropline_ladder: Vec<_> =
if let Some(succ) = dropline {
let halfladder =
self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ,
&fields);
halfladder.into_iter().map(Some).collect()
} else { dropline_ladder };
let normal_ladder =
self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ,
&fields);
(*normal_ladder.last().unwrap(),
*unwind_ladder.last().unwrap(),
*dropline_ladder.last().unwrap())
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:917",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(917u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
918 fn drop_ladder(
919 &mut self,
920 mut fields: Vec<(Place<'tcx>, Option<D::Path>)>,
921 succ: BasicBlock,
922 unwind: Unwind,
923 dropline: Option<BasicBlock>,
924 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
925 assert!(
926 if unwind.is_cleanup() { dropline.is_none() } else { true },
927 "Dropline is set for cleanup drop ladder"
928 );
929
930 fields.retain(|path| self.should_retain_for_ladder(path));
931
932 debug!("drop_ladder - fields needing drop: {:?}", fields);
933
934 let dropline_ladder: Vec<Option<BasicBlock>> = vec![None; fields.len() + 1];
935 let unwind_ladder = vec![Unwind::InCleanup; fields.len() + 1];
936 let unwind_ladder: Vec<_> = if let Unwind::To(succ) = unwind {
937 let halfladder = self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ, &fields);
938 halfladder.into_iter().map(Unwind::To).collect()
939 } else {
940 unwind_ladder
941 };
942 let dropline_ladder: Vec<_> = if let Some(succ) = dropline {
943 let halfladder = self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ, &fields);
944 halfladder.into_iter().map(Some).collect()
945 } else {
946 dropline_ladder
947 };
948
949 let normal_ladder = self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ, &fields);
950
951 (
952 *normal_ladder.last().unwrap(),
953 *unwind_ladder.last().unwrap(),
954 *dropline_ladder.last().unwrap(),
955 )
956 }
957
958 {}
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("open_drop_for_tuple",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(958u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("tys")
}> =
::tracing::__macro_support::FieldName::new("tys");
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(&tys)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let fields =
tys.iter().enumerate().map(|(i, &ty)|
{
(self.tcx().mk_place_field(self.place, FieldIdx::new(i),
ty),
self.elaborator.field_subpath(self.path, FieldIdx::new(i)))
}).collect();
let (succ, unwind, dropline) = self.drop_ladder_bottom();
self.drop_ladder(fields, succ, unwind, dropline).0
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:958",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(958u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
959 fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock {
960 let fields = tys
961 .iter()
962 .enumerate()
963 .map(|(i, &ty)| {
964 (
965 self.tcx().mk_place_field(self.place, FieldIdx::new(i), ty),
966 self.elaborator.field_subpath(self.path, FieldIdx::new(i)),
967 )
968 })
969 .collect();
970
971 let (succ, unwind, dropline) = self.drop_ladder_bottom();
972 self.drop_ladder(fields, succ, unwind, dropline).0
973 }
974
975 {}
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("open_drop_for_box_contents",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(976u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self")
}> =
::tracing::__macro_support::FieldName::new("self");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("adt")
}> =
::tracing::__macro_support::FieldName::new("adt");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dropline")
}> =
::tracing::__macro_support::FieldName::new("dropline");
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(&self)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&adt)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dropline)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let unique_ty =
adt.non_enum_variant().fields[FieldIdx::ZERO].ty(self.tcx(),
args).skip_norm_wip();
let unique_variant =
unique_ty.ty_adt_def().unwrap().non_enum_variant();
let nonnull_ty =
unique_variant.fields[FieldIdx::ZERO].ty(self.tcx(),
args).skip_norm_wip();
let ptr_ty =
Ty::new_imm_ptr(self.tcx(), args[0].expect_ty());
let unique_place =
self.tcx().mk_place_field(self.place, FieldIdx::ZERO,
unique_ty);
let nonnull_place =
self.tcx().mk_place_field(unique_place, FieldIdx::ZERO,
nonnull_ty);
let ptr_local = self.new_temp(ptr_ty);
let interior =
self.tcx().mk_place_deref(Place::from(ptr_local));
let interior_path =
self.elaborator.deref_subpath(self.path);
let do_drop_bb =
self.drop_subpath(interior, interior_path, succ, unwind,
dropline);
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(Place::from(ptr_local),
Rvalue::Cast(CastKind::Transmute,
Operand::Copy(nonnull_place), ptr_ty)));
vec
}, TerminatorKind::goto(do_drop_bb))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:976",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(976u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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", ret)]
977 fn open_drop_for_box_contents(
978 &mut self,
979 adt: ty::AdtDef<'tcx>,
980 args: GenericArgs<'tcx>,
981 succ: BasicBlock,
982 unwind: Unwind,
983 dropline: Option<BasicBlock>,
984 ) -> BasicBlock {
985 let unique_ty =
988 adt.non_enum_variant().fields[FieldIdx::ZERO].ty(self.tcx(), args).skip_norm_wip();
989 let unique_variant = unique_ty.ty_adt_def().unwrap().non_enum_variant();
990 let nonnull_ty = unique_variant.fields[FieldIdx::ZERO].ty(self.tcx(), args).skip_norm_wip();
991 let ptr_ty = Ty::new_imm_ptr(self.tcx(), args[0].expect_ty());
992
993 let unique_place = self.tcx().mk_place_field(self.place, FieldIdx::ZERO, unique_ty);
994 let nonnull_place = self.tcx().mk_place_field(unique_place, FieldIdx::ZERO, nonnull_ty);
995
996 let ptr_local = self.new_temp(ptr_ty);
997
998 let interior = self.tcx().mk_place_deref(Place::from(ptr_local));
999 let interior_path = self.elaborator.deref_subpath(self.path);
1000
1001 let do_drop_bb = self.drop_subpath(interior, interior_path, succ, unwind, dropline);
1002
1003 self.new_block_with_statements(
1004 unwind,
1005 thin_vec![self.assign(
1006 Place::from(ptr_local),
1007 Rvalue::Cast(CastKind::Transmute, Operand::Copy(nonnull_place), ptr_ty),
1008 )],
1009 TerminatorKind::goto(do_drop_bb),
1010 )
1011 }
1012
1013 {}
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("open_drop_for_adt",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1013u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self")
}> =
::tracing::__macro_support::FieldName::new("self");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("adt")
}> =
::tracing::__macro_support::FieldName::new("adt");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
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(&self)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&adt)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
if adt.variants().is_empty() {
return self.new_block(self.unwind,
TerminatorKind::Unreachable);
}
let skip_contents =
adt.is_union() || adt.is_manually_drop();
let (contents_succ, contents_unwind, contents_dropline) =
if skip_contents {
if adt.has_dtor(self.tcx()) &&
self.elaborator.get_drop_flag(self.path).is_some() {
::rustc_span::macros::bug_impl(Some(self.source_info.span),
format_args!("open dropping partially moved union"),
Location::caller());
}
(self.succ, self.unwind, self.dropline)
} else { self.open_drop_for_adt_contents(adt, args) };
if adt.has_dtor(self.tcx()) {
let destructor_block =
if adt.is_box() {
let succ =
self.destructor_call_block_sync(contents_succ,
contents_unwind);
let unwind =
contents_unwind.map(|unwind|
self.destructor_call_block_sync(unwind, Unwind::InCleanup));
let dropline =
contents_dropline.map(|dropline|
self.destructor_call_block_sync(dropline, contents_unwind));
self.open_drop_for_box_contents(adt, args, succ, unwind,
dropline)
} else {
self.destructor_call_block(contents_succ, contents_unwind,
contents_dropline)
};
self.drop_flag_test_block(destructor_block, contents_succ,
contents_unwind)
} else { contents_succ }
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1013",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1013u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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", ret)]
1014 fn open_drop_for_adt(&mut self, adt: ty::AdtDef<'tcx>, args: GenericArgs<'tcx>) -> BasicBlock {
1015 if adt.variants().is_empty() {
1016 return self.new_block(self.unwind, TerminatorKind::Unreachable);
1017 }
1018
1019 let skip_contents = adt.is_union() || adt.is_manually_drop();
1020 let (contents_succ, contents_unwind, contents_dropline) = if skip_contents {
1021 if adt.has_dtor(self.tcx()) && self.elaborator.get_drop_flag(self.path).is_some() {
1022 span_bug!(self.source_info.span, "open dropping partially moved union");
1029 }
1030
1031 (self.succ, self.unwind, self.dropline)
1032 } else {
1033 self.open_drop_for_adt_contents(adt, args)
1034 };
1035
1036 if adt.has_dtor(self.tcx()) {
1037 let destructor_block = if adt.is_box() {
1038 let succ = self.destructor_call_block_sync(contents_succ, contents_unwind);
1040 let unwind = contents_unwind
1041 .map(|unwind| self.destructor_call_block_sync(unwind, Unwind::InCleanup));
1042 let dropline = contents_dropline
1043 .map(|dropline| self.destructor_call_block_sync(dropline, contents_unwind));
1044 self.open_drop_for_box_contents(adt, args, succ, unwind, dropline)
1045 } else {
1046 self.destructor_call_block(contents_succ, contents_unwind, contents_dropline)
1047 };
1048
1049 self.drop_flag_test_block(destructor_block, contents_succ, contents_unwind)
1050 } else {
1051 contents_succ
1052 }
1053 }
1054
1055 fn open_drop_for_adt_contents(
1056 &mut self,
1057 adt: ty::AdtDef<'tcx>,
1058 args: GenericArgs<'tcx>,
1059 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
1060 let (succ, unwind, dropline) = self.drop_ladder_bottom();
1061 if !adt.is_enum() {
1062 let fields =
1063 self.move_paths_for_fields(self.place, self.path, adt.variant(FIRST_VARIANT), args);
1064 self.drop_ladder(fields, succ, unwind, dropline)
1065 } else {
1066 self.open_drop_for_multivariant(adt, args, succ, unwind, dropline)
1067 }
1068 }
1069
1070 fn open_drop_for_multivariant(
1071 &mut self,
1072 adt: ty::AdtDef<'tcx>,
1073 args: GenericArgs<'tcx>,
1074 succ: BasicBlock,
1075 unwind: Unwind,
1076 dropline: Option<BasicBlock>,
1077 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
1078 let mut values = Vec::with_capacity(adt.variants().len());
1079 let mut normal_blocks = Vec::with_capacity(adt.variants().len());
1080 let mut unwind_blocks =
1081 Vec::with_capacity(if unwind.is_cleanup() { 0 } else { adt.variants().len() });
1082 let mut dropline_blocks =
1083 Vec::with_capacity(if dropline.is_none() { 0 } else { adt.variants().len() });
1084
1085 let mut have_otherwise_with_drop_glue = false;
1086 let mut have_otherwise = false;
1087 let tcx = self.tcx();
1088
1089 for (variant_index, discr) in adt.discriminants(tcx) {
1090 let variant = &adt.variant(variant_index);
1091 let subpath = self.elaborator.downcast_subpath(self.path, variant_index);
1092
1093 if let Some(variant_path) = subpath {
1094 let base_place = tcx.mk_place_elem(
1095 self.place,
1096 ProjectionElem::Downcast(Some(variant.name), variant_index),
1097 );
1098 let fields = self.move_paths_for_fields(base_place, variant_path, variant, args);
1099 values.push(discr.val);
1100 if let Unwind::To(unwind) = unwind {
1101 let unwind_ladder = ::alloc::vec::from_elem_global(Unwind::InCleanup, fields.len() + 1)vec![Unwind::InCleanup; fields.len() + 1];
1120 let dropline_ladder: Vec<Option<BasicBlock>> = ::alloc::vec::from_elem_global(None, fields.len() + 1)vec![None; fields.len() + 1];
1121 let halfladder =
1122 self.drop_halfladder(&unwind_ladder, &dropline_ladder, unwind, &fields);
1123 unwind_blocks.push(halfladder.last().cloned().unwrap());
1124 }
1125 let (normal, _, drop_bb) = self.drop_ladder(fields, succ, unwind, dropline);
1126 normal_blocks.push(normal);
1127 if dropline.is_some() {
1128 dropline_blocks.push(drop_bb.unwrap());
1129 }
1130 } else {
1131 have_otherwise = true;
1132
1133 let typing_env = self.elaborator.typing_env();
1134 let have_field_with_drop_glue = variant
1135 .fields
1136 .iter()
1137 .any(|field| field.ty(tcx, args).skip_norm_wip().needs_drop(tcx, typing_env));
1138 if have_field_with_drop_glue {
1139 have_otherwise_with_drop_glue = true;
1140 }
1141 }
1142 }
1143
1144 if !have_otherwise {
1145 values.pop();
1146 } else if !have_otherwise_with_drop_glue {
1147 normal_blocks.push(succ);
1148 if let Unwind::To(unwind) = unwind {
1149 unwind_blocks.push(unwind);
1150 }
1151 if let Some(dropline) = dropline {
1152 dropline_blocks.push(dropline);
1153 }
1154 } else {
1155 normal_blocks.push(self.drop_block(succ, unwind));
1156 if let Unwind::To(unwind) = unwind {
1157 unwind_blocks.push(self.drop_block(unwind, Unwind::InCleanup));
1158 }
1159 if let Some(dropline) = dropline {
1160 dropline_blocks.push(self.drop_block(dropline, unwind));
1161 }
1162 }
1163
1164 (
1165 self.adt_switch_block(adt, normal_blocks, &values, succ, unwind),
1166 unwind.map(|unwind| {
1167 self.adt_switch_block(adt, unwind_blocks, &values, unwind, Unwind::InCleanup)
1168 }),
1169 dropline.map(|dropline| {
1170 self.adt_switch_block(adt, dropline_blocks, &values, dropline, unwind)
1171 }),
1172 )
1173 }
1174
1175 fn adt_switch_block(
1176 &mut self,
1177 adt: ty::AdtDef<'tcx>,
1178 blocks: Vec<BasicBlock>,
1179 values: &[u128],
1180 succ: BasicBlock,
1181 unwind: Unwind,
1182 ) -> BasicBlock {
1183 let switch_block = blocks.iter().copied().all_equal_value().unwrap_or_else(|_| {
1184 let discr_ty = adt.repr().discr_type().to_ty(self.tcx());
1192 let discr = Place::from(self.new_temp(discr_ty));
1193 let discr_rv = Rvalue::Discriminant(self.place);
1194 self.new_block_with_statements(
1195 unwind,
1196 {
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(discr, discr_rv));
vec
}thin_vec![self.assign(discr, discr_rv)],
1197 TerminatorKind::SwitchInt {
1198 discr: Operand::Move(discr),
1199 targets: SwitchTargets::new(
1200 values.iter().copied().zip(blocks.iter().copied()),
1201 *blocks.last().unwrap(),
1202 ),
1203 },
1204 )
1205 });
1206 self.drop_flag_test_block(switch_block, succ, unwind)
1207 }
1208
1209 {}
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("destructor_call_block_sync",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1209u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
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(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx();
let drop_trait =
tcx.require_lang_item(LangItem::Drop, DUMMY_SP);
let drop_fn = tcx.associated_item_def_ids(drop_trait)[0];
let ty = self.place_ty(self.place);
let ref_ty =
Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, ty);
let ref_place = self.new_temp(ref_ty);
let unit_temp = Place::from(self.new_temp(tcx.types.unit));
self.new_block_with_statements(unwind,
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(Place::from(ref_place),
Rvalue::Ref(tcx.lifetimes.re_erased,
BorrowKind::Mut { kind: MutBorrowKind::Default },
self.place)));
vec
},
TerminatorKind::Call {
func: Operand::function_handle(tcx, drop_fn, &[ty.into()],
self.source_info.span),
args: [dummy_spanned(Operand::Move(Place::from(ref_place)))].into(),
destination: unit_temp,
target: Some(succ),
unwind: unwind.into_action(),
call_source: CallSource::Misc,
fn_span: self.source_info.span,
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1209",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1209u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1210 fn destructor_call_block_sync(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
1211 let tcx = self.tcx();
1212 let drop_trait = tcx.require_lang_item(LangItem::Drop, DUMMY_SP);
1213 let drop_fn = tcx.associated_item_def_ids(drop_trait)[0];
1214 let ty = self.place_ty(self.place);
1215
1216 let ref_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, ty);
1217 let ref_place = self.new_temp(ref_ty);
1218 let unit_temp = Place::from(self.new_temp(tcx.types.unit));
1219
1220 self.new_block_with_statements(
1221 unwind,
1222 thin_vec![self.assign(
1223 Place::from(ref_place),
1224 Rvalue::Ref(
1225 tcx.lifetimes.re_erased,
1226 BorrowKind::Mut { kind: MutBorrowKind::Default },
1227 self.place,
1228 ),
1229 )],
1230 TerminatorKind::Call {
1231 func: Operand::function_handle(tcx, drop_fn, &[ty.into()], self.source_info.span),
1232 args: [dummy_spanned(Operand::Move(Place::from(ref_place)))].into(),
1233 destination: unit_temp,
1234 target: Some(succ),
1235 unwind: unwind.into_action(),
1236 call_source: CallSource::Misc,
1237 fn_span: self.source_info.span,
1238 },
1239 )
1240 }
1241
1242 {}
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("destructor_call_block",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1242u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dropline")
}> =
::tracing::__macro_support::FieldName::new("dropline");
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(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dropline)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let ty = self.place_ty(self.place);
if !unwind.is_cleanup() &&
self.check_if_can_async_drop(ty, true) {
self.build_async_drop(self.place, ty, succ, unwind,
dropline, true)
} else { self.destructor_call_block_sync(succ, unwind) }
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1242",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1242u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1243 fn destructor_call_block(
1244 &mut self,
1245 succ: BasicBlock,
1246 unwind: Unwind,
1247 dropline: Option<BasicBlock>,
1248 ) -> BasicBlock {
1249 let ty = self.place_ty(self.place);
1250 if !unwind.is_cleanup() && self.check_if_can_async_drop(ty, true) {
1251 self.build_async_drop(self.place, ty, succ, unwind, dropline, true)
1252 } else {
1253 self.destructor_call_block_sync(succ, unwind)
1254 }
1255 }
1256
1257 fn drop_loop(
1269 &mut self,
1270 succ: BasicBlock,
1271 cur: Local,
1272 len: Local,
1273 ety: Ty<'tcx>,
1274 unwind: Unwind,
1275 dropline: Option<BasicBlock>,
1276 ) -> BasicBlock {
1277 let copy = |place: Place<'tcx>| Operand::Copy(place);
1278 let move_ = |place: Place<'tcx>| Operand::Move(place);
1279 let tcx = self.tcx();
1280
1281 let ptr_ty = Ty::new_mut_ptr(tcx, ety);
1282 let ptr = Place::from(self.new_temp(ptr_ty));
1283 let can_go = Place::from(self.new_temp(tcx.types.bool));
1284 let one = self.constant_usize(1);
1285
1286 let drop_block = self.new_block_with_statements(
1287 unwind,
1288 {
let len = [(), ()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(ptr,
Rvalue::RawPtr(RawPtrKind::Mut,
tcx.mk_place_index(self.place, cur))));
vec.push(self.assign(cur.into(),
Rvalue::BinaryOp(BinOp::Add,
Box::new((move_(cur.into()), one)))));
vec
}thin_vec![
1289 self.assign(
1290 ptr,
1291 Rvalue::RawPtr(RawPtrKind::Mut, tcx.mk_place_index(self.place, cur)),
1292 ),
1293 self.assign(
1294 cur.into(),
1295 Rvalue::BinaryOp(BinOp::Add, Box::new((move_(cur.into()), one))),
1296 ),
1297 ],
1298 TerminatorKind::Unreachable,
1300 );
1301
1302 let loop_block = self.new_block_with_statements(
1303 unwind,
1304 {
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(can_go,
Rvalue::BinaryOp(BinOp::Eq,
Box::new((copy(Place::from(cur)), copy(len.into()))))));
vec
}thin_vec![self.assign(
1305 can_go,
1306 Rvalue::BinaryOp(BinOp::Eq, Box::new((copy(Place::from(cur)), copy(len.into())))),
1307 )],
1308 TerminatorKind::if_(move_(can_go), succ, drop_block),
1309 );
1310
1311 let place = tcx.mk_place_deref(ptr);
1312 if !unwind.is_cleanup() && self.check_if_can_async_drop(ety, false) {
1313 let async_drop_bb =
1314 self.build_async_drop(place, ety, loop_block, unwind, dropline, false);
1315 self.elaborator
1316 .patch()
1317 .patch_terminator(drop_block, TerminatorKind::goto(async_drop_bb));
1318 } else {
1319 self.elaborator.patch().patch_terminator(
1320 drop_block,
1321 TerminatorKind::Drop {
1322 place,
1323 target: loop_block,
1324 unwind: unwind.into_action(),
1325 replace: false,
1326 drop: None,
1327 },
1328 );
1329 }
1330 loop_block
1331 }
1332
1333 {}
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("open_drop_for_array",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1333u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("array_ty")
}> =
::tracing::__macro_support::FieldName::new("array_ty");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("ety")
}> =
::tracing::__macro_support::FieldName::new("ety");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("opt_size")
}> =
::tracing::__macro_support::FieldName::new("opt_size");
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(&array_ty)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ety)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opt_size)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx();
if let Some(size) = opt_size {
enum ProjectionKind<Path> {
Drop(std::ops::Range<u64>),
Keep(u64, Path),
}
let mut drop_ranges = ::alloc::vec::Vec::new();
let mut dropping = true;
let mut start = 0;
for i in 0..size {
let path =
self.elaborator.array_subpath(self.path, i, size);
if dropping && path.is_some() {
drop_ranges.push(ProjectionKind::Drop(start..i));
dropping = false;
} else if !dropping && path.is_none() {
dropping = true;
start = i;
}
if let Some(path) = path {
drop_ranges.push(ProjectionKind::Keep(i, path));
}
}
if !drop_ranges.is_empty() {
if dropping {
drop_ranges.push(ProjectionKind::Drop(start..size));
}
let fields =
drop_ranges.iter().map(|p|
{
let (project, path) =
match p {
ProjectionKind::Drop(r) =>
(ProjectionElem::Subslice {
from: r.start,
to: r.end,
from_end: false,
}, None),
&ProjectionKind::Keep(offset, path) =>
(ProjectionElem::ConstantIndex {
offset,
min_length: size,
from_end: false,
}, Some(path)),
};
(tcx.mk_place_elem(self.place, project), path)
}).collect::<Vec<_>>();
let (succ, unwind, dropline) = self.drop_ladder_bottom();
return self.drop_ladder(fields, succ, unwind, dropline).0;
}
}
let array_ptr_ty = Ty::new_mut_ptr(tcx, array_ty);
let array_ptr = self.new_temp(array_ptr_ty);
let slice_ty = Ty::new_slice(tcx, ety);
let slice_ptr_ty = Ty::new_mut_ptr(tcx, slice_ty);
let slice_ptr = self.new_temp(slice_ptr_ty);
let array_place =
mem::replace(&mut self.place,
Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref],
tcx));
let slice_block = self.drop_loop_trio_for_slice(ety);
self.place = array_place;
self.new_block_with_statements(self.unwind,
{
let len = [(), ()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(Place::from(array_ptr),
Rvalue::RawPtr(RawPtrKind::Mut, self.place)));
vec.push(self.assign(Place::from(slice_ptr),
Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::Unsize,
CoercionSource::Implicit),
Operand::Move(Place::from(array_ptr)), slice_ptr_ty)));
vec
}, TerminatorKind::goto(slice_block))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1333",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1333u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1334 fn open_drop_for_array(
1335 &mut self,
1336 array_ty: Ty<'tcx>,
1337 ety: Ty<'tcx>,
1338 opt_size: Option<u64>,
1339 ) -> BasicBlock {
1340 let tcx = self.tcx();
1341
1342 if let Some(size) = opt_size {
1343 enum ProjectionKind<Path> {
1344 Drop(std::ops::Range<u64>),
1345 Keep(u64, Path),
1346 }
1347 let mut drop_ranges = vec![];
1352 let mut dropping = true;
1353 let mut start = 0;
1354 for i in 0..size {
1355 let path = self.elaborator.array_subpath(self.path, i, size);
1356 if dropping && path.is_some() {
1357 drop_ranges.push(ProjectionKind::Drop(start..i));
1358 dropping = false;
1359 } else if !dropping && path.is_none() {
1360 dropping = true;
1361 start = i;
1362 }
1363 if let Some(path) = path {
1364 drop_ranges.push(ProjectionKind::Keep(i, path));
1365 }
1366 }
1367 if !drop_ranges.is_empty() {
1368 if dropping {
1369 drop_ranges.push(ProjectionKind::Drop(start..size));
1370 }
1371 let fields = drop_ranges
1372 .iter()
1373 .map(|p| {
1374 let (project, path) = match p {
1375 ProjectionKind::Drop(r) => (
1376 ProjectionElem::Subslice {
1377 from: r.start,
1378 to: r.end,
1379 from_end: false,
1380 },
1381 None,
1382 ),
1383 &ProjectionKind::Keep(offset, path) => (
1384 ProjectionElem::ConstantIndex {
1385 offset,
1386 min_length: size,
1387 from_end: false,
1388 },
1389 Some(path),
1390 ),
1391 };
1392 (tcx.mk_place_elem(self.place, project), path)
1393 })
1394 .collect::<Vec<_>>();
1395 let (succ, unwind, dropline) = self.drop_ladder_bottom();
1396 return self.drop_ladder(fields, succ, unwind, dropline).0;
1397 }
1398 }
1399
1400 let array_ptr_ty = Ty::new_mut_ptr(tcx, array_ty);
1401 let array_ptr = self.new_temp(array_ptr_ty);
1402
1403 let slice_ty = Ty::new_slice(tcx, ety);
1404 let slice_ptr_ty = Ty::new_mut_ptr(tcx, slice_ty);
1405 let slice_ptr = self.new_temp(slice_ptr_ty);
1406
1407 let array_place = mem::replace(
1408 &mut self.place,
1409 Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref], tcx),
1410 );
1411 let slice_block = self.drop_loop_trio_for_slice(ety);
1412 self.place = array_place;
1413
1414 self.new_block_with_statements(
1415 self.unwind,
1416 thin_vec![
1417 self.assign(Place::from(array_ptr), Rvalue::RawPtr(RawPtrKind::Mut, self.place)),
1418 self.assign(
1419 Place::from(slice_ptr),
1420 Rvalue::Cast(
1421 CastKind::PointerCoercion(
1422 PointerCoercion::Unsize,
1423 CoercionSource::Implicit,
1424 ),
1425 Operand::Move(Place::from(array_ptr)),
1426 slice_ptr_ty,
1427 ),
1428 ),
1429 ],
1430 TerminatorKind::goto(slice_block),
1431 )
1432 }
1433
1434 {}
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("drop_loop_trio_for_slice",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1436u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("ety")
}> =
::tracing::__macro_support::FieldName::new("ety");
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(&ety)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx();
let len = self.new_temp(tcx.types.usize);
let cur = self.new_temp(tcx.types.usize);
let unwind =
self.unwind.map(|unwind|
self.drop_loop(unwind, cur, len, ety, Unwind::InCleanup,
None));
let dropline =
self.dropline.map(|dropline|
self.drop_loop(dropline, cur, len, ety, unwind, None));
let loop_block =
self.drop_loop(self.succ, cur, len, ety, unwind, dropline);
let [PlaceElem::Deref] =
self.place.projection.as_slice() else {
::rustc_span::macros::bug_impl(Some(self.source_info.span),
format_args!("Expected place for slice drop shim to be *_n, but it\'s {0:?}",
self.place), Location::caller());
};
let zero = self.constant_usize(0);
let drop_block =
self.new_block_with_statements(unwind,
{
let len = [(), ()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(self.assign(len.into(),
Rvalue::UnaryOp(UnOp::PtrMetadata,
Operand::Copy(Place::from(self.place.local)))));
vec.push(self.assign(cur.into(),
Rvalue::Use(zero, WithRetag::Yes)));
vec
}, TerminatorKind::goto(loop_block));
let reset_block =
self.drop_flag_reset_block(DropFlagMode::Deep, drop_block,
unwind);
self.drop_flag_test_block(reset_block, self.succ, unwind)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1436",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1436u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1437 fn drop_loop_trio_for_slice(&mut self, ety: Ty<'tcx>) -> BasicBlock {
1438 let tcx = self.tcx();
1439 let len = self.new_temp(tcx.types.usize);
1440 let cur = self.new_temp(tcx.types.usize);
1441
1442 let unwind = self
1443 .unwind
1444 .map(|unwind| self.drop_loop(unwind, cur, len, ety, Unwind::InCleanup, None));
1445
1446 let dropline =
1447 self.dropline.map(|dropline| self.drop_loop(dropline, cur, len, ety, unwind, None));
1448
1449 let loop_block = self.drop_loop(self.succ, cur, len, ety, unwind, dropline);
1450
1451 let [PlaceElem::Deref] = self.place.projection.as_slice() else {
1452 span_bug!(
1453 self.source_info.span,
1454 "Expected place for slice drop shim to be *_n, but it's {:?}",
1455 self.place,
1456 );
1457 };
1458
1459 let zero = self.constant_usize(0);
1460 let drop_block = self.new_block_with_statements(
1461 unwind,
1462 thin_vec![
1463 self.assign(
1464 len.into(),
1465 Rvalue::UnaryOp(
1466 UnOp::PtrMetadata,
1467 Operand::Copy(Place::from(self.place.local)),
1468 ),
1469 ),
1470 self.assign(cur.into(), Rvalue::Use(zero, WithRetag::Yes)),
1471 ],
1472 TerminatorKind::goto(loop_block),
1473 );
1474
1475 let reset_block = self.drop_flag_reset_block(DropFlagMode::Deep, drop_block, unwind);
1477 self.drop_flag_test_block(reset_block, self.succ, unwind)
1478 }
1479
1480 fn open_drop(&mut self) -> BasicBlock {
1489 let ty = self.place_ty(self.place);
1490 match ty.kind() {
1491 ty::Closure(_, args) => self.open_drop_for_tuple(args.as_closure().upvar_tys()),
1492 ty::CoroutineClosure(_, args) => {
1493 self.open_drop_for_tuple(args.as_coroutine_closure().upvar_tys())
1494 }
1495 ty::Coroutine(_, args) => self.open_drop_for_tuple(args.as_coroutine().upvar_tys()),
1502 ty::Tuple(fields) => self.open_drop_for_tuple(fields),
1503 ty::Adt(def, args) => self.open_drop_for_adt(*def, *args),
1504 ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind),
1505 ty::Array(ety, size) => {
1506 let size = size.try_to_target_usize(self.tcx());
1507 self.open_drop_for_array(ty, *ety, size)
1508 }
1509 ty::Slice(ety) => self.drop_loop_trio_for_slice(*ety),
1510
1511 ty::UnsafeBinder(_) => {
1512 self.tcx().dcx().span_delayed_bug(
1515 self.source_info.span,
1516 "open drop for unsafe binder shouldn't be encountered",
1517 );
1518 self.new_block(self.unwind, TerminatorKind::Unreachable)
1519 }
1520
1521 _ => ::rustc_span::macros::bug_impl(Some(self.source_info.span),
format_args!("open drop from non-ADT `{0:?}`", ty), Location::caller())span_bug!(self.source_info.span, "open drop from non-ADT `{:?}`", ty),
1522 }
1523 }
1524
1525 {}
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("complete_drop",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1525u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
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(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let drop_block = self.drop_block(succ, unwind);
self.drop_flag_test_block(drop_block, succ, unwind)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1525",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1525u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1526 fn complete_drop(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
1527 let drop_block = self.drop_block(succ, unwind);
1528 self.drop_flag_test_block(drop_block, succ, unwind)
1529 }
1530
1531 {}
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("drop_flag_reset_block",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1533u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("mode")
}> =
::tracing::__macro_support::FieldName::new("mode");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("succ")
}> =
::tracing::__macro_support::FieldName::new("succ");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
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(&mode)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&succ)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
if unwind.is_cleanup() { return succ; }
let flags = self.elaborator.drop_flags_for(self.path, mode);
let statements: ThinVec<_> =
flags.into_iter().map(|flag|
{
self.assign(flag,
Rvalue::Use(self.constant_bool(DropFlagState::Absent.value()),
WithRetag::Yes))
}).collect();
if statements.is_empty() { return succ; }
self.new_block_with_statements(unwind, statements,
TerminatorKind::goto(succ))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1533",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1533u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1534 fn drop_flag_reset_block(
1535 &mut self,
1536 mode: DropFlagMode,
1537 succ: BasicBlock,
1538 unwind: Unwind,
1539 ) -> BasicBlock {
1540 if unwind.is_cleanup() {
1541 return succ;
1544 }
1545 let flags = self.elaborator.drop_flags_for(self.path, mode);
1546 let statements: ThinVec<_> = flags
1547 .into_iter()
1548 .map(|flag| {
1549 self.assign(
1550 flag,
1551 Rvalue::Use(self.constant_bool(DropFlagState::Absent.value()), WithRetag::Yes),
1552 )
1553 })
1554 .collect();
1555 if statements.is_empty() {
1556 return succ;
1557 }
1558 self.new_block_with_statements(unwind, statements, TerminatorKind::goto(succ))
1559 }
1560
1561 {}
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("elaborated_drop_block",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1561u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let blk =
self.new_block(self.unwind,
TerminatorKind::Drop {
place: self.place,
target: self.succ,
unwind: self.unwind.into_action(),
replace: false,
drop: self.dropline,
});
self.elaborate_drop(blk);
blk
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1561",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1561u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1562 fn elaborated_drop_block(&mut self) -> BasicBlock {
1563 let blk = self.new_block(
1564 self.unwind,
1565 TerminatorKind::Drop {
1566 place: self.place,
1567 target: self.succ,
1568 unwind: self.unwind.into_action(),
1569 replace: false,
1570 drop: self.dropline,
1571 },
1572 );
1573 self.elaborate_drop(blk);
1574 blk
1575 }
1576
1577 fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
1578 let drop_ty = self.place_ty(self.place);
1579 if !unwind.is_cleanup() && self.check_if_can_async_drop(drop_ty, false) {
1580 self.build_async_drop(self.place, drop_ty, self.succ, unwind, self.dropline, false)
1581 } else {
1582 self.new_block(
1583 unwind,
1584 TerminatorKind::Drop {
1585 place: self.place,
1586 target,
1587 unwind: unwind.into_action(),
1588 replace: false,
1589 drop: None,
1590 },
1591 )
1592 }
1593 }
1594
1595 {}
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("drop_flag_test_block",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1600u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("on_set")
}> =
::tracing::__macro_support::FieldName::new("on_set");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("on_unset")
}> =
::tracing::__macro_support::FieldName::new("on_unset");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
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(&on_set)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&on_unset)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unwind)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
let style =
self.elaborator.drop_style(self.path,
DropFlagMode::Shallow);
match style {
DropStyle::Dead => on_unset,
DropStyle::Static => on_set,
DropStyle::Conditional | DropStyle::Open => {
let flag =
self.elaborator.get_drop_flag(self.path).unwrap();
let term = TerminatorKind::if_(flag, on_set, on_unset);
self.new_block(unwind, term)
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1600",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1600u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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)]
1601 fn drop_flag_test_block(
1602 &mut self,
1603 on_set: BasicBlock,
1604 on_unset: BasicBlock,
1605 unwind: Unwind,
1606 ) -> BasicBlock {
1607 let style = self.elaborator.drop_style(self.path, DropFlagMode::Shallow);
1608 match style {
1609 DropStyle::Dead => on_unset,
1610 DropStyle::Static => on_set,
1611 DropStyle::Conditional | DropStyle::Open => {
1612 let flag = self.elaborator.get_drop_flag(self.path).unwrap();
1613 let term = TerminatorKind::if_(flag, on_set, on_unset);
1614 self.new_block(unwind, term)
1615 }
1616 }
1617 }
1618
1619 {}
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("new_block",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1619u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("k")
}> =
::tracing::__macro_support::FieldName::new("k");
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(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&k)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
self.elaborator.patch().new_block(BasicBlockData::new(Terminator {
source_info: self.source_info,
kind: k,
}, unwind.is_cleanup()))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1619",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1619u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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::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(level = "trace", skip(self), ret)]
1620 fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock {
1621 self.elaborator.patch().new_block(BasicBlockData::new(
1622 Terminator { source_info: self.source_info, kind: k },
1623 unwind.is_cleanup(),
1624 ))
1625 }
1626
1627 {}
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("new_block_with_statements",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1627u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_drop"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("unwind")
}> =
::tracing::__macro_support::FieldName::new("unwind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("k")
}> =
::tracing::__macro_support::FieldName::new("k");
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(&unwind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&k)
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: BasicBlock = loop {};
return __tracing_attr_fake_return;
}
{
self.elaborator.patch().new_block(BasicBlockData::new_stmts(statements,
Terminator { source_info: self.source_info, kind: k },
unwind.is_cleanup()))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs:1627",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/75a3786afbc93bbddf2c0259033b63957b45ace1/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1627u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_transform::elaborate_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::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(level = "trace", skip(self, statements), ret)]
1628 fn new_block_with_statements(
1629 &mut self,
1630 unwind: Unwind,
1631 statements: ThinVec<Statement<'tcx>>,
1632 k: TerminatorKind<'tcx>,
1633 ) -> BasicBlock {
1634 self.elaborator.patch().new_block(BasicBlockData::new_stmts(
1635 statements,
1636 Terminator { source_info: self.source_info, kind: k },
1637 unwind.is_cleanup(),
1638 ))
1639 }
1640
1641 fn new_temp(&mut self, ty: Ty<'tcx>) -> Local {
1642 self.elaborator.patch().new_temp(ty, self.source_info.span)
1643 }
1644
1645 fn constant_usize(&self, val: u16) -> Operand<'tcx> {
1646 Operand::Constant(Box::new(ConstOperand {
1647 span: self.source_info.span,
1648 user_ty: None,
1649 const_: Const::from_usize(self.tcx(), val.into()),
1650 }))
1651 }
1652
1653 fn constant_bool(&self, val: bool) -> Operand<'tcx> {
1654 Operand::Constant(Box::new(ConstOperand {
1655 span: self.source_info.span,
1656 user_ty: None,
1657 const_: Const::from_bool(self.tcx(), val),
1658 }))
1659 }
1660
1661 fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> {
1662 Statement::new(self.source_info, StatementKind::Assign(Box::new((lhs, rhs))))
1663 }
1664
1665 fn storage_live(&self, local: Local) -> Statement<'tcx> {
1666 Statement::new(self.source_info, StatementKind::StorageLive(local))
1667 }
1668
1669 fn storage_dead(&self, local: Local) -> Statement<'tcx> {
1670 Statement::new(self.source_info, StatementKind::StorageDead(local))
1671 }
1672}