Skip to content

Commit 59b380f

Browse files
committed
field path lowering, do check the field's type if the kind is OffsetOf
1 parent d32a380 commit 59b380f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
410410
}
411411

412412
field_indices.push((FIRST_VARIANT, index));
413-
if !last {
413+
if field_path_kind == FieldPathKind::OffsetOf || !last {
414414
let field_ty = field.ty(self.tcx, args);
415415
current_container = field_ty;
416416
}

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
362362
self.private_field_err(ident, container_def.did()).emit();
363363
}
364364

365-
if !last {
365+
if field_path_kind == FieldPathKind::OffsetOf || !last {
366366
let field_ty = self.field_ty(span, field, args);
367367

368368
// Enums are anyway always sized. But just to safeguard against future
@@ -402,7 +402,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
402402
self.private_field_err(ident, container_def.did()).emit();
403403
}
404404

405-
if !last {
405+
if field_path_kind == FieldPathKind::OffsetOf || !last {
406406
let field_ty = self.field_ty(span, field, args);
407407

408408
match field_path_kind {

0 commit comments

Comments
 (0)