Skip to content

Commit 6939189

Browse files
committed
Use opaque blobs for unknown template definition types
When we don't know how to generate a Rust type from a template definition (eg because it uses non-type template parameters), then we should fall back to using the instantiation's layout to generate the opaque blob.
1 parent 02ba502 commit 6939189

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/codegen/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,15 @@ impl ToRustTy for Type {
21182118
let decl = inst.template_definition();
21192119
let mut ty = decl.to_rust_ty(ctx).unwrap();
21202120

2121+
// If we gave up when making a type for the template definition,
2122+
// check if maybe we can make a better opaque blob for the
2123+
// instantiation.
2124+
if ty == aster::AstBuilder::new().ty().unit().unwrap() {
2125+
if let Some(layout) = self.layout(ctx) {
2126+
ty = BlobTyBuilder::new(layout).build().unwrap()
2127+
}
2128+
}
2129+
21212130
// TODO: If the decl type is a template class/struct
21222131
// declaration's member template declaration, it could rely on
21232132
// generic template parameters from its outer template

0 commit comments

Comments
 (0)