Rollup merge of #104357 - RalfJung:is-sized, r=cjgillot
add is_sized method on Abi and Layout, and use it This avoids the double negation of `!is_unsized()` that we have quite a lot.
This commit is contained in:
commit
8076b5903a
21 changed files with 39 additions and 29 deletions
|
@ -15,7 +15,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
) -> (Bx::Value, Bx::Value) {
|
||||
let layout = bx.layout_of(t);
|
||||
debug!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}", t, info, layout);
|
||||
if !layout.is_unsized() {
|
||||
if layout.is_sized() {
|
||||
let size = bx.const_usize(layout.size.bytes());
|
||||
let align = bx.const_usize(layout.align.abi.bytes());
|
||||
return (size, align);
|
||||
|
|
|
@ -29,7 +29,7 @@ pub struct PlaceRef<'tcx, V> {
|
|||
|
||||
impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||
pub fn new_sized(llval: V, layout: TyAndLayout<'tcx>) -> PlaceRef<'tcx, V> {
|
||||
assert!(!layout.is_unsized());
|
||||
assert!(layout.is_sized());
|
||||
PlaceRef { llval, llextra: None, layout, align: layout.align.abi }
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
layout: TyAndLayout<'tcx>,
|
||||
align: Align,
|
||||
) -> PlaceRef<'tcx, V> {
|
||||
assert!(!layout.is_unsized());
|
||||
assert!(layout.is_sized());
|
||||
PlaceRef { llval, llextra: None, layout, align }
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
bx: &mut Bx,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> Self {
|
||||
assert!(!layout.is_unsized(), "tried to statically allocate unsized place");
|
||||
assert!(layout.is_sized(), "tried to statically allocate unsized place");
|
||||
let tmp = bx.alloca(bx.cx().backend_type(layout), layout.align.abi);
|
||||
Self::new_sized(tmp, layout)
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
);
|
||||
return simple();
|
||||
}
|
||||
_ if !field.is_unsized() => return simple(),
|
||||
_ if field.is_sized() => return simple(),
|
||||
ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(),
|
||||
ty::Adt(def, _) => {
|
||||
if def.repr().packed() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue