Implement printing of nullable wrapped IR layouts

This commit is contained in:
Ayaz Hafiz 2022-12-29 12:17:46 -06:00
parent 58930cc96c
commit d59b137f45
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -805,7 +805,32 @@ impl<'a> UnionLayout<'a> {
.append(tags_doc)
.append(alloc.text("]"))
}
_ => alloc.text("TODO"),
NullableWrapped {
nullable_id,
other_tags,
} => {
let nullable_id = nullable_id as usize;
let tags_docs = (0..(other_tags.len() + 1)).map(|i| {
if i == nullable_id {
alloc.text("<null>")
} else {
let idx = if i > nullable_id { i - 1 } else { i };
alloc.text("C ").append(
alloc.intersperse(
other_tags[idx]
.iter()
.map(|x| x.to_doc(alloc, interner, Parens::InTypeParam)),
" ",
),
)
}
});
let tags_docs = alloc.intersperse(tags_docs, alloc.text(", "));
alloc
.text("[<rnw>")
.append(tags_docs)
.append(alloc.text("]"))
}
}
}