Skip to content

Commit 5cb94e7

Browse files
Add TyKind::TyAlias support in rustc_ty_utils
1 parent 02ee18f commit 5cb94e7

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,12 @@ fn layout_of_uncached<'tcx>(
13451345
bug!("Layout::compute: unexpected type `{}`", ty)
13461346
}
13471347

1348+
ty::TyAlias(def_id, substs) => {
1349+
let binder_ty = tcx.bound_type_of(def_id);
1350+
let ty = binder_ty.subst(tcx, substs);
1351+
return layout_of_uncached(cx, ty);
1352+
}
1353+
13481354
ty::Bound(..) | ty::Param(_) | ty::Error(_) => {
13491355
return Err(LayoutError::Unknown(ty));
13501356
}

compiler/rustc_ty_utils/src/representability.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ fn representability_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Representabilit
4747
}
4848
Representability::Representable
4949
}
50+
ty::TyAlias(def_id, substs) => {
51+
let binder_ty = tcx.bound_type_of(def_id);
52+
let ty = binder_ty.subst(tcx, substs);
53+
representability_ty(tcx, ty)
54+
}
55+
ty::Closure(..) => {
56+
// this check is run on type definitions, so we don't expect
57+
// to see closure types
58+
bug!("requires check invoked on inapplicable type: {:?}", ty)
59+
}
5060
_ => Representability::Representable,
5161
}
5262
}

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn sized_constraint_for_ty<'tcx>(
3737
.collect()
3838
}
3939

40-
Projection(..) | Opaque(..) => {
40+
Projection(..) | Opaque(..) | TyAlias(..) => {
4141
// must calculate explicitly.
4242
// FIXME: consider special-casing always-Sized projections
4343
vec![ty]

0 commit comments

Comments
 (0)