diff options
Diffstat (limited to 'compiler/rustc_mir_dataflow/src')
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/elaborate_drops.rs | 37 | ||||
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/impls/mod.rs | 6 |
2 files changed, 22 insertions, 21 deletions
diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 774df752113..84491d0c2ad 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -407,7 +407,7 @@ where self.drop_ladder(fields, succ, unwind).0 } - fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { + fn open_drop_for_box(&mut self, adt: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs); let interior = self.tcx().mk_place_deref(self.place); @@ -420,9 +420,9 @@ where self.drop_subpath(interior, interior_path, succ, unwind_succ) } - fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { + fn open_drop_for_adt(&mut self, adt: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs); - if adt.variants.is_empty() { + if adt.variants().is_empty() { return self.elaborator.patch().new_block(BasicBlockData { statements: vec![], terminator: Some(Terminator { @@ -434,7 +434,7 @@ where } let skip_contents = - adt.is_union() || Some(adt.did) == self.tcx().lang_items().manually_drop(); + adt.is_union() || Some(adt.did()) == self.tcx().lang_items().manually_drop(); let contents_drop = if skip_contents { (self.succ, self.unwind) } else { @@ -450,7 +450,7 @@ where fn open_drop_for_adt_contents( &mut self, - adt: &'tcx ty::AdtDef, + adt: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>, ) -> (BasicBlock, Unwind) { let (succ, unwind) = self.drop_ladder_bottom(); @@ -458,7 +458,7 @@ where let fields = self.move_paths_for_fields( self.place, self.path, - &adt.variants[VariantIdx::new(0)], + &adt.variant(VariantIdx::new(0)), substs, ); self.drop_ladder(fields, succ, unwind) @@ -469,22 +469,22 @@ where fn open_drop_for_multivariant( &mut self, - adt: &'tcx ty::AdtDef, + adt: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>, succ: BasicBlock, unwind: Unwind, ) -> (BasicBlock, Unwind) { - let mut values = Vec::with_capacity(adt.variants.len()); - let mut normal_blocks = Vec::with_capacity(adt.variants.len()); + let mut values = Vec::with_capacity(adt.variants().len()); + let mut normal_blocks = Vec::with_capacity(adt.variants().len()); let mut unwind_blocks = - if unwind.is_cleanup() { None } else { Some(Vec::with_capacity(adt.variants.len())) }; + if unwind.is_cleanup() { None } else { Some(Vec::with_capacity(adt.variants().len())) }; let mut have_otherwise_with_drop_glue = false; let mut have_otherwise = false; let tcx = self.tcx(); for (variant_index, discr) in adt.discriminants(tcx) { - let variant = &adt.variants[variant_index]; + let variant = &adt.variant(variant_index); let subpath = self.elaborator.downcast_subpath(self.path, variant_index); if let Some(variant_path) = subpath { @@ -564,7 +564,7 @@ where fn adt_switch_block( &mut self, - adt: &'tcx ty::AdtDef, + adt: ty::AdtDef<'tcx>, blocks: Vec<BasicBlock>, values: &[u128], succ: BasicBlock, @@ -577,7 +577,7 @@ where // Additionally, we do not want to switch on the // discriminant after it is free-ed, because that // way lies only trouble. - let discr_ty = adt.repr.discr_type().to_ty(self.tcx()); + let discr_ty = adt.repr().discr_type().to_ty(self.tcx()); let discr = Place::from(self.new_temp(discr_ty)); let discr_rv = Rvalue::Discriminant(self.place); let switch_block = BasicBlockData { @@ -869,9 +869,9 @@ where ty::Tuple(fields) => self.open_drop_for_tuple(fields), ty::Adt(def, substs) => { if def.is_box() { - self.open_drop_for_box(def, substs) + self.open_drop_for_box(*def, substs) } else { - self.open_drop_for_adt(def, substs) + self.open_drop_for_adt(*def, substs) } } ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind), @@ -927,7 +927,7 @@ where /// The contained value will not be dropped. fn box_free_block( &mut self, - adt: &'tcx ty::AdtDef, + adt: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>, target: BasicBlock, unwind: Unwind, @@ -940,7 +940,7 @@ where /// value). fn unelaborated_free_block( &mut self, - adt: &'tcx ty::AdtDef, + adt: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>, target: BasicBlock, unwind: Unwind, @@ -948,7 +948,8 @@ where let tcx = self.tcx(); let unit_temp = Place::from(self.new_temp(tcx.mk_unit())); let free_func = tcx.require_lang_item(LangItem::BoxFree, Some(self.source_info.span)); - let args = adt.variants[VariantIdx::new(0)] + let args = adt + .variant(VariantIdx::new(0)) .fields .iter() .enumerate() diff --git a/compiler/rustc_mir_dataflow/src/impls/mod.rs b/compiler/rustc_mir_dataflow/src/impls/mod.rs index 7d6a08d47da..87c1060f552 100644 --- a/compiler/rustc_mir_dataflow/src/impls/mod.rs +++ b/compiler/rustc_mir_dataflow/src/impls/mod.rs @@ -705,14 +705,14 @@ fn switch_on_enum_discriminant<'mir, 'tcx>( body: &'mir mir::Body<'tcx>, block: &'mir mir::BasicBlockData<'tcx>, switch_on: mir::Place<'tcx>, -) -> Option<(mir::Place<'tcx>, &'tcx ty::AdtDef)> { +) -> Option<(mir::Place<'tcx>, ty::AdtDef<'tcx>)> { for statement in block.statements.iter().rev() { match &statement.kind { mir::StatementKind::Assign(box (lhs, mir::Rvalue::Discriminant(discriminated))) if *lhs == switch_on => { - match &discriminated.ty(body, tcx).ty.kind() { - ty::Adt(def, _) => return Some((*discriminated, def)), + match discriminated.ty(body, tcx).ty.kind() { + ty::Adt(def, _) => return Some((*discriminated, *def)), // `Rvalue::Discriminant` is also used to get the active yield point for a // generator, but we do not need edge-specific effects in that case. This may |
