Update ty::VariantDef
to use IndexVec<FieldIdx, FieldDef>
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
This commit is contained in:
parent
10338571cf
commit
4abb455529
47 changed files with 127 additions and 104 deletions
|
@ -158,12 +158,12 @@ impl<'tcx> CapturedPlace<'tcx> {
|
|||
for proj in self.place.projections.iter() {
|
||||
match proj.kind {
|
||||
HirProjectionKind::Field(idx, variant) => match ty.kind() {
|
||||
ty::Tuple(_) => write!(&mut symbol, "__{}", idx).unwrap(),
|
||||
ty::Tuple(_) => write!(&mut symbol, "__{}", idx.index()).unwrap(),
|
||||
ty::Adt(def, ..) => {
|
||||
write!(
|
||||
&mut symbol,
|
||||
"__{}",
|
||||
def.variant(variant).fields[idx as usize].name.as_str(),
|
||||
def.variant(variant).fields[idx].name.as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -356,11 +356,11 @@ pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tc
|
|||
curr_string = format!(
|
||||
"{}.{}",
|
||||
curr_string,
|
||||
def.variant(variant).fields[idx as usize].name.as_str()
|
||||
def.variant(variant).fields[idx].name.as_str()
|
||||
);
|
||||
}
|
||||
ty::Tuple(_) => {
|
||||
curr_string = format!("{}.{}", curr_string, idx);
|
||||
curr_string = format!("{}.{}", curr_string, idx.index());
|
||||
}
|
||||
_ => {
|
||||
bug!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue