Skip to content

Commit 89697ec

Browse files
committed
Fixed a bug where self-referential types would cause infinite recursion and stack overflows
1 parent 0d8b77e commit 89697ec

File tree

1 file changed

+6
-0
lines changed
  • crates/rustc_codegen_nvvm/src

1 file changed

+6
-0
lines changed

crates/rustc_codegen_nvvm/src/ty.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,12 @@ fn struct_llfields<'a, 'tcx>(
611611
assert_eq!(offset.align_to(padding_align) + padding, target_offset);
612612
result.push(cx.type_padding_filler(padding, padding_align));
613613
}
614+
match field.ty.kind() {
615+
// FIXME(FractalFir): This is a workaround for recursive types.
616+
// Get rid of this as soon as we don't have to bother with typed pointers
617+
rustc_middle::ty::TyKind::FnPtr(_, _) | rustc_middle::ty::TyKind::RawPtr(_, _) | rustc_middle::ty::TyKind::Ref(_,_, _) => result.push(cx.type_i8p()),
618+
_ => result.push(field.llvm_type(cx)),
619+
}
614620

615621
result.push(field.llvm_type(cx));
616622
offset = target_offset + field.size;

0 commit comments

Comments
 (0)