Skip to content

Commit e631891

Browse files
committed
Auto merge of #104370 - matthiaskrgr:rollup-c3b38sm, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #103996 (Add small clarification around using pointers derived from references) - #104315 (Improve spans with `use crate::{self}`) - #104320 (Use `derive_const` and rm manual StructuralEq impl) - #104357 (add is_sized method on Abi and Layout, and use it) - #104365 (Add x tool to triagebot) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e4d6307 + 39ff9d2 commit e631891

File tree

29 files changed

+73
-32
lines changed

29 files changed

+73
-32
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub(crate) fn codegen_const_value<'tcx>(
128128
ty: Ty<'tcx>,
129129
) -> CValue<'tcx> {
130130
let layout = fx.layout_of(ty);
131-
assert!(!layout.is_unsized(), "sized const value");
131+
assert!(layout.is_sized(), "unsized const value");
132132

133133
if layout.is_zst() {
134134
return CValue::by_ref(crate::Pointer::dangling(layout.align.pref), layout);

compiler/rustc_codegen_cranelift/src/value_and_place.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn codegen_field<'tcx>(
1919
};
2020

2121
if let Some(extra) = extra {
22-
if !field_layout.is_unsized() {
22+
if field_layout.is_sized() {
2323
return simple(fx);
2424
}
2525
match field_layout.ty.kind() {
@@ -364,7 +364,7 @@ impl<'tcx> CPlace<'tcx> {
364364
fx: &mut FunctionCx<'_, '_, 'tcx>,
365365
layout: TyAndLayout<'tcx>,
366366
) -> CPlace<'tcx> {
367-
assert!(!layout.is_unsized());
367+
assert!(layout.is_sized());
368368
if layout.size.bytes() == 0 {
369369
return CPlace {
370370
inner: CPlaceInner::Addr(Pointer::dangling(layout.align.pref), None),
@@ -825,7 +825,7 @@ impl<'tcx> CPlace<'tcx> {
825825
fx: &FunctionCx<'_, '_, 'tcx>,
826826
variant: VariantIdx,
827827
) -> Self {
828-
assert!(!self.layout().is_unsized());
828+
assert!(self.layout().is_sized());
829829
let layout = self.layout().for_variant(fx, variant);
830830
CPlace { inner: self.inner, layout }
831831
}

compiler/rustc_codegen_gcc/src/type_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub fn struct_fields<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
277277
offset = target_offset + field.size;
278278
prev_effective_align = effective_field_align;
279279
}
280-
if !layout.is_unsized() && field_count > 0 {
280+
if layout.is_sized() && field_count > 0 {
281281
if offset > layout.size {
282282
bug!("layout: {:#?} stride: {:?} offset: {:?}", layout, layout.size, offset);
283283
}

compiler/rustc_codegen_llvm/src/debuginfo/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
7272
layout.is_unsized()
7373
);
7474

75-
if !layout.is_unsized() {
75+
if layout.is_sized() {
7676
return None;
7777
}
7878

compiler/rustc_codegen_llvm/src/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn struct_llfields<'a, 'tcx>(
140140
prev_effective_align = effective_field_align;
141141
}
142142
let padding_used = result.len() > field_count;
143-
if !layout.is_unsized() && field_count > 0 {
143+
if layout.is_sized() && field_count > 0 {
144144
if offset > layout.size {
145145
bug!("layout: {:#?} stride: {:?} offset: {:?}", layout, layout.size, offset);
146146
}

compiler/rustc_codegen_ssa/src/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
1515
) -> (Bx::Value, Bx::Value) {
1616
let layout = bx.layout_of(t);
1717
debug!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}", t, info, layout);
18-
if !layout.is_unsized() {
18+
if layout.is_sized() {
1919
let size = bx.const_usize(layout.size.bytes());
2020
let align = bx.const_usize(layout.align.abi.bytes());
2121
return (size, align);

compiler/rustc_codegen_ssa/src/mir/place.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct PlaceRef<'tcx, V> {
2929

3030
impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
3131
pub fn new_sized(llval: V, layout: TyAndLayout<'tcx>) -> PlaceRef<'tcx, V> {
32-
assert!(!layout.is_unsized());
32+
assert!(layout.is_sized());
3333
PlaceRef { llval, llextra: None, layout, align: layout.align.abi }
3434
}
3535

@@ -38,7 +38,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
3838
layout: TyAndLayout<'tcx>,
3939
align: Align,
4040
) -> PlaceRef<'tcx, V> {
41-
assert!(!layout.is_unsized());
41+
assert!(layout.is_sized());
4242
PlaceRef { llval, llextra: None, layout, align }
4343
}
4444

@@ -48,7 +48,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
4848
bx: &mut Bx,
4949
layout: TyAndLayout<'tcx>,
5050
) -> Self {
51-
assert!(!layout.is_unsized(), "tried to statically allocate unsized place");
51+
assert!(layout.is_sized(), "tried to statically allocate unsized place");
5252
let tmp = bx.alloca(bx.cx().backend_type(layout), layout.align.abi);
5353
Self::new_sized(tmp, layout)
5454
}
@@ -145,7 +145,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
145145
);
146146
return simple();
147147
}
148-
_ if !field.is_unsized() => return simple(),
148+
_ if field.is_sized() => return simple(),
149149
ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(),
150150
ty::Adt(def, _) => {
151151
if def.repr().packed() {

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
4646
ecx.tcx.def_kind(cid.instance.def_id())
4747
);
4848
let layout = ecx.layout_of(body.bound_return_ty().subst(tcx, cid.instance.substs))?;
49-
assert!(!layout.is_unsized());
49+
assert!(layout.is_sized());
5050
let ret = ecx.allocate(layout, MemoryKind::Stack)?;
5151

5252
trace!(

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
572572
metadata: &MemPlaceMeta<M::Provenance>,
573573
layout: &TyAndLayout<'tcx>,
574574
) -> InterpResult<'tcx, Option<(Size, Align)>> {
575-
if !layout.is_unsized() {
575+
if layout.is_sized() {
576576
return Ok(Some((layout.size, layout.align.abi)));
577577
}
578578
match layout.ty.kind() {

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
713713
rhs: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>,
714714
) -> InterpResult<'tcx, Scalar<M::Provenance>> {
715715
let layout = self.layout_of(lhs.layout.ty.builtin_deref(true).unwrap().ty)?;
716-
assert!(!layout.is_unsized());
716+
assert!(layout.is_sized());
717717

718718
let get_bytes = |this: &InterpCx<'mir, 'tcx, M>,
719719
op: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>,

0 commit comments

Comments
 (0)