X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=compiler%2Frustc_mir_dataflow%2Fsrc%2Fvalue_analysis.rs;fp=compiler%2Frustc_mir_dataflow%2Fsrc%2Fvalue_analysis.rs;h=98bebc9b13bc505df2753921013d8284610cdab4;hb=26c9e740979f0063790cbc37e8c490da76ec0743;hp=401db890a9810d1f811d63390c9f082f8beb57a9;hpb=e1ed88c81f28226936b0f9d0358d45bb02563e4f;p=rustc.git diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 401db890a9..98bebc9b13 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -36,11 +36,11 @@ use std::fmt::{Debug, Formatter}; use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; -use rustc_index::vec::IndexVec; +use rustc_index::vec::{IndexSlice, IndexVec}; use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_target::abi::VariantIdx; +use rustc_target::abi::{FieldIdx, VariantIdx}; use crate::lattice::{HasBottom, HasTop}; use crate::{ @@ -86,6 +86,7 @@ pub trait ValueAnalysis<'tcx> { StatementKind::ConstEvalCounter | StatementKind::Nop | StatementKind::FakeRead(..) + | StatementKind::PlaceMention(..) | StatementKind::Coverage(..) | StatementKind::AscribeUserType(..) => (), } @@ -230,14 +231,14 @@ pub trait ValueAnalysis<'tcx> { TerminatorKind::Drop { place, .. } => { state.flood_with(place.as_ref(), self.map(), Self::Value::bottom()); } - TerminatorKind::DropAndReplace { .. } | TerminatorKind::Yield { .. } => { + TerminatorKind::Yield { .. } => { // They would have an effect, but are not allowed in this phase. bug!("encountered disallowed terminator"); } TerminatorKind::Goto { .. } | TerminatorKind::SwitchInt { .. } | TerminatorKind::Resume - | TerminatorKind::Abort + | TerminatorKind::Terminate | TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::Assert { .. } @@ -690,7 +691,7 @@ impl Map { } // Recurse with all fields of this place. - iter_fields(ty, tcx, |variant, field, ty| { + iter_fields(ty, tcx, ty::ParamEnv::reveal_all(), |variant, field, ty| { if let Some(variant) = variant { projection.push(PlaceElem::Downcast(None, variant)); let _ = self.make_place(local, projection); @@ -918,7 +919,7 @@ impl ValueOrPlace { /// Although only field projections are currently allowed, this could change in the future. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum TrackElem { - Field(Field), + Field(FieldIdx), Variant(VariantIdx), Discriminant, } @@ -939,7 +940,8 @@ impl TryFrom> for TrackElem { pub fn iter_fields<'tcx>( ty: Ty<'tcx>, tcx: TyCtxt<'tcx>, - mut f: impl FnMut(Option, Field, Ty<'tcx>), + param_env: ty::ParamEnv<'tcx>, + mut f: impl FnMut(Option, FieldIdx, Ty<'tcx>), ) { match ty.kind() { ty::Tuple(list) => { @@ -956,14 +958,14 @@ pub fn iter_fields<'tcx>( for (f_index, f_def) in v_def.fields.iter().enumerate() { let field_ty = f_def.ty(tcx, substs); let field_ty = tcx - .try_normalize_erasing_regions(ty::ParamEnv::reveal_all(), field_ty) - .unwrap_or(field_ty); + .try_normalize_erasing_regions(param_env, field_ty) + .unwrap_or_else(|_| tcx.erase_regions(field_ty)); f(variant, f_index.into(), field_ty); } } } ty::Closure(_, substs) => { - iter_fields(substs.as_closure().tupled_upvars_ty(), tcx, f); + iter_fields(substs.as_closure().tupled_upvars_ty(), tcx, param_env, f); } _ => (), } @@ -1026,8 +1028,8 @@ where fn debug_with_context_rec( place: PlaceIndex, place_str: &str, - new: &IndexVec, - old: Option<&IndexVec>, + new: &IndexSlice, + old: Option<&IndexSlice>, map: &Map, f: &mut Formatter<'_>, ) -> std::fmt::Result { @@ -1067,8 +1069,8 @@ fn debug_with_context_rec( } fn debug_with_context( - new: &IndexVec, - old: Option<&IndexVec>, + new: &IndexSlice, + old: Option<&IndexSlice>, map: &Map, f: &mut Formatter<'_>, ) -> std::fmt::Result {