Skip to content

Commit 5bda3aa

Browse files
committed
Add a comment documenting the hacky test of () from ToRustTy
1 parent b662443 commit 5bda3aa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/codegen/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ impl CodeGenerator for Type {
562562
BlobTyBuilder::new(layout).build()
563563
} else {
564564
let inner_rust_ty = inner_item.to_rust_ty(ctx);
565+
566+
// We get a unit if the inner type is a template definition
567+
// that is opaque or has non-type template parameters and
568+
// doesn't know its layout. Its possible that we have better
569+
// information about the layout, and in the worst case, just
570+
// make sure we don't return a zero-sized type.
565571
if inner_rust_ty == aster::AstBuilder::new().ty().unit() {
566572
let layout = self.layout(ctx).unwrap_or_else(|| Layout::for_size(1));
567573
BlobTyBuilder::new(layout).build()

0 commit comments

Comments
 (0)