1
Fork 0

use List<Ty<'tcx>> for tuples

This commit is contained in:
lcnr 2022-02-07 16:06:31 +01:00
parent a9c1ab82f5
commit 1245131a11
53 changed files with 128 additions and 170 deletions

View file

@ -256,7 +256,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
// We must have inferred the capture types since we are building MIR, therefore
// it's safe to call `tuple_element_ty` and we can unwrap here because
// we know that the capture exists and is the `capture_index`-th capture.
let var_ty = substs.tupled_upvars_ty().tuple_element_ty(capture_index).unwrap();
let var_ty = substs.tupled_upvars_ty().tuple_fields()[capture_index];
upvar_resolved_place_builder =
upvar_resolved_place_builder.field(Field::new(capture_index), var_ty);

View file

@ -1209,7 +1209,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
) -> Self {
let ret = match constructor {
Single | Variant(_) => match ty.kind() {
ty::Tuple(fs) => Fields::wildcards_from_tys(cx, fs.iter().map(|ty| ty.expect_ty())),
ty::Tuple(fs) => Fields::wildcards_from_tys(cx, fs.iter()),
ty::Ref(_, rty, _) => Fields::wildcards_from_tys(cx, once(*rty)),
ty::Adt(adt, substs) => {
if adt.is_box() {
@ -1315,11 +1315,8 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
match pat.ty.kind() {
ty::Tuple(fs) => {
ctor = Single;
let mut wilds: SmallVec<[_; 2]> = fs
.iter()
.map(|ty| ty.expect_ty())
.map(DeconstructedPat::wildcard)
.collect();
let mut wilds: SmallVec<[_; 2]> =
fs.iter().map(DeconstructedPat::wildcard).collect();
for pat in subpatterns {
wilds[pat.field.index()] = mkpat(&pat.pattern);
}