1use std::{fmt, iter, mem};
2
3use itertools::Itertools;
4use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
5use rustc_data_structures::thin_vec::ThinVec;
6use rustc_hir::attrs::lang_items::LangItem;
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, GenericArgsRef, 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]
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]
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]
fn clone(&self) -> Unwind {
let _: ::core::clone::AssertParamIsClone<BasicBlock>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Unwind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Unwind::To(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "To",
&__self_0),
Unwind::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]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["elaborator", "source_info", "place", "path", "succ", "unwind",
"dropline"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.elaborator, &self.source_info, &self.place, &self.path,
&self.succ, &self.unwind, &&self.dropline];
::core::fmt::Formatter::debug_struct_fields_finish(f, "DropCtxt",
names, values)
}
}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/feaadeeaca7db0594da854e7c8c07495341c7439/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/feaadeeaca7db0594da854e7c8c07495341c7439/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/feaadeeaca7db0594da854e7c8c07495341c7439/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/feaadeeaca7db0594da854e7c8c07495341c7439/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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.storage_dead(fut)])),
TerminatorKind::Goto { target: succ });
let dropline_with_dead =
dropline.map(|target|
{
self.new_block_with_statements(unwind,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.storage_dead(fut)])), TerminatorKind::Goto { target })
});
let unwind_with_dead =
unwind.map(|target|
{
self.new_block_with_statements(Unwind::InCleanup,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.storage_dead(fut)])), 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 {
bug_impl(None, format_args!("impossible case reached"),
Location::caller())
};
let ty::Adt(_option_adt, args) =
*args.type_at(0).kind() else {
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 { target: panic_bb });
self.elaborator.patch().patch_terminator(drop_drop_bb,
TerminatorKind::Goto { target: 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 { target: pin_bb });
self.elaborator.patch().patch_terminator(drop_bb,
TerminatorKind::Goto { target: 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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.storage_live(fut)])),
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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[assign_obj_ref_place])),
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/feaadeeaca7db0594da854e7c8c07495341c7439/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/feaadeeaca7db0594da854e7c8c07495341c7439/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 vec![self.storage_dead(fut)],
265 TerminatorKind::Goto { target: succ },
266 );
267 let dropline_with_dead = dropline.map(|target| {
268 self.new_block_with_statements(
269 unwind,
270 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 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
325 .patch()
326 .patch_terminator(drop_resume_bb, TerminatorKind::Goto { target: panic_bb });
327 self.elaborator
328 .patch()
329 .patch_terminator(drop_drop_bb, TerminatorKind::Goto { target: drop_pin_bb });
330
331 let succ_yield_loop = if dropline_with_dead.is_some() {
338 let (pin_bb, resume_bb, drop_bb) = self.build_pin_poll_yield_loop(
339 CTX_ARG.into(),
340 fut.into(),
341 yield_value,
342 succ_with_dead,
344 unwind_with_dead,
345 );
346 self.elaborator
347 .patch()
348 .patch_terminator(resume_bb, TerminatorKind::Goto { target: pin_bb });
349 self.elaborator
350 .patch()
351 .patch_terminator(drop_bb, TerminatorKind::Goto { target: drop_pin_bb });
352 pin_bb
353 } else {
354 drop_pin_bb
356 };
357
358 let pin_adt_def = tcx.adt_def(tcx.require_lang_item(LangItem::Pin, span));
362 let pin_obj_ty = Ty::new_adt(tcx, pin_adt_def, tcx.mk_args(&[obj_ref_ty.into()]));
363 let pin_obj_local = self.new_temp(pin_obj_ty);
365 let drop_arg = if call_destructor_only {
366 Operand::Move(pin_obj_local.into())
368 } else {
369 Operand::Copy(tcx.mk_place_field(pin_obj_local.into(), FieldIdx::ZERO, obj_ref_ty))
371 };
372 let call_drop_bb = self.new_block_with_statements(
373 unwind_with_dead,
374 vec![self.storage_live(fut)],
375 TerminatorKind::Call {
376 func: Operand::function_handle(tcx, async_drop_fn_def_id, &[drop_ty.into()], span),
377 args: [dummy_spanned(drop_arg)].into(),
378 destination: fut.into(),
379 target: Some(succ_yield_loop),
380 unwind: unwind_with_dead.into_action(),
381 call_source: CallSource::Misc,
382 fn_span: self.source_info.span,
383 },
384 );
385
386 let obj_ref_place = Place::from(self.new_temp(obj_ref_ty));
388 let pin_obj_new_unchecked_fn = tcx.require_lang_item(LangItem::PinNewUnchecked, span);
389 let assign_obj_ref_place = self.assign(
390 obj_ref_place,
391 Rvalue::Ref(
392 tcx.lifetimes.re_erased,
393 BorrowKind::Mut { kind: MutBorrowKind::Default },
394 place,
395 ),
396 );
397 self.new_block_with_statements(
398 unwind,
399 vec![assign_obj_ref_place],
400 TerminatorKind::Call {
401 func: Operand::function_handle(
402 tcx,
403 pin_obj_new_unchecked_fn,
404 &[obj_ref_ty.into()],
405 span,
406 ),
407 args: [dummy_spanned(Operand::Move(obj_ref_place))].into(),
408 destination: pin_obj_local.into(),
409 target: Some(call_drop_bb),
410 unwind: unwind.into_action(),
411 call_source: CallSource::Misc,
412 fn_span: span,
413 },
414 )
415 }
416
417 fn build_resumed_after_drop_abort_block(
418 &mut self,
419 unwind: Unwind,
420 coroutine_kind: CoroutineKind,
421 ) -> BasicBlock {
422 let tcx = self.tcx();
423 let panic_bb = self.new_block(unwind, TerminatorKind::Unreachable);
424 let msg = AssertMessage::ResumedAfterDrop(coroutine_kind);
425 let false_op = Operand::Constant(Box::new(ConstOperand {
426 span: self.source_info.span,
427 user_ty: None,
428 const_: Const::from_bool(tcx, false),
429 }));
430 self.elaborator.patch().patch_terminator(
431 panic_bb,
432 TerminatorKind::Assert {
433 cond: false_op,
434 expected: true,
435 msg: Box::new(msg),
436 target: panic_bb,
437 unwind: unwind.into_action(),
438 },
439 );
440 panic_bb
441 }
442
443 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(458u32),
::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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(resume_place,
Rvalue::Use(Operand::Move(yield_resume_local.into()),
WithRetag::Yes)), self.storage_dead(yield_resume_local)])),
TerminatorKind::Unreachable);
let dropline_bb =
self.new_block_with_statements(unwind,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(resume_place,
Rvalue::Use(Operand::Move(yield_resume_local.into()),
WithRetag::Yes)), self.storage_dead(yield_resume_local)])),
TerminatorKind::Unreachable);
let yield_bb =
self.new_block_with_statements(unwind,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.storage_live(yield_resume_local)])),
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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(poll_discr_local.into(),
Rvalue::Discriminant(poll_unit_local.into()))])),
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, Vec::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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(entry_resume_local.into(),
Rvalue::Use(Operand::Move(resume_place),
WithRetag::Yes))])),
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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(fut_ref_local.into(),
Rvalue::Ref(tcx.lifetimes.re_erased,
BorrowKind::Mut { kind: MutBorrowKind::Default },
fut_place))])),
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:458",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(458u32),
::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)]
459 fn build_pin_poll_yield_loop(
460 &mut self,
461 resume_place: Place<'tcx>,
462 fut_place: Place<'tcx>,
463 yield_value: Operand<'tcx>,
464 succ: BasicBlock,
465 unwind: Unwind,
466 ) -> (BasicBlock, BasicBlock, BasicBlock) {
467 let tcx = self.tcx();
468 let source_info = self.source_info;
469
470 let resume_arg_ty = resume_place.ty(self.elaborator.body(), tcx).ty;
471 let context_ref_ty = Ty::new_task_context(tcx);
472
473 let poll_adt_def = tcx.adt_def(tcx.require_lang_item(LangItem::Poll, source_info.span));
474 let poll_enum = Ty::new_adt(tcx, poll_adt_def, tcx.mk_args(&[tcx.types.unit.into()]));
475
476 let fut_ty = self.elaborator.patch_ref().local_ty(fut_place.local);
477 let fut_ref_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, fut_ty);
478
479 let pin_adt_def = tcx.adt_def(tcx.require_lang_item(LangItem::Pin, source_info.span));
480 let fut_pin_ty = Ty::new_adt(tcx, pin_adt_def, tcx.mk_args(&[fut_ref_ty.into()]));
481
482 let yield_resume_local = self.new_temp(resume_arg_ty);
485 let resume_bb = self.new_block_with_statements(
486 unwind,
487 vec![
488 self.assign(
489 resume_place,
490 Rvalue::Use(Operand::Move(yield_resume_local.into()), WithRetag::Yes),
491 ),
492 self.storage_dead(yield_resume_local),
493 ],
494 TerminatorKind::Unreachable,
496 );
497 let dropline_bb = self.new_block_with_statements(
498 unwind,
499 vec![
500 self.assign(
501 resume_place,
502 Rvalue::Use(Operand::Move(yield_resume_local.into()), WithRetag::Yes),
503 ),
504 self.storage_dead(yield_resume_local),
505 ],
506 TerminatorKind::Unreachable,
508 );
509 let yield_bb = self.new_block_with_statements(
510 unwind,
511 vec![self.storage_live(yield_resume_local)],
512 TerminatorKind::Yield {
513 value: yield_value,
514 resume: resume_bb,
515 resume_arg: yield_resume_local.into(),
516 drop: Some(dropline_bb),
517 },
518 );
519
520 let poll_unit_local = self.new_temp(poll_enum);
521 let switch_bb = {
522 let poll_ready_variant =
523 tcx.require_lang_item(LangItem::PollReady, self.source_info.span);
524 let poll_ready_variant_idx = poll_adt_def.variant_index_with_id(poll_ready_variant);
525 let poll_pending_variant =
526 tcx.require_lang_item(LangItem::PollPending, self.source_info.span);
527 let poll_pending_variant_idx = poll_adt_def.variant_index_with_id(poll_pending_variant);
528
529 let Discr { val: poll_ready_discr, ty: poll_discr_ty } =
530 poll_enum.discriminant_for_variant(tcx, poll_ready_variant_idx).unwrap();
531 let Discr { val: poll_pending_discr, ty: _ } =
532 poll_enum.discriminant_for_variant(tcx, poll_pending_variant_idx).unwrap();
533
534 let poll_discr_local = self.new_temp(poll_discr_ty);
535 let otherwise_bb = self.elaborator.patch().unreachable_no_cleanup_block();
536 self.new_block_with_statements(
537 unwind,
538 vec![
539 self.assign(
540 poll_discr_local.into(),
541 Rvalue::Discriminant(poll_unit_local.into()),
542 ),
543 ],
544 TerminatorKind::SwitchInt {
545 discr: Operand::Move(poll_discr_local.into()),
546 targets: SwitchTargets::new(
547 [
548 (poll_ready_discr, succ),
550 (poll_pending_discr, yield_bb),
552 ]
553 .into_iter(),
554 otherwise_bb,
556 ),
557 },
558 )
559 };
560
561 let fut_pin_local = self.new_temp(fut_pin_ty);
562 let context_ref_local = self.new_temp(context_ref_ty);
563
564 let poll_fn = tcx.require_lang_item(LangItem::FuturePoll, source_info.span);
565 let poll_bb = self.new_block_with_statements(
566 unwind,
567 Vec::new(),
568 TerminatorKind::Call {
569 func: Operand::function_handle(tcx, poll_fn, &[fut_ty.into()], source_info.span),
570 args: [
571 dummy_spanned(Operand::Move(fut_pin_local.into())),
572 dummy_spanned(Operand::Move(context_ref_local.into())),
573 ]
574 .into(),
575 destination: poll_unit_local.into(),
576 target: Some(switch_bb),
577 unwind: unwind.into_action(),
578 call_source: CallSource::Misc,
579 fn_span: source_info.span,
580 },
581 );
582
583 let get_context_fn = tcx.require_lang_item(LangItem::GetContext, source_info.span);
584 let get_context_bb = {
585 let entry_resume_local = self.new_temp(resume_arg_ty);
588 self.new_block_with_statements(
589 unwind,
590 vec![self.assign(
591 entry_resume_local.into(),
592 Rvalue::Use(Operand::Move(resume_place), WithRetag::Yes),
593 )],
594 TerminatorKind::Call {
595 func: Operand::function_handle(
596 tcx,
597 get_context_fn,
598 &[tcx.lifetimes.re_erased.into(), tcx.lifetimes.re_erased.into()],
599 source_info.span,
600 ),
601 args: [dummy_spanned(Operand::Move(entry_resume_local.into()))].into(),
602 destination: context_ref_local.into(),
603 target: Some(poll_bb),
604 unwind: unwind.into_action(),
605 call_source: CallSource::Misc,
606 fn_span: source_info.span,
607 },
608 )
609 };
610
611 let fut_ref_local = self.new_temp(fut_ref_ty);
612 let fut_pin_new_unchecked_fn =
613 tcx.require_lang_item(LangItem::PinNewUnchecked, source_info.span);
614 let pin_bb = self.new_block_with_statements(
615 unwind,
616 vec![self.assign(
617 fut_ref_local.into(),
618 Rvalue::Ref(
619 tcx.lifetimes.re_erased,
620 BorrowKind::Mut { kind: MutBorrowKind::Default },
621 fut_place,
622 ),
623 )],
624 TerminatorKind::Call {
625 func: Operand::function_handle(
626 tcx,
627 fut_pin_new_unchecked_fn,
628 &[fut_ref_ty.into()],
629 source_info.span,
630 ),
631 args: [dummy_spanned(Operand::Move(fut_ref_local.into()))].into(),
632 destination: fut_pin_local.into(),
633 target: Some(get_context_bb),
634 unwind: unwind.into_action(),
635 call_source: CallSource::Misc,
636 fn_span: source_info.span,
637 },
638 );
639
640 (pin_bb, resume_bb, dropline_bb)
641 }
642
643 fn build_drop(&mut self, bb: BasicBlock) {
644 let drop_ty = self.place_ty(self.place);
645 if !self.elaborator.patch_ref().block(self.elaborator.body(), bb).is_cleanup
646 && self.check_if_can_async_drop(drop_ty, false)
647 {
648 let async_drop_bb = self.build_async_drop(
649 self.place,
650 drop_ty,
651 self.succ,
652 self.unwind,
653 self.dropline,
654 false,
655 );
656 self.elaborator
657 .patch()
658 .patch_terminator(bb, TerminatorKind::Goto { target: async_drop_bb });
659 } else {
660 self.elaborator.patch().patch_terminator(
661 bb,
662 TerminatorKind::Drop {
663 place: self.place,
664 target: self.succ,
665 unwind: self.unwind.into_action(),
666 replace: false,
667 drop: None,
668 },
669 );
670 }
671 }
672
673 fn check_if_can_async_drop(&mut self, drop_ty: Ty<'tcx>, call_destructor_only: bool) -> bool {
675 if !self.elaborator.allow_async_drops()
676 || !self
677 .elaborator
678 .body()
679 .coroutine
680 .as_ref()
681 .is_some_and(|ck| ck.coroutine_kind.is_async_desugaring())
682 {
683 return false;
684 }
685
686 if drop_ty == self.place_ty(Local::arg(0).into()) {
687 return false;
688 }
689
690 let is_async_drop_feature_enabled = if self.tcx().features().async_drop() {
691 true
692 } else {
693 if let ty::Adt(adt_def, _) = drop_ty.kind() {
695 !adt_def.did().is_local() && adt_def.async_destructor(self.tcx()).is_some()
696 } else {
697 false
698 }
699 };
700
701 if !is_async_drop_feature_enabled {
705 return false;
706 }
707
708 let needs_async_drop = if call_destructor_only {
709 drop_ty.is_async_drop(self.tcx(), self.elaborator.typing_env())
710 } else {
711 drop_ty.needs_async_drop(self.tcx(), self.elaborator.typing_env())
712 };
713
714 if needs_async_drop && self.tcx().features().staged_api() {
716 bug_impl(Some(self.source_info.span),
format_args!("don\'t use async drop in libstd, it becomes insta-stable"),
Location::caller());span_bug!(
717 self.source_info.span,
718 "don't use async drop in libstd, it becomes insta-stable"
719 );
720 }
721
722 needs_async_drop
723 }
724
725 {}
#[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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(743u32),
::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 { target: 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 { target: drop_bb });
}
DropStyle::Open => {
let drop_bb = self.open_drop();
self.elaborator.patch().patch_terminator(bb,
TerminatorKind::Goto { target: drop_bb });
}
}
}
}
}#[instrument(level = "debug")]
744 fn elaborate_drop(&mut self, bb: BasicBlock) {
745 match self.elaborator.drop_style(self.path, DropFlagMode::Deep) {
746 DropStyle::Dead => {
747 self.elaborator
748 .patch()
749 .patch_terminator(bb, TerminatorKind::Goto { target: self.succ });
750 }
751 DropStyle::Static => {
752 self.build_drop(bb);
753 }
754 DropStyle::Conditional => {
755 let drop_bb = self.complete_drop(self.succ, self.unwind);
756 self.elaborator
757 .patch()
758 .patch_terminator(bb, TerminatorKind::Goto { target: drop_bb });
759 }
760 DropStyle::Open => {
761 let drop_bb = self.open_drop();
762 self.elaborator
763 .patch()
764 .patch_terminator(bb, TerminatorKind::Goto { target: drop_bb });
765 }
766 }
767 }
768
769 fn move_paths_for_fields(
772 &self,
773 base_place: Place<'tcx>,
774 variant_path: D::Path,
775 variant: &'tcx ty::VariantDef,
776 args: GenericArgsRef<'tcx>,
777 ) -> Vec<(Place<'tcx>, Option<D::Path>)> {
778 variant
779 .fields
780 .iter_enumerated()
781 .map(|(field_idx, field)| {
782 let subpath = self.elaborator.field_subpath(variant_path, field_idx);
783 let tcx = self.tcx();
784
785 match self.elaborator.typing_env().typing_mode().assert_not_erased() {
786 ty::TypingMode::PostAnalysis | ty::TypingMode::Codegen => {}
787 ty::TypingMode::Coherence
788 | ty::TypingMode::Reflection
789 | ty::TypingMode::Typeck { .. }
790 | ty::TypingMode::PostTypeckUntilBorrowck { .. }
791 | ty::TypingMode::PostBorrowck { .. } => {
792 bug_impl(None, format_args!("impossible case reached"), Location::caller())bug!()
793 }
794 }
795
796 let field_ty = field.ty(tcx, args);
797 let field_ty = tcx
800 .try_normalize_erasing_regions(self.elaborator.typing_env(), field_ty)
801 .unwrap_or(field_ty.skip_norm_wip());
802
803 (tcx.mk_place_field(base_place, field_idx, field_ty), subpath)
804 })
805 .filter(|path| self.should_retain_for_ladder(path))
806 .collect()
807 }
808
809 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(809u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:809",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(809u32),
::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)]
810 fn drop_subpath(
811 &mut self,
812 place: Place<'tcx>,
813 path: Option<D::Path>,
814 succ: BasicBlock,
815 unwind: Unwind,
816 dropline: Option<BasicBlock>,
817 ) -> BasicBlock {
818 if let Some(path) = path {
819 DropCtxt {
820 elaborator: self.elaborator,
821 source_info: self.source_info,
822 path,
823 place,
824 succ,
825 unwind,
826 dropline,
827 }
828 .elaborated_drop_block()
829 } else {
830 DropCtxt {
831 elaborator: self.elaborator,
832 source_info: self.source_info,
833 place,
834 succ,
835 unwind,
836 dropline,
837 path: self.path,
839 }
840 .complete_drop(succ, unwind)
841 }
842 }
843
844 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(854u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:854",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(854u32),
::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)]
855 fn drop_halfladder(
856 &mut self,
857 unwind_ladder: &[Unwind],
858 dropline_ladder: &[Option<BasicBlock>],
859 mut succ: BasicBlock,
860 fields: &[(Place<'tcx>, Option<D::Path>)],
861 ) -> Vec<BasicBlock> {
862 iter::once(succ)
863 .chain(itertools::izip!(fields.iter().rev(), unwind_ladder, dropline_ladder).map(
864 |(&(place, path), &unwind_succ, &dropline_to)| {
865 succ = self.drop_subpath(place, path, succ, unwind_succ, dropline_to);
866 succ
867 },
868 ))
869 .collect()
870 }
871
872 fn drop_ladder_bottom(&mut self) -> (BasicBlock, Unwind, Option<BasicBlock>) {
873 (
877 self.drop_flag_reset_block(DropFlagMode::Shallow, self.succ, self.unwind),
878 self.unwind,
879 self.dropline,
880 )
881 }
882
883 fn should_retain_for_ladder(&self, (place, subpath): &(Place<'tcx>, Option<D::Path>)) -> bool {
885 if !self.place_ty(*place).needs_drop(self.tcx(), self.elaborator.typing_env()) {
886 return false;
887 }
888 if let Some(subpath) = subpath
889 && let DropStyle::Dead = self.elaborator.drop_style(*subpath, DropFlagMode::Deep)
890 {
891 return false;
892 }
893 true
894 }
895
896 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(933u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:948",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(948u32),
::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(None, fields.len() + 1);
let unwind_ladder =
::alloc::vec::from_elem(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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:933",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(933u32),
::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)]
934 fn drop_ladder(
935 &mut self,
936 mut fields: Vec<(Place<'tcx>, Option<D::Path>)>,
937 succ: BasicBlock,
938 unwind: Unwind,
939 dropline: Option<BasicBlock>,
940 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
941 assert!(
942 if unwind.is_cleanup() { dropline.is_none() } else { true },
943 "Dropline is set for cleanup drop ladder"
944 );
945
946 fields.retain(|path| self.should_retain_for_ladder(path));
947
948 debug!("drop_ladder - fields needing drop: {:?}", fields);
949
950 let dropline_ladder: Vec<Option<BasicBlock>> = vec![None; fields.len() + 1];
951 let unwind_ladder = vec![Unwind::InCleanup; fields.len() + 1];
952 let unwind_ladder: Vec<_> = if let Unwind::To(succ) = unwind {
953 let halfladder = self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ, &fields);
954 halfladder.into_iter().map(Unwind::To).collect()
955 } else {
956 unwind_ladder
957 };
958 let dropline_ladder: Vec<_> = if let Some(succ) = dropline {
959 let halfladder = self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ, &fields);
960 halfladder.into_iter().map(Some).collect()
961 } else {
962 dropline_ladder
963 };
964
965 let normal_ladder = self.drop_halfladder(&unwind_ladder, &dropline_ladder, succ, &fields);
966
967 (
968 *normal_ladder.last().unwrap(),
969 *unwind_ladder.last().unwrap(),
970 *dropline_ladder.last().unwrap(),
971 )
972 }
973
974 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(974u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:974",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(974u32),
::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)]
975 fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock {
976 let fields = tys
977 .iter()
978 .enumerate()
979 .map(|(i, &ty)| {
980 (
981 self.tcx().mk_place_field(self.place, FieldIdx::new(i), ty),
982 self.elaborator.field_subpath(self.path, FieldIdx::new(i)),
983 )
984 })
985 .collect();
986
987 let (succ, unwind, dropline) = self.drop_ladder_bottom();
988 self.drop_ladder(fields, succ, unwind, dropline).0
989 }
990
991 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(992u32),
::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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(Place::from(ptr_local),
Rvalue::Cast(CastKind::Transmute,
Operand::Copy(nonnull_place), ptr_ty))])),
TerminatorKind::Goto { target: 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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:992",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(992u32),
::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)]
993 fn open_drop_for_box_contents(
994 &mut self,
995 adt: ty::AdtDef<'tcx>,
996 args: GenericArgsRef<'tcx>,
997 succ: BasicBlock,
998 unwind: Unwind,
999 dropline: Option<BasicBlock>,
1000 ) -> BasicBlock {
1001 let unique_ty =
1004 adt.non_enum_variant().fields[FieldIdx::ZERO].ty(self.tcx(), args).skip_norm_wip();
1005 let unique_variant = unique_ty.ty_adt_def().unwrap().non_enum_variant();
1006 let nonnull_ty = unique_variant.fields[FieldIdx::ZERO].ty(self.tcx(), args).skip_norm_wip();
1007 let ptr_ty = Ty::new_imm_ptr(self.tcx(), args[0].expect_ty());
1008
1009 let unique_place = self.tcx().mk_place_field(self.place, FieldIdx::ZERO, unique_ty);
1010 let nonnull_place = self.tcx().mk_place_field(unique_place, FieldIdx::ZERO, nonnull_ty);
1011
1012 let ptr_local = self.new_temp(ptr_ty);
1013
1014 let interior = self.tcx().mk_place_deref(Place::from(ptr_local));
1015 let interior_path = self.elaborator.deref_subpath(self.path);
1016
1017 let do_drop_bb = self.drop_subpath(interior, interior_path, succ, unwind, dropline);
1018
1019 self.new_block_with_statements(
1020 unwind,
1021 vec![self.assign(
1022 Place::from(ptr_local),
1023 Rvalue::Cast(CastKind::Transmute, Operand::Copy(nonnull_place), ptr_ty),
1024 )],
1025 TerminatorKind::Goto { target: do_drop_bb },
1026 )
1027 }
1028
1029 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1029u32),
::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() {
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1029",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1029u32),
::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)]
1030 fn open_drop_for_adt(
1031 &mut self,
1032 adt: ty::AdtDef<'tcx>,
1033 args: GenericArgsRef<'tcx>,
1034 ) -> BasicBlock {
1035 if adt.variants().is_empty() {
1036 return self.new_block(self.unwind, TerminatorKind::Unreachable);
1037 }
1038
1039 let skip_contents = adt.is_union() || adt.is_manually_drop();
1040 let (contents_succ, contents_unwind, contents_dropline) = if skip_contents {
1041 if adt.has_dtor(self.tcx()) && self.elaborator.get_drop_flag(self.path).is_some() {
1042 span_bug!(self.source_info.span, "open dropping partially moved union");
1049 }
1050
1051 (self.succ, self.unwind, self.dropline)
1052 } else {
1053 self.open_drop_for_adt_contents(adt, args)
1054 };
1055
1056 if adt.has_dtor(self.tcx()) {
1057 let destructor_block = if adt.is_box() {
1058 let succ = self.destructor_call_block_sync(contents_succ, contents_unwind);
1060 let unwind = contents_unwind
1061 .map(|unwind| self.destructor_call_block_sync(unwind, Unwind::InCleanup));
1062 let dropline = contents_dropline
1063 .map(|dropline| self.destructor_call_block_sync(dropline, contents_unwind));
1064 self.open_drop_for_box_contents(adt, args, succ, unwind, dropline)
1065 } else {
1066 self.destructor_call_block(contents_succ, contents_unwind, contents_dropline)
1067 };
1068
1069 self.drop_flag_test_block(destructor_block, contents_succ, contents_unwind)
1070 } else {
1071 contents_succ
1072 }
1073 }
1074
1075 fn open_drop_for_adt_contents(
1076 &mut self,
1077 adt: ty::AdtDef<'tcx>,
1078 args: GenericArgsRef<'tcx>,
1079 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
1080 let (succ, unwind, dropline) = self.drop_ladder_bottom();
1081 if !adt.is_enum() {
1082 let fields =
1083 self.move_paths_for_fields(self.place, self.path, adt.variant(FIRST_VARIANT), args);
1084 self.drop_ladder(fields, succ, unwind, dropline)
1085 } else {
1086 self.open_drop_for_multivariant(adt, args, succ, unwind, dropline)
1087 }
1088 }
1089
1090 fn open_drop_for_multivariant(
1091 &mut self,
1092 adt: ty::AdtDef<'tcx>,
1093 args: GenericArgsRef<'tcx>,
1094 succ: BasicBlock,
1095 unwind: Unwind,
1096 dropline: Option<BasicBlock>,
1097 ) -> (BasicBlock, Unwind, Option<BasicBlock>) {
1098 let mut values = Vec::with_capacity(adt.variants().len());
1099 let mut normal_blocks = Vec::with_capacity(adt.variants().len());
1100 let mut unwind_blocks =
1101 Vec::with_capacity(if unwind.is_cleanup() { 0 } else { adt.variants().len() });
1102 let mut dropline_blocks =
1103 Vec::with_capacity(if dropline.is_none() { 0 } else { adt.variants().len() });
1104
1105 let mut have_otherwise_with_drop_glue = false;
1106 let mut have_otherwise = false;
1107 let tcx = self.tcx();
1108
1109 for (variant_index, discr) in adt.discriminants(tcx) {
1110 let variant = &adt.variant(variant_index);
1111 let subpath = self.elaborator.downcast_subpath(self.path, variant_index);
1112
1113 if let Some(variant_path) = subpath {
1114 let base_place = tcx.mk_place_elem(
1115 self.place,
1116 ProjectionElem::Downcast(Some(variant.name), variant_index),
1117 );
1118 let fields = self.move_paths_for_fields(base_place, variant_path, variant, args);
1119 values.push(discr.val);
1120 if let Unwind::To(unwind) = unwind {
1121 let unwind_ladder = ::alloc::vec::from_elem(Unwind::InCleanup, fields.len() + 1)vec![Unwind::InCleanup; fields.len() + 1];
1140 let dropline_ladder: Vec<Option<BasicBlock>> = ::alloc::vec::from_elem(None, fields.len() + 1)vec![None; fields.len() + 1];
1141 let halfladder =
1142 self.drop_halfladder(&unwind_ladder, &dropline_ladder, unwind, &fields);
1143 unwind_blocks.push(halfladder.last().cloned().unwrap());
1144 }
1145 let (normal, _, drop_bb) = self.drop_ladder(fields, succ, unwind, dropline);
1146 normal_blocks.push(normal);
1147 if dropline.is_some() {
1148 dropline_blocks.push(drop_bb.unwrap());
1149 }
1150 } else {
1151 have_otherwise = true;
1152
1153 let typing_env = self.elaborator.typing_env();
1154 let have_field_with_drop_glue = variant
1155 .fields
1156 .iter()
1157 .any(|field| field.ty(tcx, args).skip_norm_wip().needs_drop(tcx, typing_env));
1158 if have_field_with_drop_glue {
1159 have_otherwise_with_drop_glue = true;
1160 }
1161 }
1162 }
1163
1164 if !have_otherwise {
1165 values.pop();
1166 } else if !have_otherwise_with_drop_glue {
1167 normal_blocks.push(succ);
1168 if let Unwind::To(unwind) = unwind {
1169 unwind_blocks.push(unwind);
1170 }
1171 if let Some(dropline) = dropline {
1172 dropline_blocks.push(dropline);
1173 }
1174 } else {
1175 normal_blocks.push(self.drop_block(succ, unwind));
1176 if let Unwind::To(unwind) = unwind {
1177 unwind_blocks.push(self.drop_block(unwind, Unwind::InCleanup));
1178 }
1179 if let Some(dropline) = dropline {
1180 dropline_blocks.push(self.drop_block(dropline, unwind));
1181 }
1182 }
1183
1184 (
1185 self.adt_switch_block(adt, normal_blocks, &values, succ, unwind),
1186 unwind.map(|unwind| {
1187 self.adt_switch_block(adt, unwind_blocks, &values, unwind, Unwind::InCleanup)
1188 }),
1189 dropline.map(|dropline| {
1190 self.adt_switch_block(adt, dropline_blocks, &values, dropline, unwind)
1191 }),
1192 )
1193 }
1194
1195 fn adt_switch_block(
1196 &mut self,
1197 adt: ty::AdtDef<'tcx>,
1198 blocks: Vec<BasicBlock>,
1199 values: &[u128],
1200 succ: BasicBlock,
1201 unwind: Unwind,
1202 ) -> BasicBlock {
1203 let switch_block = blocks.iter().copied().all_equal_value().unwrap_or_else(|_| {
1204 let discr_ty = adt.repr().discr_type().to_ty(self.tcx());
1212 let discr = Place::from(self.new_temp(discr_ty));
1213 let discr_rv = Rvalue::Discriminant(self.place);
1214 self.new_block_with_statements(
1215 unwind,
1216 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(discr, discr_rv)]))vec![self.assign(discr, discr_rv)],
1217 TerminatorKind::SwitchInt {
1218 discr: Operand::Move(discr),
1219 targets: SwitchTargets::new(
1220 values.iter().copied().zip(blocks.iter().copied()),
1221 *blocks.last().unwrap(),
1222 ),
1223 },
1224 )
1225 });
1226 self.drop_flag_test_block(switch_block, succ, unwind)
1227 }
1228
1229 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1229u32),
::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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(Place::from(ref_place),
Rvalue::Ref(tcx.lifetimes.re_erased,
BorrowKind::Mut { kind: MutBorrowKind::Default },
self.place))])),
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1229",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1229u32),
::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)]
1230 fn destructor_call_block_sync(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
1231 let tcx = self.tcx();
1232 let drop_trait = tcx.require_lang_item(LangItem::Drop, DUMMY_SP);
1233 let drop_fn = tcx.associated_item_def_ids(drop_trait)[0];
1234 let ty = self.place_ty(self.place);
1235
1236 let ref_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, ty);
1237 let ref_place = self.new_temp(ref_ty);
1238 let unit_temp = Place::from(self.new_temp(tcx.types.unit));
1239
1240 self.new_block_with_statements(
1241 unwind,
1242 vec![self.assign(
1243 Place::from(ref_place),
1244 Rvalue::Ref(
1245 tcx.lifetimes.re_erased,
1246 BorrowKind::Mut { kind: MutBorrowKind::Default },
1247 self.place,
1248 ),
1249 )],
1250 TerminatorKind::Call {
1251 func: Operand::function_handle(tcx, drop_fn, &[ty.into()], self.source_info.span),
1252 args: [dummy_spanned(Operand::Move(Place::from(ref_place)))].into(),
1253 destination: unit_temp,
1254 target: Some(succ),
1255 unwind: unwind.into_action(),
1256 call_source: CallSource::Misc,
1257 fn_span: self.source_info.span,
1258 },
1259 )
1260 }
1261
1262 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1262u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1262",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1262u32),
::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)]
1263 fn destructor_call_block(
1264 &mut self,
1265 succ: BasicBlock,
1266 unwind: Unwind,
1267 dropline: Option<BasicBlock>,
1268 ) -> BasicBlock {
1269 let ty = self.place_ty(self.place);
1270 if !unwind.is_cleanup() && self.check_if_can_async_drop(ty, true) {
1271 self.build_async_drop(self.place, ty, succ, unwind, dropline, true)
1272 } else {
1273 self.destructor_call_block_sync(succ, unwind)
1274 }
1275 }
1276
1277 fn drop_loop(
1289 &mut self,
1290 succ: BasicBlock,
1291 cur: Local,
1292 len: Local,
1293 ety: Ty<'tcx>,
1294 unwind: Unwind,
1295 dropline: Option<BasicBlock>,
1296 ) -> BasicBlock {
1297 let copy = |place: Place<'tcx>| Operand::Copy(place);
1298 let move_ = |place: Place<'tcx>| Operand::Move(place);
1299 let tcx = self.tcx();
1300
1301 let ptr_ty = Ty::new_mut_ptr(tcx, ety);
1302 let ptr = Place::from(self.new_temp(ptr_ty));
1303 let can_go = Place::from(self.new_temp(tcx.types.bool));
1304 let one = self.constant_usize(1);
1305
1306 let drop_block = self.new_block_with_statements(
1307 unwind,
1308 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(ptr,
Rvalue::RawPtr(RawPtrKind::Mut,
tcx.mk_place_index(self.place, cur))),
self.assign(cur.into(),
Rvalue::BinaryOp(BinOp::Add,
Box::new((move_(cur.into()), one))))]))vec![
1309 self.assign(
1310 ptr,
1311 Rvalue::RawPtr(RawPtrKind::Mut, tcx.mk_place_index(self.place, cur)),
1312 ),
1313 self.assign(
1314 cur.into(),
1315 Rvalue::BinaryOp(BinOp::Add, Box::new((move_(cur.into()), one))),
1316 ),
1317 ],
1318 TerminatorKind::Unreachable,
1320 );
1321
1322 let loop_block = self.new_block_with_statements(
1323 unwind,
1324 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(can_go,
Rvalue::BinaryOp(BinOp::Eq,
Box::new((copy(Place::from(cur)), copy(len.into())))))]))vec![self.assign(
1325 can_go,
1326 Rvalue::BinaryOp(BinOp::Eq, Box::new((copy(Place::from(cur)), copy(len.into())))),
1327 )],
1328 TerminatorKind::if_(move_(can_go), succ, drop_block),
1329 );
1330
1331 let place = tcx.mk_place_deref(ptr);
1332 if !unwind.is_cleanup() && self.check_if_can_async_drop(ety, false) {
1333 let async_drop_bb =
1334 self.build_async_drop(place, ety, loop_block, unwind, dropline, false);
1335 self.elaborator
1336 .patch()
1337 .patch_terminator(drop_block, TerminatorKind::Goto { target: async_drop_bb });
1338 } else {
1339 self.elaborator.patch().patch_terminator(
1340 drop_block,
1341 TerminatorKind::Drop {
1342 place,
1343 target: loop_block,
1344 unwind: unwind.into_action(),
1345 replace: false,
1346 drop: None,
1347 },
1348 );
1349 }
1350 loop_block
1351 }
1352
1353 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1353u32),
::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().rev().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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(Place::from(array_ptr),
Rvalue::RawPtr(RawPtrKind::Mut, self.place)),
self.assign(Place::from(slice_ptr),
Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::Unsize,
CoercionSource::Implicit),
Operand::Move(Place::from(array_ptr)), slice_ptr_ty))])),
TerminatorKind::Goto { target: 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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1353",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1353u32),
::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)]
1354 fn open_drop_for_array(
1355 &mut self,
1356 array_ty: Ty<'tcx>,
1357 ety: Ty<'tcx>,
1358 opt_size: Option<u64>,
1359 ) -> BasicBlock {
1360 let tcx = self.tcx();
1361
1362 if let Some(size) = opt_size {
1363 enum ProjectionKind<Path> {
1364 Drop(std::ops::Range<u64>),
1365 Keep(u64, Path),
1366 }
1367 let mut drop_ranges = vec![];
1372 let mut dropping = true;
1373 let mut start = 0;
1374 for i in 0..size {
1375 let path = self.elaborator.array_subpath(self.path, i, size);
1376 if dropping && path.is_some() {
1377 drop_ranges.push(ProjectionKind::Drop(start..i));
1378 dropping = false;
1379 } else if !dropping && path.is_none() {
1380 dropping = true;
1381 start = i;
1382 }
1383 if let Some(path) = path {
1384 drop_ranges.push(ProjectionKind::Keep(i, path));
1385 }
1386 }
1387 if !drop_ranges.is_empty() {
1388 if dropping {
1389 drop_ranges.push(ProjectionKind::Drop(start..size));
1390 }
1391 let fields = drop_ranges
1392 .iter()
1393 .rev()
1394 .map(|p| {
1395 let (project, path) = match p {
1396 ProjectionKind::Drop(r) => (
1397 ProjectionElem::Subslice {
1398 from: r.start,
1399 to: r.end,
1400 from_end: false,
1401 },
1402 None,
1403 ),
1404 &ProjectionKind::Keep(offset, path) => (
1405 ProjectionElem::ConstantIndex {
1406 offset,
1407 min_length: size,
1408 from_end: false,
1409 },
1410 Some(path),
1411 ),
1412 };
1413 (tcx.mk_place_elem(self.place, project), path)
1414 })
1415 .collect::<Vec<_>>();
1416 let (succ, unwind, dropline) = self.drop_ladder_bottom();
1417 return self.drop_ladder(fields, succ, unwind, dropline).0;
1418 }
1419 }
1420
1421 let array_ptr_ty = Ty::new_mut_ptr(tcx, array_ty);
1422 let array_ptr = self.new_temp(array_ptr_ty);
1423
1424 let slice_ty = Ty::new_slice(tcx, ety);
1425 let slice_ptr_ty = Ty::new_mut_ptr(tcx, slice_ty);
1426 let slice_ptr = self.new_temp(slice_ptr_ty);
1427
1428 let array_place = mem::replace(
1429 &mut self.place,
1430 Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref], tcx),
1431 );
1432 let slice_block = self.drop_loop_trio_for_slice(ety);
1433 self.place = array_place;
1434
1435 self.new_block_with_statements(
1436 self.unwind,
1437 vec![
1438 self.assign(Place::from(array_ptr), Rvalue::RawPtr(RawPtrKind::Mut, self.place)),
1439 self.assign(
1440 Place::from(slice_ptr),
1441 Rvalue::Cast(
1442 CastKind::PointerCoercion(
1443 PointerCoercion::Unsize,
1444 CoercionSource::Implicit,
1445 ),
1446 Operand::Move(Place::from(array_ptr)),
1447 slice_ptr_ty,
1448 ),
1449 ),
1450 ],
1451 TerminatorKind::Goto { target: slice_block },
1452 )
1453 }
1454
1455 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1457u32),
::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 {
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,
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[self.assign(len.into(),
Rvalue::UnaryOp(UnOp::PtrMetadata,
Operand::Copy(Place::from(self.place.local)))),
self.assign(cur.into(),
Rvalue::Use(zero, WithRetag::Yes))])),
TerminatorKind::Goto { target: 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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1457",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1457u32),
::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)]
1458 fn drop_loop_trio_for_slice(&mut self, ety: Ty<'tcx>) -> BasicBlock {
1459 let tcx = self.tcx();
1460 let len = self.new_temp(tcx.types.usize);
1461 let cur = self.new_temp(tcx.types.usize);
1462
1463 let unwind = self
1464 .unwind
1465 .map(|unwind| self.drop_loop(unwind, cur, len, ety, Unwind::InCleanup, None));
1466
1467 let dropline =
1468 self.dropline.map(|dropline| self.drop_loop(dropline, cur, len, ety, unwind, None));
1469
1470 let loop_block = self.drop_loop(self.succ, cur, len, ety, unwind, dropline);
1471
1472 let [PlaceElem::Deref] = self.place.projection.as_slice() else {
1473 span_bug!(
1474 self.source_info.span,
1475 "Expected place for slice drop shim to be *_n, but it's {:?}",
1476 self.place,
1477 );
1478 };
1479
1480 let zero = self.constant_usize(0);
1481 let drop_block = self.new_block_with_statements(
1482 unwind,
1483 vec![
1484 self.assign(
1485 len.into(),
1486 Rvalue::UnaryOp(
1487 UnOp::PtrMetadata,
1488 Operand::Copy(Place::from(self.place.local)),
1489 ),
1490 ),
1491 self.assign(cur.into(), Rvalue::Use(zero, WithRetag::Yes)),
1492 ],
1493 TerminatorKind::Goto { target: loop_block },
1494 );
1495
1496 let reset_block = self.drop_flag_reset_block(DropFlagMode::Deep, drop_block, unwind);
1498 self.drop_flag_test_block(reset_block, self.succ, unwind)
1499 }
1500
1501 fn open_drop(&mut self) -> BasicBlock {
1510 let ty = self.place_ty(self.place);
1511 match ty.kind() {
1512 ty::Closure(_, args) => self.open_drop_for_tuple(args.as_closure().upvar_tys()),
1513 ty::CoroutineClosure(_, args) => {
1514 self.open_drop_for_tuple(args.as_coroutine_closure().upvar_tys())
1515 }
1516 ty::Coroutine(_, args) => self.open_drop_for_tuple(args.as_coroutine().upvar_tys()),
1523 ty::Tuple(fields) => self.open_drop_for_tuple(fields),
1524 ty::Adt(def, args) => self.open_drop_for_adt(*def, args),
1525 ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind),
1526 ty::Array(ety, size) => {
1527 let size = size.try_to_target_usize(self.tcx());
1528 self.open_drop_for_array(ty, *ety, size)
1529 }
1530 ty::Slice(ety) => self.drop_loop_trio_for_slice(*ety),
1531
1532 ty::UnsafeBinder(_) => {
1533 self.tcx().dcx().span_delayed_bug(
1536 self.source_info.span,
1537 "open drop for unsafe binder shouldn't be encountered",
1538 );
1539 self.new_block(self.unwind, TerminatorKind::Unreachable)
1540 }
1541
1542 _ => 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),
1543 }
1544 }
1545
1546 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1546u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1546",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1546u32),
::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)]
1547 fn complete_drop(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock {
1548 let drop_block = self.drop_block(succ, unwind);
1549 self.drop_flag_test_block(drop_block, succ, unwind)
1550 }
1551
1552 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1554u32),
::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: Vec<_> =
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 { target: 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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1554",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1554u32),
::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)]
1555 fn drop_flag_reset_block(
1556 &mut self,
1557 mode: DropFlagMode,
1558 succ: BasicBlock,
1559 unwind: Unwind,
1560 ) -> BasicBlock {
1561 if unwind.is_cleanup() {
1562 return succ;
1565 }
1566 let flags = self.elaborator.drop_flags_for(self.path, mode);
1567 let statements: Vec<_> = flags
1568 .into_iter()
1569 .map(|flag| {
1570 self.assign(
1571 flag,
1572 Rvalue::Use(self.constant_bool(DropFlagState::Absent.value()), WithRetag::Yes),
1573 )
1574 })
1575 .collect();
1576 if statements.is_empty() {
1577 return succ;
1578 }
1579 self.new_block_with_statements(unwind, statements, TerminatorKind::Goto { target: succ })
1580 }
1581
1582 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1582u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1582",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1582u32),
::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)]
1583 fn elaborated_drop_block(&mut self) -> BasicBlock {
1584 let blk = self.new_block(
1585 self.unwind,
1586 TerminatorKind::Drop {
1587 place: self.place,
1588 target: self.succ,
1589 unwind: self.unwind.into_action(),
1590 replace: false,
1591 drop: self.dropline,
1592 },
1593 );
1594 self.elaborate_drop(blk);
1595 blk
1596 }
1597
1598 fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
1599 let drop_ty = self.place_ty(self.place);
1600 if !unwind.is_cleanup() && self.check_if_can_async_drop(drop_ty, false) {
1601 self.build_async_drop(self.place, drop_ty, self.succ, unwind, self.dropline, false)
1602 } else {
1603 self.new_block(
1604 unwind,
1605 TerminatorKind::Drop {
1606 place: self.place,
1607 target,
1608 unwind: unwind.into_action(),
1609 replace: false,
1610 drop: None,
1611 },
1612 )
1613 }
1614 }
1615
1616 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1621u32),
::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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1621",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1621u32),
::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)]
1622 fn drop_flag_test_block(
1623 &mut self,
1624 on_set: BasicBlock,
1625 on_unset: BasicBlock,
1626 unwind: Unwind,
1627 ) -> BasicBlock {
1628 let style = self.elaborator.drop_style(self.path, DropFlagMode::Shallow);
1629 match style {
1630 DropStyle::Dead => on_unset,
1631 DropStyle::Static => on_set,
1632 DropStyle::Conditional | DropStyle::Open => {
1633 let flag = self.elaborator.get_drop_flag(self.path).unwrap();
1634 let term = TerminatorKind::if_(flag, on_set, on_unset);
1635 self.new_block(unwind, term)
1636 }
1637 }
1638 }
1639
1640 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1640u32),
::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(Some(Terminator {
source_info: self.source_info,
kind: k,
attributes: ThinVec::new(),
}), 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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1640",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1640u32),
::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)]
1641 fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock {
1642 self.elaborator.patch().new_block(BasicBlockData::new(
1643 Some(Terminator { source_info: self.source_info, kind: k, attributes: ThinVec::new() }),
1644 unwind.is_cleanup(),
1645 ))
1646 }
1647
1648 {}
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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1648u32),
::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,
Some(Terminator {
source_info: self.source_info,
kind: k,
attributes: ThinVec::new(),
}), 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/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs:1648",
"rustc_mir_transform::elaborate_drop",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/feaadeeaca7db0594da854e7c8c07495341c7439/compiler/rustc_mir_transform/src/elaborate_drop.rs"),
::tracing_core::__macro_support::Option::Some(1648u32),
::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)]
1649 fn new_block_with_statements(
1650 &mut self,
1651 unwind: Unwind,
1652 statements: Vec<Statement<'tcx>>,
1653 k: TerminatorKind<'tcx>,
1654 ) -> BasicBlock {
1655 self.elaborator.patch().new_block(BasicBlockData::new_stmts(
1656 statements,
1657 Some(Terminator { source_info: self.source_info, kind: k, attributes: ThinVec::new() }),
1658 unwind.is_cleanup(),
1659 ))
1660 }
1661
1662 fn new_temp(&mut self, ty: Ty<'tcx>) -> Local {
1663 self.elaborator.patch().new_temp(ty, self.source_info.span)
1664 }
1665
1666 fn constant_usize(&self, val: u16) -> Operand<'tcx> {
1667 Operand::Constant(Box::new(ConstOperand {
1668 span: self.source_info.span,
1669 user_ty: None,
1670 const_: Const::from_usize(self.tcx(), val.into()),
1671 }))
1672 }
1673
1674 fn constant_bool(&self, val: bool) -> Operand<'tcx> {
1675 Operand::Constant(Box::new(ConstOperand {
1676 span: self.source_info.span,
1677 user_ty: None,
1678 const_: Const::from_bool(self.tcx(), val),
1679 }))
1680 }
1681
1682 fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> {
1683 Statement::new(self.source_info, StatementKind::Assign(Box::new((lhs, rhs))))
1684 }
1685
1686 fn storage_live(&self, local: Local) -> Statement<'tcx> {
1687 Statement::new(self.source_info, StatementKind::StorageLive(local))
1688 }
1689
1690 fn storage_dead(&self, local: Local) -> Statement<'tcx> {
1691 Statement::new(self.source_info, StatementKind::StorageDead(local))
1692 }
1693}