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 mut discriminants = enum_def.discriminants(tcx);
67 let variants = targets
68 .all_values()
69 .iter()
70 .map(|value| {
71 discriminants
74 .find(|(_, discr)| discr.val == value.get())
75 .expect("SwitchInt vals should match a variant")
76 .0
77 })
78 .collect();
79
80 return Some(MaybePlacesSwitchIntData { enum_place, variants });
81 }
82
83 ty::Coroutine(..) => break,
87
88 t => ::rustc_middle::util::bug::bug_fmt(format_args!("`discriminant` called on unexpected type {0:?}",
t))bug!("`discriminant` called on unexpected type {:?}", t),
89 }
90 }
91 mir::StatementKind::Coverage(_) => continue,
92 _ => break,
93 }
94 }
95 None
96 }
97}
98
99pub struct MaybeInitializedPlaces<'a, 'tcx> {
136 tcx: TyCtxt<'tcx>,
137 body: &'a Body<'tcx>,
138 move_data: &'a MoveData<'tcx>,
139 exclude_inactive_in_otherwise: bool,
140 skip_unreachable_unwind: bool,
141}
142
143impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
144 pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
145 MaybeInitializedPlaces {
146 tcx,
147 body,
148 move_data,
149 exclude_inactive_in_otherwise: false,
150 skip_unreachable_unwind: false,
151 }
152 }
153
154 pub fn exclude_inactive_in_otherwise(mut self) -> Self {
157 self.exclude_inactive_in_otherwise = true;
158 self
159 }
160
161 pub fn skipping_unreachable_unwind(mut self) -> Self {
162 self.skip_unreachable_unwind = true;
163 self
164 }
165
166 pub fn is_unwind_dead(
167 &self,
168 place: mir::Place<'tcx>,
169 state: &<Self as Analysis<'tcx>>::Domain,
170 ) -> bool {
171 if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
172 let mut maybe_live = false;
173 on_all_children_bits(self.move_data(), path, |child| {
174 maybe_live |= state.contains(child);
175 });
176 !maybe_live
177 } else {
178 false
179 }
180 }
181}
182
183impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> {
184 fn move_data(&self) -> &MoveData<'tcx> {
185 self.move_data
186 }
187}
188
189pub struct MaybeUninitializedPlaces<'a, 'tcx> {
226 tcx: TyCtxt<'tcx>,
227 body: &'a Body<'tcx>,
228 move_data: &'a MoveData<'tcx>,
229
230 mark_inactive_variants_as_uninit: bool,
231 skip_unreachable_unwind: DenseBitSet<mir::BasicBlock>,
232}
233
234impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> {
235 pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
236 MaybeUninitializedPlaces {
237 tcx,
238 body,
239 move_data,
240 mark_inactive_variants_as_uninit: false,
241 skip_unreachable_unwind: DenseBitSet::new_empty(body.basic_blocks.len()),
242 }
243 }
244
245 pub fn mark_inactive_variants_as_uninit(mut self) -> Self {
251 self.mark_inactive_variants_as_uninit = true;
252 self
253 }
254
255 pub fn skipping_unreachable_unwind(
256 mut self,
257 unreachable_unwind: DenseBitSet<mir::BasicBlock>,
258 ) -> Self {
259 self.skip_unreachable_unwind = unreachable_unwind;
260 self
261 }
262}
263
264impl<'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
265 fn move_data(&self) -> &MoveData<'tcx> {
266 self.move_data
267 }
268}
269
270pub struct EverInitializedPlaces<'a, 'tcx> {
303 body: &'a Body<'tcx>,
304 move_data: &'a MoveData<'tcx>,
305}
306
307impl<'a, 'tcx> EverInitializedPlaces<'a, 'tcx> {
308 pub fn new(body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
309 EverInitializedPlaces { body, move_data }
310 }
311}
312
313impl<'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'_, 'tcx> {
314 fn move_data(&self) -> &MoveData<'tcx> {
315 self.move_data
316 }
317}
318
319impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
320 fn update_bits(
321 state: &mut <Self as Analysis<'tcx>>::Domain,
322 path: MovePathIndex,
323 dfstate: DropFlagState,
324 ) {
325 match dfstate {
326 DropFlagState::Absent => state.kill(path),
327 DropFlagState::Present => state.gen_(path),
328 }
329 }
330}
331
332impl<'tcx> MaybeUninitializedPlaces<'_, '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.gen_(path),
340 DropFlagState::Present => state.kill(path),
341 }
342 }
343}
344
345impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
346 type Domain = MaybeReachable<MixedBitSet<MovePathIndex>>;
349
350 type SwitchIntData = MaybePlacesSwitchIntData<'tcx>;
351
352 const NAME: &'static str = "maybe_init";
353
354 fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
355 MaybeReachable::Unreachable
357 }
358
359 fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
360 *state =
361 MaybeReachable::Reachable(MixedBitSet::new_empty(self.move_data().move_paths.len()));
362 drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
363 if !(s == DropFlagState::Present) {
::core::panicking::panic("assertion failed: s == DropFlagState::Present")
};assert!(s == DropFlagState::Present);
364 state.gen_(path);
365 });
366 }
367
368 fn apply_primary_statement_effect(
369 &self,
370 state: &mut Self::Domain,
371 statement: &mir::Statement<'tcx>,
372 location: Location,
373 ) {
374 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
375 Self::update_bits(state, path, s)
376 });
377
378 if self.tcx.sess.opts.unstable_opts.precise_enum_drop_elaboration
380 && let Some((_, rvalue)) = statement.kind.as_assign()
381 && let mir::Rvalue::Ref(_, mir::BorrowKind::Mut { .. }, place)
382 | mir::Rvalue::RawPtr(_, place) = rvalue
384 && let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
385 {
386 on_all_children_bits(self.move_data(), mpi, |child| {
387 state.gen_(child);
388 })
389 }
390 }
391
392 fn apply_primary_terminator_effect<'mir>(
393 &self,
394 state: &mut Self::Domain,
395 terminator: &'mir mir::Terminator<'tcx>,
396 location: Location,
397 ) -> TerminatorEdges<'mir, 'tcx> {
398 let mut edges = terminator.edges();
401 if self.skip_unreachable_unwind
402 && let mir::TerminatorKind::Drop { target, unwind, place, replace: _, drop: _ } =
403 terminator.kind
404 && #[allow(non_exhaustive_omitted_patterns)] match unwind {
mir::UnwindAction::Cleanup(_) => true,
_ => false,
}matches!(unwind, mir::UnwindAction::Cleanup(_))
405 && self.is_unwind_dead(place, state)
406 {
407 edges = TerminatorEdges::Single(target);
408 }
409 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
410 Self::update_bits(state, path, s)
411 });
412 edges
413 }
414
415 fn apply_call_return_effect(
416 &self,
417 state: &mut Self::Domain,
418 _block: mir::BasicBlock,
419 return_places: CallReturnPlaces<'_, 'tcx>,
420 ) {
421 return_places.for_each(|place| {
422 on_lookup_result_bits(
425 self.move_data(),
426 self.move_data().rev_lookup.find(place.as_ref()),
427 |mpi| {
428 state.gen_(mpi);
429 },
430 );
431 });
432 }
433
434 fn get_switch_int_data(
435 &self,
436 block: mir::BasicBlock,
437 targets: &mir::SwitchTargets,
438 discr: &mir::Operand<'tcx>,
439 ) -> Option<Self::SwitchIntData> {
440 if !self.tcx.sess.opts.unstable_opts.precise_enum_drop_elaboration {
441 return None;
442 }
443
444 MaybePlacesSwitchIntData::new(self.tcx, self.body, block, targets, discr)
445 }
446
447 fn apply_switch_int_edge_effect(
448 &self,
449 state: &mut Self::Domain,
450 data: &mut Self::SwitchIntData,
451 target_idx: SwitchTargetIndex,
452 ) {
453 let inactive_variants = match target_idx {
454 SwitchTargetIndex::Normal(target_idx) => {
455 InactiveVariants::Active(data.variants[target_idx])
456 }
457 SwitchTargetIndex::Otherwise if self.exclude_inactive_in_otherwise => {
458 InactiveVariants::Inactives(data.variants.clone())
459 }
460 _ => return,
461 };
462
463 drop_flag_effects::on_all_inactive_variants(
466 self.move_data,
467 data.enum_place,
468 &inactive_variants,
469 |mpi| state.kill(mpi),
470 );
471 }
472}
473
474pub type MaybeUninitializedPlacesDomain = MixedBitSet<MovePathIndex>;
477
478impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
479 type Domain = MaybeUninitializedPlacesDomain;
480
481 type SwitchIntData = MaybePlacesSwitchIntData<'tcx>;
482
483 const NAME: &'static str = "maybe_uninit";
484
485 fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
486 MixedBitSet::new_empty(self.move_data().move_paths.len())
488 }
489
490 fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
492 state.insert_all();
494
495 drop_flag_effects_for_function_entry(self.body, self.move_data, |path, s| {
496 if !(s == DropFlagState::Present) {
::core::panicking::panic("assertion failed: s == DropFlagState::Present")
};assert!(s == DropFlagState::Present);
497 state.remove(path);
498 });
499 }
500
501 fn apply_primary_statement_effect(
502 &self,
503 state: &mut Self::Domain,
504 _statement: &mir::Statement<'tcx>,
505 location: Location,
506 ) {
507 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
508 Self::update_bits(state, path, s)
509 });
510
511 }
514
515 fn apply_primary_terminator_effect<'mir>(
516 &self,
517 state: &mut Self::Domain,
518 terminator: &'mir mir::Terminator<'tcx>,
519 location: Location,
520 ) -> TerminatorEdges<'mir, 'tcx> {
521 drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
522 Self::update_bits(state, path, s)
523 });
524 if self.skip_unreachable_unwind.contains(location.block) {
525 let mir::TerminatorKind::Drop { target, unwind, .. } = terminator.kind else { ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))bug!() };
526 {
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(_));
527 TerminatorEdges::Single(target)
528 } else {
529 terminator.edges()
530 }
531 }
532
533 fn apply_call_return_effect(
534 &self,
535 state: &mut Self::Domain,
536 _block: mir::BasicBlock,
537 return_places: CallReturnPlaces<'_, 'tcx>,
538 ) {
539 return_places.for_each(|place| {
540 on_lookup_result_bits(
543 self.move_data(),
544 self.move_data().rev_lookup.find(place.as_ref()),
545 |mpi| {
546 state.kill(mpi);
547 },
548 );
549 });
550 }
551
552 fn get_switch_int_data(
553 &self,
554 block: mir::BasicBlock,
555 targets: &mir::SwitchTargets,
556 discr: &mir::Operand<'tcx>,
557 ) -> Option<Self::SwitchIntData> {
558 if !self.tcx.sess.opts.unstable_opts.precise_enum_drop_elaboration {
559 return None;
560 }
561
562 if !self.mark_inactive_variants_as_uninit {
563 return None;
564 }
565
566 MaybePlacesSwitchIntData::new(self.tcx, self.body, block, targets, discr)
567 }
568
569 fn apply_switch_int_edge_effect(
570 &self,
571 state: &mut Self::Domain,
572 data: &mut Self::SwitchIntData,
573 target_idx: SwitchTargetIndex,
574 ) {
575 let inactive_variants = match target_idx {
576 SwitchTargetIndex::Normal(target_idx) => {
577 InactiveVariants::Active(data.variants[target_idx])
578 }
579 SwitchTargetIndex::Otherwise => InactiveVariants::Inactives(data.variants.clone()),
580 };
581
582 drop_flag_effects::on_all_inactive_variants(
585 self.move_data,
586 data.enum_place,
587 &inactive_variants,
588 |mpi| state.gen_(mpi),
589 );
590 }
591}
592
593pub type EverInitializedPlacesDomain = MixedBitSet<InitIndex>;
596
597impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
598 type Domain = EverInitializedPlacesDomain;
599
600 const NAME: &'static str = "ever_init";
601
602 fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
603 MixedBitSet::new_empty(self.move_data().inits.len())
605 }
606
607 fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain) {
608 for arg_init in 0..body.arg_count {
609 state.insert(InitIndex::new(arg_init));
610 }
611 }
612
613 #[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(613u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("stmt")
}> =
::tracing::__macro_support::FieldName::new("stmt");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("location")
}> =
::tracing::__macro_support::FieldName::new("location");
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(&stmt)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&location)
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;
}
{
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:625",
"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(625u32),
::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};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("initializes move_indexes {0:?}",
init_loc_map[location]) as &dyn ::tracing::field::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:633",
"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(633u32),
::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};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("clears the ever initialized status of {0:?}",
init_path_map[move_path_index]) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};
state.kill_all(init_path_map[move_path_index].iter().copied());
}
}
}
}#[instrument(skip(self, state), level = "debug")]
614 fn apply_primary_statement_effect(
615 &self,
616 state: &mut Self::Domain,
617 stmt: &mir::Statement<'tcx>,
618 location: Location,
619 ) {
620 let move_data = self.move_data();
621 let init_path_map = &move_data.init_path_map;
622 let init_loc_map = &move_data.init_loc_map;
623 let rev_lookup = &move_data.rev_lookup;
624
625 debug!("initializes move_indexes {:?}", init_loc_map[location]);
626 state.gen_all(init_loc_map[location].iter().copied());
627
628 if let mir::StatementKind::StorageDead(local) = stmt.kind
629 && let Some(move_path_index) = rev_lookup.find_local(local)
632 {
633 debug!("clears the ever initialized status of {:?}", init_path_map[move_path_index]);
634 state.kill_all(init_path_map[move_path_index].iter().copied());
635 }
636 }
637
638 #[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(638u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("location")
}> =
::tracing::__macro_support::FieldName::new("location");
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(&location)
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: TerminatorEdges<'mir, 'tcx> =
loop {};
return __tracing_attr_fake_return;
}
{
let move_data = self.move_data();
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:647",
"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(647u32),
::tracing_core::__macro_support::Option::Some("rustc_mir_dataflow::impls::initialized"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("terminator")
}> =
::tracing::__macro_support::FieldName::new("terminator");
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(&terminator)
as &dyn ::tracing::field::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:648",
"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(648u32),
::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};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("initializes move_indexes {0:?}",
init_loc_map[location]) as &dyn ::tracing::field::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")]
639 fn apply_primary_terminator_effect<'mir>(
640 &self,
641 state: &mut Self::Domain,
642 terminator: &'mir mir::Terminator<'tcx>,
643 location: Location,
644 ) -> TerminatorEdges<'mir, 'tcx> {
645 let move_data = self.move_data();
646 let init_loc_map = &move_data.init_loc_map;
647 debug!(?terminator);
648 debug!("initializes move_indexes {:?}", init_loc_map[location]);
649 state.gen_all(
650 init_loc_map[location]
651 .iter()
652 .filter(|init_index| {
653 move_data.inits[**init_index].kind != InitKind::NonPanicPathOnly
654 })
655 .copied(),
656 );
657 terminator.edges()
658 }
659
660 fn apply_call_return_effect(
661 &self,
662 state: &mut Self::Domain,
663 block: mir::BasicBlock,
664 _return_places: CallReturnPlaces<'_, 'tcx>,
665 ) {
666 let move_data = self.move_data();
667 let init_loc_map = &move_data.init_loc_map;
668
669 let call_loc = self.body.terminator_loc(block);
670 for init_index in &init_loc_map[call_loc] {
671 state.gen_(*init_index);
672 }
673 }
674}