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