compiler: Add is_uninhabited and use LayoutS accessors

This reduces the need of the compiler to peek on the fields of LayoutS.
This commit is contained in:
Jubilee Young
2024-10-27 21:34:49 -07:00
parent 5f5c243ca0
commit 88a9edc091
20 changed files with 40 additions and 37 deletions

View File

@@ -1652,6 +1652,11 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
}
}
/// Returns `true` if this is an uninhabited type
pub fn is_uninhabited(&self) -> bool {
self.abi.is_uninhabited()
}
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
let size = scalar.size(cx);