address review
This commit is contained in:
parent
2ef8308687
commit
fd6fed3027
@ -325,6 +325,13 @@ pub(crate) fn clone_project(&self, elem: PlaceElem<'tcx>) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
/// Similar to `Place::ty` but needed during mir building.
|
||||
///
|
||||
/// Applies the projections in the `PlaceBuilder` to the base
|
||||
/// type.
|
||||
///
|
||||
/// Fallible as the root of this place may be an upvar for
|
||||
/// which no base type can be determined.
|
||||
pub fn try_compute_ty<D>(
|
||||
&self,
|
||||
local_decls: &D,
|
||||
|
@ -54,10 +54,20 @@ pub(crate) fn field_match_pairs_tuple_struct<'pat>(
|
||||
let variant_idx = opt_variant_idx.unwrap();
|
||||
adt_def.variant(variant_idx).fields[field_idx].ty(self.tcx, substs)
|
||||
}
|
||||
ty::Adt(adt_def, substs) => {
|
||||
adt_def.all_fields().collect::<Vec<_>>()[field_idx].ty(self.tcx, substs)
|
||||
}
|
||||
ty::Tuple(elems) => elems.to_vec()[field_idx],
|
||||
ty::Adt(adt_def, substs) => adt_def
|
||||
.all_fields()
|
||||
.nth(field_idx)
|
||||
.unwrap_or_else(|| {
|
||||
bug!(
|
||||
"expected to take field idx {:?} of fields of {:?}",
|
||||
field_idx,
|
||||
adt_def
|
||||
)
|
||||
})
|
||||
.ty(self.tcx, substs),
|
||||
ty::Tuple(elems) => elems.iter().nth(field_idx).unwrap_or_else(|| {
|
||||
bug!("expected to take field idx {:?} of {:?}", field_idx, elems)
|
||||
}),
|
||||
_ => bug!(
|
||||
"no field available, place_ty: {:#?}, kind: {:?}",
|
||||
place_ty,
|
||||
|
Loading…
Reference in New Issue
Block a user