add comment explaining why ty_and_layout_field is not used

Co-authored-by: Jack Wrenn <me@jswrenn.com>
This commit is contained in:
Ralf Jung 2024-12-02 17:56:18 +01:00
parent e023590de4
commit 85f01386da

View file

@ -495,7 +495,10 @@ pub(crate) mod rustc {
(ty, layout): (Ty<'tcx>, Layout<'tcx>),
i: FieldIdx,
) -> Ty<'tcx> {
// FIXME: Why does this not just use `ty_and_layout_field`?
// We cannot use `ty_and_layout_field` to retrieve the field type, since
// `ty_and_layout_field` erases regions in the returned type. We must
// not erase regions here, since we may need to ultimately emit outlives
// obligations as a consequence of the transmutability analysis.
match ty.kind() {
ty::Adt(def, args) => {
match layout.variants {