1use std::assert_matches;
2
3use rustc_abi::VariantIdx;
4use rustc_index::Idx;
5use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
6use rustc_middle::bug;
7use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
8use rustc_middle::ty::{self, TyCtxt};
9use smallvec::SmallVec;
10use tracing::{debug, instrument};
11
12use crate::drop_flag_effects::{DropFlagState, InactiveVariants};
13use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
14use crate::{
15 Analysis, GenKill, MaybeReachable, SwitchTargetIndex, drop_flag_effects,
16 drop_flag_effects_for_function_entry, drop_flag_effects_for_location, on_all_children_bits,
17 on_lookup_result_bits,
18};
19
20pub struct MaybePlacesSwitchIntData<'tcx> {
22 enum_place: mir::Place<'tcx>,
23
24 variants: SmallVec<[VariantIdx; 4]>,
31}
32
33impl<'tcx> MaybePlacesSwitchIntData<'tcx> {
34 fn new(
35 tcx: TyCtxt<'tcx>,
36 body: &Body<'tcx>,
37 block: mir::BasicBlock,
38 targets: &mir::SwitchTargets,
39 discr: &mir::Operand<'tcx>,
40 ) -> Option<Self> {
41 let Some(discr) = discr.place() else { return None };
42
43 let block_data = &body[block];
55 for statement in block_data.statements.iter().rev() {
56 match statement.kind {
57 mir::StatementKind::Assign((lhs, mir::Rvalue::Discriminant(enum_place)))
58 if lhs == discr =>
59 {
60 match enum_place.ty(body, tcx).ty.kind() {
61 ty::Adt(enum_def, _) => {
62 let discriminant_vals: SmallVec<[u128; 4]> =
64 enum_def.discriminants(tcx).map(|(_, discr)| discr.val).collect();
65 let mut i = 0;
66
67 let variants = targets
72 .all_values()
73 .iter()
74 .map(|value| {
75 loop {
76 if discriminant_vals[i] == value.get() {
77 return VariantIdx::new(i);
78 }
79 i += 1;
80 }
81 })
82 .collect();
83
84 return Some(MaybePlacesSwitchIntData { enum_place, variants });
85 }
86
87 ty::Coroutine(..) => break,
91
92 t => ::rustc_middle::util::bug::bug_fmt(format_args!("`discriminant` called on unexpected type {0:?}",
t))bug!("`discriminant` called on unexpected type {:?}", t),
93 }
94 }
95 mir::StatementKind::Coverage(_) => continue,
96 _ => break,
97 }
98 }
99 None
100 }
101}
102
103pub struct MaybeInitializedPlaces<'a, 'tcx> {
140 tcx: TyCtxt<'tcx>,
141 body: &'a Body<'tcx>,
142 move_data: &'a MoveData<'tcx>,
143 exclude_inactive_in_otherwise: bool,
144 skip_unreachable_unwind: bool,
145}
146
147impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
148 pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
149 MaybeInitializedPlaces {
150 tcx,
151 body,
152 move_data,
153 exclude_inactive_in_otherwise: false,
154 skip_unreachable_unwind: false,
155 }
156 }
157
158 pub fn exclude_inactive_in_otherwise(mut self) -> Self {
161 self.exclude_inactive_in_otherwise = true;
162 self
163 }
164
165 pub fn skipping_unreachable_unwind(mut self) -> Self {
166 self.skip_unreachable_unwind = true;
167 self
168 }
169
170 pub fn is_unwind_dead(
171 &self,
172 place: mir::Place<'tcx>,
173 state: &<Self as Analysis<'tcx>>::Domain,
174 ) -> bool {
175 if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
176 let mut maybe_live = false;
177 on_all_children_bits(self.move_data(), path, |child| {
178 maybe_live |= state.contains(child);
179 });
180 !maybe_live
181 } else {
182 false
183 }
184 }
185}
186
187impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> {
188 fn move_data(&self) -> &MoveData<'tcx> {
189 self.move_data
190 }
191}
192
193pub struct MaybeUninitializedPlaces<'a, 'tcx> {
230 tcx: TyCtxt<'tcx>,
231 body: &'a Body<'tcx>,
232 move_data: &'a MoveData<'tcx>,
233
234 mark_inactive_variants_as_uninit: bool,
235 include_inactive_in_otherwise: bool,
236 skip_unreachable_unwind: DenseBitSet<mir::BasicBlock>,
237}
238
239impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> {
240 pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
241 MaybeUninitializedPlaces {
242 tcx,
243 body,
244 move_data,
245 mark_inactive_variants_as_uninit: false,
246 include_inactive_in_otherwise: false,
247 skip_unreachable_unwind: DenseBitSet::new_empty(body.basic_blocks.len()),
248 }
249 }
250
251 pub fn mark_inactive_variants_as_uninit(mut self) -> Self {
257 self.mark_inactive_variants_as_uninit = true;
258 self
259 }
260
261 pub fn include_inactive_in_otherwise(mut self) -> Self {
264 self.include_inactive_in_otherwise = true;
265 self
266 }
267
268 pub fn skipping_unreachable_unwind(
269 mut self,
270 unreachable_unwind: DenseBitSet<mir::BasicBlock>,
271 ) -> Self {
272 self.skip_unreachable_unwind = unreachable_unwind;
273 self
274 }
275}
276
277impl<'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
278 fn move_data(&self) -> &MoveData<'tcx> {
279 self.move_data
280 }
281}
282
283pub struct EverInitializedPlaces<'a, 'tcx> {
316 body: &'a Body<'tcx>,
317 move_data: &'a MoveData<'tcx>,
318}
319
320impl<'a, 'tcx> EverInitializedPlaces<'a, 'tcx> {
321 pub fn new(body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
322 EverInitializedPlaces { body, move_data }
323 }
324}
325
326impl<'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'_, 'tcx> {
327 fn move_data(&self) -> &MoveData<'tcx> {
328 self.move_data
329 }
330}
331
332impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
333 fn update_bits(
334 state: &mut <Self as Analysis<'tcx>>::Domain,
335 path: MovePathIndex,
336 dfstate: DropFlagState,
337 ) {
338 match dfstate {
339 DropFlagState::Absent => state.kill(path),
340 DropFlagState::Present => state.gen_(path),
341 }
342 }
343}
344
345impl<'tcx> MaybeUninitializedPlaces<'_, 'tcx> {
346 fn update_bits(
347 state: &mut <Self as Analysis<'tcx>>::Domain,
348 path: MovePathIndex,
349 dfstate: DropFlagState,
350 ) {
351 match dfstate {
352 DropFlagState::Absent => state.gen_(path),
353 DropFlagState::Present => state.kill(path),
354 }
355 }
356}
357
358impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
359 type Domain = MaybeReachable<MixedBitSet<MovePathIndex>>;
362
363 type SwitchIntData = MaybePlacesSwitchIntData<'tcx>;
364
365 const NAME: &'static str = "maybe_init";
366
367 fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
368 MaybeReachable::Unreachable
370 }
371
372 fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
373 *state =
374 MaybeReachable::Reachable(MixedBitSet::new_empty(self.move_data().move_paths.len()));
375 drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
376 if !(s == DropFlagState::Present) {
::core::panicking::panic("assertion failed: s == DropFlagState::Present")
};assert!(s == DropFlagState::Present);
377 state.gen_(path);
378 });
379 }
380
381 fn apply_primary_statement_effect(
382 &self,
383 state: &mut Self::Domain,
384 statement: &mir::Statement<'tcx>,
385 location: Location,
386 ) {
387 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
388 Self::update_bits(state, path, s)
389 });
390
391 if self.tcx.sess.opts.unstable_opts.precise_enum_drop_elaboration
393 && let Some((_, rvalue)) = statement.kind.as_assign()
394 && let mir::Rvalue::Ref(_, mir::BorrowKind::Mut { .. }, place)
395 | mir::Rvalue::RawPtr(_, place) = rvalue
397 && let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
398 {
399 on_all_children_bits(self.move_data(), mpi, |child| {
400 state.gen_(child);
401 })
402 }
403 }
404
405 fn apply_primary_terminator_effect<'mir>(
406 &self,
407 state: &mut Self::Domain,
408 terminator: &'mir mir::Terminator<'tcx>,
409 location: Location,
410 ) -> TerminatorEdges<'mir, 'tcx> {
411 let mut edges = terminator.edges();
414 if self.skip_unreachable_unwind
415 && let mir::TerminatorKind::Drop { target, unwind, place, replace: _, drop: _ } =
416 terminator.kind
417 && #[allow(non_exhaustive_omitted_patterns)] match unwind {
mir::UnwindAction::Cleanup(_) => true,
_ => false,
}matches!(unwind, mir::UnwindAction::Cleanup(_))
418 && self.is_unwind_dead(place, state)
419 {
420 edges = TerminatorEdges::Single(target);
421 }
422 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
423 Self::update_bits(state, path, s)
424 });
425 edges
426 }
427
428 fn apply_call_return_effect(
429 &self,
430 state: &mut Self::Domain,
431 _block: mir::BasicBlock,
432 return_places: CallReturnPlaces<'_, 'tcx>,
433 ) {
434 return_places.for_each(|place| {
435 on_lookup_result_bits(
438 self.move_data(),
439 self.move_data().rev_lookup.find(place.as_ref()),
440 |mpi| {
441 state.gen_(mpi);
442 },
443 );
444 });
445 }
446
447 fn get_switch_int_data(
448 &self,
449 block: mir::BasicBlock,
450 targets: &mir::SwitchTargets,
451 discr: &mir::Operand<'tcx>,
452 ) -> Option<Self::SwitchIntData> {
453 if !self.tcx.sess.opts.unstable_opts.precise_enum_drop_elaboration {
454 return None;
455 }
456
457 MaybePlacesSwitchIntData::new(self.tcx, self.body, block, targets, discr)
458 }
459
460 fn apply_switch_int_edge_effect(
461 &self,
462 state: &mut Self::Domain,
463 data: &mut Self::SwitchIntData,
464 target_idx: SwitchTargetIndex,
465 ) {
466 let inactive_variants = match target_idx {
467 SwitchTargetIndex::Normal(target_idx) => {
468 InactiveVariants::Active(data.variants[target_idx])
469 }
470 SwitchTargetIndex::Otherwise if self.exclude_inactive_in_otherwise => {
471 InactiveVariants::Inactives(data.variants.clone())
472 }
473 _ => return,
474 };
475
476 drop_flag_effects::on_all_inactive_variants(
479 self.move_data,
480 data.enum_place,
481 &inactive_variants,
482 |mpi| state.kill(mpi),
483 );
484 }
485}
486
487pub type MaybeUninitializedPlacesDomain = MixedBitSet<MovePathIndex>;
490
491impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
492 type Domain = MaybeUninitializedPlacesDomain;
493
494 type SwitchIntData = MaybePlacesSwitchIntData<'tcx>;
495
496 const NAME: &'static str = "maybe_uninit";
497
498 fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
499 MixedBitSet::new_empty(self.move_data().move_paths.len())
501 }
502
503 fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
505 state.insert_all();
507
508 drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
509 if !(s == DropFlagState::Present) {
::core::panicking::panic("assertion failed: s == DropFlagState::Present")
};assert!(s == DropFlagState::Present);
510 state.remove(path);
511 });
512 }
513
514 fn apply_primary_statement_effect(
515 &self,
516 state: &mut Self::Domain,
517 _statement: &mir::Statement<'tcx>,
518 location: Location,
519 ) {
520 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
521 Self::update_bits(state, path, s)
522 });
523
524 }
527
528 fn apply_primary_terminator_effect<'mir>(
529 &self,
530 state: &mut Self::Domain,
531 terminator: &'mir mir::Terminator<'tcx>,
532 location: Location,
533 ) -> TerminatorEdges<'mir, 'tcx> {
534 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
535 Self::update_bits(state, path, s)
536 });
537 if self.skip_unreachable_unwind.contains(location.block) {
538 let mir::TerminatorKind::Drop { target, unwind, .. } = terminator.kind else { ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))bug!() };
539 {
match unwind {
mir::UnwindAction::Cleanup(_) => {}
ref left_val => {
::core::panicking::assert_matches_failed(left_val,
"mir::UnwindAction::Cleanup(_)",
::core::option::Option::None);
}
}
};assert_matches!(unwind, mir::UnwindAction::Cleanup(_));
540 TerminatorEdges::Single(target)
541 } else {
542 terminator.edges()
543 }
544 }
545
546 fn apply_call_return_effect(
547 &self,
548 state: &mut Self::Domain,
549 _block: mir::BasicBlock,
550 return_places: CallReturnPlaces<'_, 'tcx>,
551 ) {
552 return_places.for_each(|place| {
553 on_lookup_result_bits(
556 self.move_data(),
557 self.move_data().rev_lookup.find(place.as_ref()),
558 |mpi| {
559 state.kill(mpi);
560 },
561 );
562 });
563 }
564
565 fn get_switch_int_data(
566 &self,
567 block: mir::BasicBlock,
568 targets: &mir::SwitchTargets,
569 discr: &mir::Operand<'tcx>,
570 ) -> Option<Self::SwitchIntData> {
571 if !self.tcx.sess.opts.unstable_opts.precise_enum_drop_elaboration {
572 return None;
573 }
574
575 if !self.mark_inactive_variants_as_uninit {
576 return None;
577 }
578
579 MaybePlacesSwitchIntData::new(self.tcx, self.body, block, targets, discr)
580 }
581
582 fn apply_switch_int_edge_effect(
583 &self,
584 state: &mut Self::Domain,
585 data: &mut Self::SwitchIntData,
586 target_idx: SwitchTargetIndex,
587 ) {
588 let inactive_variants = match target_idx {
589 SwitchTargetIndex::Normal(target_idx) => {
590 InactiveVariants::Active(data.variants[target_idx])
591 }
592 SwitchTargetIndex::Otherwise if self.include_inactive_in_otherwise => {
593 InactiveVariants::Inactives(data.variants.clone())
594 }
595 _ => return,
596 };
597
598 drop_flag_effects::on_all_inactive_variants(
601 self.move_data,
602 data.enum_place,
603 &inactive_variants,
604 |mpi| state.gen_(mpi),
605 );
606 }
607}
608
609pub type EverInitializedPlacesDomain = MixedBitSet<InitIndex>;
612
613impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
614 type Domain = EverInitializedPlacesDomain;
615
616 const NAME: &'static str = "ever_init";
617
618 fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
619 MixedBitSet::new_empty(self.move_data().inits.len())
621 }
622
623 fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain) {
624 for arg_init in 0..body.arg_count {
625 state.insert(InitIndex::new(arg_init));
626 }
627 }
628
629 #[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("apply_primary_statement_effect",
"rustc_mir_dataflow::impls::initialized",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/impls/initialized.rs"),
::tracing_core::__macro_support::Option::Some(629u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::tracing_core::field::FieldSet::new(&["stmt", "location"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stmt)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&location)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let move_data = self.move_data();
let init_path_map = &move_data.init_path_map;
let init_loc_map = &move_data.init_loc_map;
let rev_lookup = &move_data.rev_lookup;
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_mir_dataflow/src/impls/initialized.rs:641",
"rustc_mir_dataflow::impls::initialized",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/impls/initialized.rs"),
::tracing_core::__macro_support::Option::Some(641u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("initializes move_indexes {0:?}",
init_loc_map[location]) as &dyn Value))])
});
} else { ; }
};
state.gen_all(init_loc_map[location].iter().copied());
if let mir::StatementKind::StorageDead(local) = stmt.kind &&
let Some(move_path_index) = rev_lookup.find_local(local) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_mir_dataflow/src/impls/initialized.rs:649",
"rustc_mir_dataflow::impls::initialized",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/impls/initialized.rs"),
::tracing_core::__macro_support::Option::Some(649u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("clears the ever initialized status of {0:?}",
init_path_map[move_path_index]) as &dyn Value))])
});
} else { ; }
};
state.kill_all(init_path_map[move_path_index].iter().copied());
}
}
}
}#[instrument(skip(self, state), level = "debug")]
630 fn apply_primary_statement_effect(
631 &self,
632 state: &mut Self::Domain,
633 stmt: &mir::Statement<'tcx>,
634 location: Location,
635 ) {
636 let move_data = self.move_data();
637 let init_path_map = &move_data.init_path_map;
638 let init_loc_map = &move_data.init_loc_map;
639 let rev_lookup = &move_data.rev_lookup;
640
641 debug!("initializes move_indexes {:?}", init_loc_map[location]);
642 state.gen_all(init_loc_map[location].iter().copied());
643
644 if let mir::StatementKind::StorageDead(local) = stmt.kind
645 && let Some(move_path_index) = rev_lookup.find_local(local)
648 {
649 debug!("clears the ever initialized status of {:?}", init_path_map[move_path_index]);
650 state.kill_all(init_path_map[move_path_index].iter().copied());
651 }
652 }
653
654 #[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("apply_primary_terminator_effect",
"rustc_mir_dataflow::impls::initialized",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/impls/initialized.rs"),
::tracing_core::__macro_support::Option::Some(654u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::tracing_core::field::FieldSet::new(&["location"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&location)
as &dyn 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: TerminatorEdges<'mir, 'tcx> =
loop {};
return __tracing_attr_fake_return;
}
{
let (body, move_data) = (self.body, self.move_data());
let term = body[location.block].terminator();
let init_loc_map = &move_data.init_loc_map;
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_mir_dataflow/src/impls/initialized.rs:664",
"rustc_mir_dataflow::impls::initialized",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/impls/initialized.rs"),
::tracing_core::__macro_support::Option::Some(664u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::tracing_core::field::FieldSet::new(&["term"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&term) as
&dyn Value))])
});
} else { ; }
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_mir_dataflow/src/impls/initialized.rs:665",
"rustc_mir_dataflow::impls::initialized",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_mir_dataflow/src/impls/initialized.rs"),
::tracing_core::__macro_support::Option::Some(665u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("initializes move_indexes {0:?}",
init_loc_map[location]) as &dyn Value))])
});
} else { ; }
};
state.gen_all(init_loc_map[location].iter().filter(|init_index|
{
move_data.inits[**init_index].kind !=
InitKind::NonPanicPathOnly
}).copied());
terminator.edges()
}
}
}#[instrument(skip(self, state, terminator), level = "debug")]
655 fn apply_primary_terminator_effect<'mir>(
656 &self,
657 state: &mut Self::Domain,
658 terminator: &'mir mir::Terminator<'tcx>,
659 location: Location,
660 ) -> TerminatorEdges<'mir, 'tcx> {
661 let (body, move_data) = (self.body, self.move_data());
662 let term = body[location.block].terminator();
663 let init_loc_map = &move_data.init_loc_map;
664 debug!(?term);
665 debug!("initializes move_indexes {:?}", init_loc_map[location]);
666 state.gen_all(
667 init_loc_map[location]
668 .iter()
669 .filter(|init_index| {
670 move_data.inits[**init_index].kind != InitKind::NonPanicPathOnly
671 })
672 .copied(),
673 );
674 terminator.edges()
675 }
676
677 fn apply_call_return_effect(
678 &self,
679 state: &mut Self::Domain,
680 block: mir::BasicBlock,
681 _return_places: CallReturnPlaces<'_, 'tcx>,
682 ) {
683 let move_data = self.move_data();
684 let init_loc_map = &move_data.init_loc_map;
685
686 let call_loc = self.body.terminator_loc(block);
687 for init_index in &init_loc_map[call_loc] {
688 state.gen_(*init_index);
689 }
690 }
691}