From 625ad60ecae1e78ae84ad04ad0316c8640d8bdc8 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 19 Nov 2022 13:33:46 -0500 Subject: [PATCH] Check for occupied niches --- compiler/rustc_codegen_ssa/src/common.rs | 9 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 30 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 1 + .../rustc_codegen_ssa/src/mir/niche_check.rs | 296 ++++++++++++++++++ compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 6 +- .../rustc_codegen_ssa/src/mir/statement.rs | 19 ++ compiler/rustc_codegen_ssa/src/size_of_val.rs | 2 +- compiler/rustc_hir/src/lang_items.rs | 1 + compiler/rustc_middle/src/mir/mono.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 8 + compiler/rustc_monomorphize/src/collector.rs | 21 ++ .../rustc_monomorphize/src/partitioning.rs | 53 ++++ compiler/rustc_span/src/symbol.rs | 1 + library/core/src/panicking.rs | 16 + src/tools/tidy/src/ui_tests.rs | 2 +- .../future-sizes/async-awaiting-fut.stdout | 73 +++++ .../async-await/future-sizes/large-arg.stdout | 73 +++++ tests/ui/niche_checks/invalid_enums.rs | 23 ++ .../niche_checks/invalid_nonnull_transmute.rs | 10 + .../niche_checks/invalid_nonzero_argument.rs | 14 + tests/ui/niche_checks/invalid_option.rs | 10 + tests/ui/niche_checks/operand_pair.rs | 12 + .../ui/niche_checks/valid_nonzero_argument.rs | 13 + tests/ui/print_type_sizes/anonymous.stdout | 73 +++++ tests/ui/print_type_sizes/async.stdout | 73 +++++ tests/ui/print_type_sizes/coroutine.stdout | 73 +++++ .../coroutine_discr_placement.stdout | 73 +++++ tests/ui/print_type_sizes/generics.stdout | 73 +++++ .../ui/print_type_sizes/multiple_types.stdout | 73 +++++ .../ui/print_type_sizes/niche-filling.stdout | 73 +++++ .../ui/print_type_sizes/no_duplicates.stdout | 73 +++++ tests/ui/print_type_sizes/packed.stdout | 73 +++++ tests/ui/print_type_sizes/padding.stdout | 73 +++++ tests/ui/print_type_sizes/repr-align.stdout | 73 +++++ tests/ui/print_type_sizes/repr_int_c.stdout | 73 +++++ tests/ui/print_type_sizes/uninhabited.stdout | 73 +++++ tests/ui/print_type_sizes/variants.stdout | 73 +++++ .../print_type_sizes/zero-sized-fields.stdout | 73 +++++ 38 files changed, 1775 insertions(+), 15 deletions(-) create mode 100644 compiler/rustc_codegen_ssa/src/mir/niche_check.rs create mode 100644 tests/ui/niche_checks/invalid_enums.rs create mode 100644 tests/ui/niche_checks/invalid_nonnull_transmute.rs create mode 100644 tests/ui/niche_checks/invalid_nonzero_argument.rs create mode 100644 tests/ui/niche_checks/invalid_option.rs create mode 100644 tests/ui/niche_checks/operand_pair.rs create mode 100644 tests/ui/niche_checks/valid_nonzero_argument.rs create mode 100644 tests/ui/print_type_sizes/anonymous.stdout diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index 71fca403defb5..cfe22338e4c2f 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -3,7 +3,7 @@ use rustc_hir::LangItem; use rustc_middle::mir; use rustc_middle::ty::Instance; -use rustc_middle::ty::{self, layout::TyAndLayout, Ty, TyCtxt}; +use rustc_middle::ty::{self, layout::TyAndLayout, GenericArg, Ty, TyCtxt}; use rustc_span::Span; use crate::base; @@ -121,10 +121,15 @@ pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &Bx, span: Option, li: LangItem, + generic: Option>, ) -> (Bx::FnAbiOfResult, Bx::Value, Instance<'tcx>) { let tcx = bx.tcx(); let def_id = tcx.require_lang_item(li, span); - let instance = ty::Instance::mono(tcx, def_id); + let instance = if let Some(arg) = generic { + ty::Instance::new(def_id, tcx.mk_args(&[arg])) + } else { + ty::Instance::mono(tcx, def_id) + }; (bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance), instance) } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index d4123329f4481..49f38b72eb445 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -687,7 +687,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } }; - let (fn_abi, llfn, instance) = common::build_langcall(bx, Some(span), lang_item); + let (fn_abi, llfn, instance) = common::build_langcall(bx, Some(span), lang_item, None); // Codegen the actual panic invoke/call. let merging_succ = @@ -707,7 +707,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { self.set_debug_loc(bx, terminator.source_info); // Obtain the panic entry point. - let (fn_abi, llfn, instance) = common::build_langcall(bx, Some(span), reason.lang_item()); + let (fn_abi, llfn, instance) = + common::build_langcall(bx, Some(span), reason.lang_item(), None); // Codegen the actual panic invoke/call. let merging_succ = helper.do_call( @@ -769,8 +770,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let msg = bx.const_str(&msg_str); // Obtain the panic entry point. - let (fn_abi, llfn, instance) = - common::build_langcall(bx, Some(source_info.span), LangItem::PanicNounwind); + let (fn_abi, llfn, instance) = common::build_langcall( + bx, + Some(source_info.span), + LangItem::PanicNounwind, + None, + ); // Codegen the actual panic invoke/call. helper.do_call( @@ -1289,6 +1294,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ) -> MergingSucc { debug!("codegen_terminator: {:?}", terminator); + if bx.tcx().may_insert_niche_checks() { + if let mir::TerminatorKind::Return = terminator.kind { + let op = mir::Operand::Copy(mir::Place::return_place()); + let ty = op.ty(self.mir, bx.tcx()); + let ty = self.monomorphize(ty); + if let Some(niche) = bx.layout_of(ty).largest_niche { + self.codegen_niche_check(bx, op, niche, terminator.source_info); + } + } + } + let helper = TerminatorCodegenHelper { bb, terminator }; let mergeable_succ = || { @@ -1557,7 +1573,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { tuple.layout.fields.count() } - fn get_caller_location( + pub fn get_caller_location( &mut self, bx: &mut Bx, source_info: mir::SourceInfo, @@ -1698,12 +1714,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { self.set_debug_loc(&mut bx, mir::SourceInfo::outermost(self.mir.span)); - let (fn_abi, fn_ptr, instance) = common::build_langcall(&bx, None, reason.lang_item()); + let (fn_abi, fn_ptr, instance) = + common::build_langcall(&bx, None, reason.lang_item(), None); if is_call_from_compiler_builtins_to_upstream_monomorphization(bx.tcx(), instance) { bx.abort(); } else { let fn_ty = bx.fn_decl_backend_type(fn_abi); - let llret = bx.call(fn_ty, None, Some(fn_abi), fn_ptr, &[], funclet.as_ref(), None); bx.apply_attrs_to_cleanup_callsite(llret); } diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 387a5366b209b..addf9323c80e2 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -18,6 +18,7 @@ pub mod coverageinfo; pub mod debuginfo; mod intrinsic; mod locals; +mod niche_check; pub mod operand; pub mod place; mod rvalue; diff --git a/compiler/rustc_codegen_ssa/src/mir/niche_check.rs b/compiler/rustc_codegen_ssa/src/mir/niche_check.rs new file mode 100644 index 0000000000000..e38cea6de4974 --- /dev/null +++ b/compiler/rustc_codegen_ssa/src/mir/niche_check.rs @@ -0,0 +1,296 @@ +use rustc_hir::LangItem; +use rustc_middle::mir; +use rustc_middle::mir::visit::Visitor; +use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext}; +use rustc_middle::ty::Mutability; +use rustc_middle::ty::Ty; +use rustc_middle::ty::TyCtxt; +use rustc_span::def_id::LOCAL_CRATE; +use rustc_span::Span; +use rustc_target::abi::Integer; +use rustc_target::abi::Niche; +use rustc_target::abi::Primitive; +use rustc_target::abi::Size; + +use super::FunctionCx; +use crate::base; +use crate::common; +use crate::mir::OperandValue; +use crate::traits::*; + +pub struct NicheFinder<'s, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> { + pub fx: &'s mut FunctionCx<'a, 'tcx, Bx>, + pub bx: &'s mut Bx, + pub places: Vec<(mir::Operand<'tcx>, Niche)>, +} + +impl<'s, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> for NicheFinder<'s, 'a, 'tcx, Bx> { + fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: mir::Location) { + match rvalue { + mir::Rvalue::Cast(mir::CastKind::Transmute, op, ty) => { + let ty = self.fx.monomorphize(*ty); + if let Some(niche) = self.bx.layout_of(ty).largest_niche { + self.places.push((op.clone(), niche)); + } + } + _ => self.super_rvalue(rvalue, location), + } + } + + fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, _location: mir::Location) { + if let mir::TerminatorKind::Return = terminator.kind { + let op = mir::Operand::Copy(mir::Place::return_place()); + let ty = op.ty(self.fx.mir, self.bx.tcx()); + let ty = self.fx.monomorphize(ty); + if let Some(niche) = self.bx.layout_of(ty).largest_niche { + self.places.push((op, niche)); + } + } + } + + fn visit_place( + &mut self, + place: &mir::Place<'tcx>, + context: PlaceContext, + _location: mir::Location, + ) { + match context { + PlaceContext::NonMutatingUse( + NonMutatingUseContext::Copy | NonMutatingUseContext::Move, + ) => {} + _ => { + return; + } + } + + let ty = place.ty(self.fx.mir, self.bx.tcx()).ty; + let ty = self.fx.monomorphize(ty); + if let Some(niche) = self.bx.layout_of(ty).largest_niche { + self.places.push((mir::Operand::Copy(*place), niche)); + }; + } +} + +use rustc_target::abi::Abi; +use rustc_target::abi::Scalar; +use rustc_target::abi::WrappingRange; +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { + fn value_in_niche( + &mut self, + bx: &mut Bx, + op: crate::mir::OperandRef<'tcx, Bx::Value>, + niche: Niche, + ) -> Option { + let niche_ty = niche.ty(bx.tcx()); + let niche_layout = bx.layout_of(niche_ty); + + let (imm, from_scalar, from_backend_ty) = match op.val { + OperandValue::Immediate(imm) => { + let Abi::Scalar(from_scalar) = op.layout.abi else { unreachable!() }; + let from_backend_ty = bx.backend_type(op.layout); + (imm, from_scalar, from_backend_ty) + } + OperandValue::Pair(first, second) => { + let Abi::ScalarPair(first_scalar, second_scalar) = op.layout.abi else { + unreachable!() + }; + if niche.offset == Size::ZERO { + (first, first_scalar, bx.scalar_pair_element_backend_type(op.layout, 0, true)) + } else { + // yolo + (second, second_scalar, bx.scalar_pair_element_backend_type(op.layout, 1, true)) + } + } + OperandValue::ZeroSized => unreachable!(), + OperandValue::Ref(ptr, _metadata, _align) => { + // General case: Load the niche primitive via pointer arithmetic. + let niche_ptr_ty = Ty::new_ptr(bx.tcx(), niche_ty, Mutability::Not); + let ptr = bx.pointercast(ptr, bx.backend_type(bx.layout_of(niche_ptr_ty))); + + let offset = niche.offset.bytes() / niche_layout.size.bytes(); + let niche_backend_ty = bx.backend_type(bx.layout_of(niche_ty)); + let ptr = bx.inbounds_gep(niche_backend_ty, ptr, &[bx.const_usize(offset)]); + let value = bx.load(niche_backend_ty, ptr, rustc_target::abi::Align::ONE); + return Some(value); + } + }; + + // Any type whose ABI is a Scalar bool is turned into an i1, so it cannot contain a value + // outside of its niche. + if from_scalar.is_bool() { + return None; + } + + let to_scalar = Scalar::Initialized { + value: niche.value, + valid_range: WrappingRange::full(niche.size(bx.tcx())), + }; + let to_backend_ty = bx.backend_type(niche_layout); + if from_backend_ty == to_backend_ty { + return Some(imm); + } + let value = self.transmute_immediate( + bx, + imm, + from_scalar, + from_backend_ty, + to_scalar, + to_backend_ty, + ); + Some(value) + } + + #[instrument(level = "debug", skip(self, bx))] + pub fn codegen_niche_check( + &mut self, + bx: &mut Bx, + mir_op: mir::Operand<'tcx>, + niche: Niche, + source_info: mir::SourceInfo, + ) { + let op_ty = self.monomorphize(mir_op.ty(self.mir, bx.tcx())); + if op_ty == bx.tcx().types.bool { + return; + } + + let op = self.codegen_operand(bx, &mir_op); + + let Some(value_in_niche) = self.value_in_niche(bx, op, niche) else { + return; + }; + let size = niche.size(bx.tcx()); + + let start = niche.scalar(niche.valid_range.start, bx); + let end = niche.scalar(niche.valid_range.end, bx); + + let binop_le = base::bin_op_to_icmp_predicate(mir::BinOp::Le.to_hir_binop(), false); + let binop_ge = base::bin_op_to_icmp_predicate(mir::BinOp::Ge.to_hir_binop(), false); + let is_valid = if niche.valid_range.start == 0 { + bx.icmp(binop_le, value_in_niche, end) + } else if niche.valid_range.end == (u128::MAX >> 128 - size.bits()) { + bx.icmp(binop_ge, value_in_niche, start) + } else { + // We need to check if the value is within a *wrapping* range. We could do this: + // (niche >= start) && (niche <= end) + // But what we're going to actually do is this: + // max = end - start + // (niche - start) <= max + // The latter is much more complicated conceptually, but is actually less operations + // because we can compute max in codegen. + let mut max = niche.valid_range.end.wrapping_sub(niche.valid_range.start); + let size = niche.size(bx.tcx()); + if size.bits() < 128 { + let mask = (1 << size.bits()) - 1; + max &= mask; + } + let max_adjusted_allowed_value = niche.scalar(max, bx); + + let biased = bx.sub(value_in_niche, start); + bx.icmp(binop_le, biased, max_adjusted_allowed_value) + }; + + // Create destination blocks, branching on is_valid + let panic = bx.append_sibling_block("panic"); + let success = bx.append_sibling_block("success"); + bx.cond_br(is_valid, success, panic); + + // Switch to the failure block and codegen a call to the panic intrinsic + bx.switch_to_block(panic); + self.set_debug_loc(bx, source_info); + let location = self.get_caller_location(bx, source_info).immediate(); + self.codegen_panic( + bx, + LangItem::PanicOccupiedNiche, + &[value_in_niche, start, end, location], + source_info.span, + niche.ty(bx.tcx()), + ); + + // Continue codegen in the success block. + bx.switch_to_block(success); + self.set_debug_loc(bx, source_info); + } + + #[instrument(level = "debug", skip(self, bx))] + fn codegen_panic( + &mut self, + bx: &mut Bx, + lang_item: LangItem, + args: &[Bx::Value], + span: Span, + ty: Ty<'tcx>, + ) { + if bx.tcx().is_compiler_builtins(LOCAL_CRATE) { + bx.abort() + } else { + let (fn_abi, fn_ptr, instance) = + common::build_langcall(bx, Some(span), lang_item, Some(ty.into())); + let fn_ty = bx.fn_decl_backend_type(&fn_abi); + let fn_attrs = if bx.tcx().def_kind(self.instance.def_id()).has_codegen_attrs() { + Some(bx.tcx().codegen_fn_attrs(self.instance.def_id())) + } else { + None + }; + bx.call(fn_ty, fn_attrs, Some(&fn_abi), fn_ptr, args, None, Some(instance)); + } + bx.unreachable(); + } +} + +pub trait NicheExt { + fn ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>; + fn size<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Size; + fn scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(&self, val: u128, bx: &mut Bx) -> Bx::Value; +} + +impl NicheExt for Niche { + fn ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { + let types = &tcx.types; + match self.value { + Primitive::Int(Integer::I8, _) => types.u8, + Primitive::Int(Integer::I16, _) => types.u16, + Primitive::Int(Integer::I32, _) => types.u32, + Primitive::Int(Integer::I64, _) => types.u64, + Primitive::Int(Integer::I128, _) => types.u128, + Primitive::Pointer(_) => Ty::new_ptr(tcx, types.unit, Mutability::Not), + Primitive::F16 => types.u16, + Primitive::F32 => types.u32, + Primitive::F64 => types.u64, + Primitive::F128 => types.u128, + } + } + + fn size<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Size { + let bits = match self.value { + Primitive::Int(Integer::I8, _) => 8, + Primitive::Int(Integer::I16, _) => 16, + Primitive::Int(Integer::I32, _) => 32, + Primitive::Int(Integer::I64, _) => 64, + Primitive::Int(Integer::I128, _) => 128, + Primitive::Pointer(_) => tcx.sess.target.pointer_width as usize, + Primitive::F16 => 16, + Primitive::F32 => 32, + Primitive::F64 => 64, + Primitive::F128 => 128, + }; + Size::from_bits(bits) + } + + fn scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(&self, val: u128, bx: &mut Bx) -> Bx::Value { + use rustc_middle::mir::interpret::Pointer; + use rustc_middle::mir::interpret::Scalar; + + let tcx = bx.tcx(); + let niche_ty = self.ty(tcx); + let value = if niche_ty.is_any_ptr() { + Scalar::from_maybe_pointer(Pointer::from_addr_invalid(val as u64), &tcx) + } else { + Scalar::from_uint(val, self.size(tcx)) + }; + let layout = rustc_target::abi::Scalar::Initialized { + value: self.value, + valid_range: WrappingRange::full(self.size(tcx)), + }; + bx.scalar_to_backend(value, layout, bx.backend_type(bx.layout_of(self.ty(tcx)))) + } +} diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 0af84ff067af4..1e330680049c6 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -155,7 +155,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } - fn codegen_transmute( + pub fn codegen_transmute( &mut self, bx: &mut Bx, src: OperandRef<'tcx, Bx::Value>, @@ -190,7 +190,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { /// /// Returns `None` for cases that can't work in that framework, such as for /// `Immediate`->`Ref` that needs an `alloc` to get the location. - fn codegen_transmute_operand( + pub fn codegen_transmute_operand( &mut self, bx: &mut Bx, operand: OperandRef<'tcx, Bx::Value>, @@ -281,7 +281,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { /// /// `to_backend_ty` must be the *non*-immediate backend type (so it will be /// `i8`, not `i1`, for `bool`-like types.) - fn transmute_immediate( + pub fn transmute_immediate( &self, bx: &mut Bx, mut imm: Bx::Value, diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs index 2188eeae42686..1632f946427da 100644 --- a/compiler/rustc_codegen_ssa/src/mir/statement.rs +++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs @@ -1,15 +1,34 @@ use rustc_middle::mir; +use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::NonDivergingIntrinsic; use rustc_session::config::OptLevel; use super::FunctionCx; use super::LocalRef; +use crate::mir::niche_check::NicheFinder; use crate::traits::*; impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { + fn niches_to_check( + &mut self, + bx: &mut Bx, + statement: &mir::Statement<'tcx>, + ) -> Vec<(mir::Operand<'tcx>, rustc_target::abi::Niche)> { + let mut finder = NicheFinder { fx: self, bx, places: Vec::new() }; + finder.visit_statement(statement, rustc_middle::mir::Location::START); + finder.places + } + #[instrument(level = "debug", skip(self, bx))] pub fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) { self.set_debug_loc(bx, statement.source_info); + + if bx.tcx().may_insert_niche_checks() { + for (op, niche) in self.niches_to_check(bx, statement) { + self.codegen_niche_check(bx, op, niche, statement.source_info); + } + } + match statement.kind { mir::StatementKind::Assign(box (ref place, ref rvalue)) => { if let Some(index) = place.as_local() { diff --git a/compiler/rustc_codegen_ssa/src/size_of_val.rs b/compiler/rustc_codegen_ssa/src/size_of_val.rs index c250cc2682323..0bab9f654e95d 100644 --- a/compiler/rustc_codegen_ssa/src/size_of_val.rs +++ b/compiler/rustc_codegen_ssa/src/size_of_val.rs @@ -63,7 +63,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // Obtain the panic entry point. let (fn_abi, llfn, _instance) = - common::build_langcall(bx, None, LangItem::PanicNounwind); + common::build_langcall(bx, None, LangItem::PanicNounwind, None); // Generate the call. // Cannot use `do_call` since we don't have a MIR terminator so we can't create a `TerminationCodegenHelper`. diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index da59276857059..f1faea468a33b 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -243,6 +243,7 @@ language_item_table! { ConstPanicFmt, sym::const_panic_fmt, const_panic_fmt, Target::Fn, GenericRequirement::None; PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, Target::Fn, GenericRequirement::Exact(0); PanicMisalignedPointerDereference, sym::panic_misaligned_pointer_dereference, panic_misaligned_pointer_dereference_fn, Target::Fn, GenericRequirement::Exact(0); + PanicOccupiedNiche, sym::panic_occupied_niche, panic_occupied_niche_fn, Target::Fn, GenericRequirement::Exact(1); PanicInfo, sym::panic_info, panic_info, Target::Struct, GenericRequirement::None; PanicLocation, sym::panic_location, panic_location, Target::Struct, GenericRequirement::None; PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None; diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 43e1318a75ab1..d536faaf4a5bc 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -17,7 +17,7 @@ use std::fmt; use std::hash::Hash; /// Describes how a monomorphization will be instantiated in object files. -#[derive(PartialEq)] +#[derive(PartialEq, Debug)] pub enum InstantiationMode { /// There will be exactly one instance of the given MonoItem. It will have /// external linkage so that it can be linked to from other codegen units. diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 188cb50849dc1..76bbe0f839f4a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2507,6 +2507,14 @@ impl<'tcx> TyCtxt<'tcx> { pub fn impl_polarity(self, def_id: impl IntoQueryParam) -> ty::ImplPolarity { self.impl_trait_header(def_id).map_or(ty::ImplPolarity::Positive, |h| h.polarity) } + + /// Whether a codegen backend may emit alignment checks for pointers when they are + /// read or written through. If this returns true, the backend is allowed to emit such checks. + /// If this returns false, the backend must not emit such checks. + pub fn may_insert_niche_checks(self) -> bool { + let has_panic_shim = self.lang_items().get(LangItem::PanicOccupiedNiche).is_some(); + has_panic_shim && self.sess.opts.debug_assertions + } } /// Parameter attributes that can only be determined by examining the body of a function instead diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 0c35f9838ed3f..862727435472f 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -220,6 +220,7 @@ use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion}; use rustc_middle::ty::layout::ValidityRequirement; use rustc_middle::ty::print::with_no_trimmed_paths; +use rustc_middle::ty::Mutability; use rustc_middle::ty::{ self, AssocKind, GenericParamDefKind, Instance, InstanceDef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, VtblEntry, @@ -228,6 +229,7 @@ use rustc_middle::ty::{GenericArgKind, GenericArgs}; use rustc_session::config::EntryFnType; use rustc_session::lint::builtin::LARGE_ASSIGNMENTS; use rustc_session::Limit; +use rustc_span::def_id::LOCAL_CRATE; use rustc_span::source_map::{dummy_spanned, respan, Spanned}; use rustc_span::symbol::{sym, Ident}; use rustc_span::{Span, DUMMY_SP}; @@ -1533,6 +1535,25 @@ fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionStrategy) -> Vec = codegen_units.into_values().collect(); codegen_units.sort_by(|a, b| a.name().as_str().cmp(b.name().as_str())); + let tcx = cx.tcx; + if tcx.may_insert_niche_checks() && !tcx.is_compiler_builtins(LOCAL_CRATE) { + for cgu in &mut codegen_units { + for ty in [ + tcx.types.u8, + tcx.types.u16, + tcx.types.u32, + tcx.types.u64, + tcx.types.u128, + Ty::new_ptr(tcx, tcx.types.unit, Mutability::Not), + ] { + let Some(def_id) = tcx.lang_items().get(rustc_hir::LangItem::PanicOccupiedNiche) + else { + continue; + }; + let instance = rustc_middle::ty::Instance::new(def_id, tcx.mk_args(&[ty.into()])); + let mono_item = MonoItem::Fn(instance.polymorphize(tcx)); + cgu.items_mut().insert( + mono_item, + MonoItemData { + inlined: false, + linkage: Linkage::Internal, + visibility: Visibility::Default, + size_estimate: mono_item.size_estimate(tcx), + }, + ); + + let mut reachable_inlined_items = FxHashSet::default(); + get_reachable_inlined_items( + cx.tcx, + mono_item, + cx.usage_map, + &mut reachable_inlined_items, + ); + for inlined_item in reachable_inlined_items { + cgu.items_mut().entry(inlined_item).or_insert_with(|| MonoItemData { + inlined: true, + linkage: Linkage::Internal, + visibility: Visibility::Default, + size_estimate: inlined_item.size_estimate(cx.tcx), + }); + } + } + } + } + for cgu in codegen_units.iter_mut() { cgu.compute_size_estimate(); } @@ -808,6 +856,11 @@ fn mono_item_visibility<'tcx>( return Visibility::Hidden; } + if tcx.lang_items().get(rustc_hir::LangItem::PanicOccupiedNiche) == Some(def_id) { + *can_be_internalized = false; + return Visibility::Hidden; + } + let is_generic = instance.args.non_erasable_generics(tcx, def_id).next().is_some(); // Upstream `DefId` instances get different handling than local ones. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 998b1a5c7eaa9..379cd4838b7d8 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1332,6 +1332,7 @@ symbols! { panic_location, panic_misaligned_pointer_dereference, panic_nounwind, + panic_occupied_niche, panic_runtime, panic_str, panic_unwind, diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index cbb0a7d61db05..d3753655eb39b 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -286,6 +286,22 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! { ) } +#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] +#[cfg_attr(feature = "panic_immediate_abort", inline)] +#[track_caller] +#[cfg_attr(not(bootstrap), lang = "panic_occupied_niche")] // needed by codegen for panic on occupied niches +#[rustc_nounwind] +fn panic_occupied_niche(found: T, min: T, max: T) -> ! { + if cfg!(feature = "panic_immediate_abort") { + super::intrinsics::abort() + } + + panic_nounwind_fmt( + format_args!("occupied niche: found {found:?} but must be in {min:?}..={max:?}"), + /* force_no_backtrace */ false, + ) +} + /// Panic because we cannot unwind out of a function. /// /// This is a separate function to avoid the codesize impact of each crate containing the string to diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index fe27964981e06..cd63fda4a62a4 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -18,7 +18,7 @@ const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1750; -const ROOT_ENTRY_LIMIT: usize = 860; +const ROOT_ENTRY_LIMIT: usize = 861; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index def967ba195ef..e4ad7e80628ee 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -50,6 +50,70 @@ print-type-size variant `Returned`: 1024 bytes print-type-size upvar `.arg`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.arg`: 1024 bytes +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes print-type-size type: `std::mem::ManuallyDrop`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes @@ -62,6 +126,12 @@ print-type-size type: `std::mem::MaybeUninit<{async fn body of wait()}>`: 1 byte print-type-size variant `MaybeUninit`: 1 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 1 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Ready`: 0 bytes @@ -72,3 +142,6 @@ print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/future-sizes/large-arg.stdout b/tests/ui/async-await/future-sizes/large-arg.stdout index 67168a3d6ef74..6fb50773dd499 100644 --- a/tests/ui/async-await/future-sizes/large-arg.stdout +++ b/tests/ui/async-await/future-sizes/large-arg.stdout @@ -58,3 +58,76 @@ print-type-size variant `Returned`: 1024 bytes print-type-size upvar `.t`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.t`: 1024 bytes +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/niche_checks/invalid_enums.rs b/tests/ui/niche_checks/invalid_enums.rs new file mode 100644 index 0000000000000..3de2b591a5e08 --- /dev/null +++ b/tests/ui/niche_checks/invalid_enums.rs @@ -0,0 +1,23 @@ +//@ run-fail +//@ ignore-wasm32-bare: No panic messages +//@ compile-flags: -C debug-assertions -Zmir-opt-level=0 + +#[repr(C)] +struct Thing { + x: usize, + y: Contents, + z: usize, +} + +#[repr(usize)] +enum Contents { + A = 8usize, + B = 9usize, + C = 10usize, +} + +fn main() { + unsafe { + let _thing = std::mem::transmute::<(usize, usize, usize), Thing>((0, 3, 0)); + } +} diff --git a/tests/ui/niche_checks/invalid_nonnull_transmute.rs b/tests/ui/niche_checks/invalid_nonnull_transmute.rs new file mode 100644 index 0000000000000..8e0213570a9c1 --- /dev/null +++ b/tests/ui/niche_checks/invalid_nonnull_transmute.rs @@ -0,0 +1,10 @@ +//@ run-fail +//@ ignore-wasm32-bare: No panic messages +//@ compile-flags: -C debug-assertions -Zmir-opt-level=0 +//@ error-pattern: occupied niche: found 0x0 but must be in 0x1..=0xffffffff + +fn main() { + unsafe { + std::mem::transmute::<*const u8, std::ptr::NonNull>(std::ptr::null()); + } +} diff --git a/tests/ui/niche_checks/invalid_nonzero_argument.rs b/tests/ui/niche_checks/invalid_nonzero_argument.rs new file mode 100644 index 0000000000000..efa0105935b5e --- /dev/null +++ b/tests/ui/niche_checks/invalid_nonzero_argument.rs @@ -0,0 +1,14 @@ +//@ run-fail +//@ ignore-wasm32-bare: No panic messages +//@ compile-flags: -C debug-assertions -Zmir-opt-level=0 +//@ error-pattern: occupied niche: found 0 but must be in 1..=255 + +fn main() { + let mut bad = std::num::NonZeroU8::new(1u8).unwrap(); + unsafe { + std::ptr::write_bytes(&mut bad, 0u8, 1usize); + } + func(bad); +} + +fn func(_t: T) {} diff --git a/tests/ui/niche_checks/invalid_option.rs b/tests/ui/niche_checks/invalid_option.rs new file mode 100644 index 0000000000000..f5fbf98f69981 --- /dev/null +++ b/tests/ui/niche_checks/invalid_option.rs @@ -0,0 +1,10 @@ +//@ run-fail +//@ ignore-wasm32-bare: No panic messages +//@ compile-flags: -C debug-assertions -Zmir-opt-level=0 +//@ error-pattern: occupied niche: found 2 but must be in 0..=1 + +fn main() { + unsafe { + std::mem::transmute::<(u8, u8), Option>((2, 0)); + } +} diff --git a/tests/ui/niche_checks/operand_pair.rs b/tests/ui/niche_checks/operand_pair.rs new file mode 100644 index 0000000000000..993ae5b71e060 --- /dev/null +++ b/tests/ui/niche_checks/operand_pair.rs @@ -0,0 +1,12 @@ +//@ run-fail +//@ ignore-wasm32-bare: No panic messages +//@ compile-flags: -C debug-assertions -Zmir-opt-level=0 +//@ error-pattern: occupied niche: found 0x0 but must be in 0x1..=0xffffffff + +use std::ptr::NonNull; + +fn main() { + unsafe { + std::mem::transmute::<(usize, *const u8), (usize, NonNull)>((0usize, std::ptr::null())); + } +} diff --git a/tests/ui/niche_checks/valid_nonzero_argument.rs b/tests/ui/niche_checks/valid_nonzero_argument.rs new file mode 100644 index 0000000000000..6237e7b6cddf2 --- /dev/null +++ b/tests/ui/niche_checks/valid_nonzero_argument.rs @@ -0,0 +1,13 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions -Zmir-opt-level=0 + +fn main() { + for val in i8::MIN..=i8::MAX { + if val != 0 { + let x = std::num::NonZeroI8::new(val).unwrap(); + if val != i8::MIN { + let _y = -x; + } + } + } +} diff --git a/tests/ui/print_type_sizes/anonymous.stdout b/tests/ui/print_type_sizes/anonymous.stdout new file mode 100644 index 0000000000000..bf7eb45bd7840 --- /dev/null +++ b/tests/ui/print_type_sizes/anonymous.stdout @@ -0,0 +1,73 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/async.stdout b/tests/ui/print_type_sizes/async.stdout index 83a6962e4cd13..b0764c1f7480f 100644 --- a/tests/ui/print_type_sizes/async.stdout +++ b/tests/ui/print_type_sizes/async.stdout @@ -16,12 +16,82 @@ print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment print-type-size variant `MaybeUninit`: 8192 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 8192 bytes +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 1 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Ready`: 0 bytes @@ -32,3 +102,6 @@ print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/coroutine.stdout b/tests/ui/print_type_sizes/coroutine.stdout index 5d51339558caf..ee643e28828aa 100644 --- a/tests/ui/print_type_sizes/coroutine.stdout +++ b/tests/ui/print_type_sizes/coroutine.stdout @@ -8,3 +8,76 @@ print-type-size variant `Returned`: 8192 bytes print-type-size upvar `.array`: 8192 bytes print-type-size variant `Panicked`: 8192 bytes print-type-size upvar `.array`: 8192 bytes +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout index 71a7f3c63815c..30263db5d96b6 100644 --- a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout @@ -1,3 +1,42 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `{coroutine@$DIR/coroutine_discr_placement.rs:12:13: 12:15}`: 8 bytes, alignment: 4 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes @@ -15,3 +54,37 @@ print-type-size type: `std::mem::MaybeUninit`: 4 bytes, alignment: 4 bytes print-type-size variant `MaybeUninit`: 4 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 4 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/generics.stdout b/tests/ui/print_type_sizes/generics.stdout index 0f02f39795365..497e8956fe8d8 100644 --- a/tests/ui/print_type_sizes/generics.stdout +++ b/tests/ui/print_type_sizes/generics.stdout @@ -1,14 +1,87 @@ print-type-size type: `Pair`: 100 bytes, alignment: 1 bytes print-type-size field `._car`: 50 bytes print-type-size field `._cdr`: 50 bytes +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes print-type-size type: `FiftyBytes`: 50 bytes, alignment: 1 bytes print-type-size field `.0`: 50 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes print-type-size type: `Pair`: 14 bytes, alignment: 1 bytes print-type-size field `._car`: 7 bytes print-type-size field `._cdr`: 7 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `SevenBytes`: 7 bytes, alignment: 1 bytes print-type-size field `.0`: 7 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes print-type-size type: `Pair`: 2 bytes, alignment: 1 bytes print-type-size field `._car`: 1 bytes print-type-size field `._cdr`: 1 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes print-type-size type: `ZeroSized`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/multiple_types.stdout b/tests/ui/print_type_sizes/multiple_types.stdout index 6411881545843..b14e0fa12dcaf 100644 --- a/tests/ui/print_type_sizes/multiple_types.stdout +++ b/tests/ui/print_type_sizes/multiple_types.stdout @@ -1,3 +1,11 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes print-type-size type: `Enum`: 51 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Large`: 50 bytes @@ -6,5 +14,70 @@ print-type-size variant `Small`: 7 bytes print-type-size field `.0`: 7 bytes print-type-size type: `FiftyBytes`: 50 bytes, alignment: 1 bytes print-type-size field `.0`: 50 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `SevenBytes`: 7 bytes, alignment: 1 bytes print-type-size field `.0`: 7 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/niche-filling.stdout b/tests/ui/print_type_sizes/niche-filling.stdout index eeb5de5324121..00d78b43cc28e 100644 --- a/tests/ui/print_type_sizes/niche-filling.stdout +++ b/tests/ui/print_type_sizes/niche-filling.stdout @@ -1,3 +1,35 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes print-type-size field `.nested`: 8 bytes print-type-size field `.post`: 2 bytes @@ -34,6 +66,13 @@ print-type-size field `.val`: 4 bytes print-type-size field `.post`: 2 bytes print-type-size field `.pre`: 1 bytes print-type-size end padding: 1 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `Enum4<(), char, (), ()>`: 4 bytes, alignment: 4 bytes print-type-size variant `Two`: 4 bytes print-type-size field `.0`: 4 bytes @@ -76,6 +115,25 @@ print-type-size type: `std::option::Option>`: 4 bytes, al print-type-size variant `Some`: 4 bytes print-type-size field `.0`: 4 bytes print-type-size variant `None`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes print-type-size type: `Enum4<(), (), (), MyOption>`: 2 bytes, alignment: 1 bytes print-type-size variant `Four`: 2 bytes print-type-size field `.0`: 2 bytes @@ -111,8 +169,23 @@ print-type-size type: `MyOption`: 1 bytes, alignment: 1 byte print-type-size variant `Some`: 1 bytes print-type-size field `.0`: 1 bytes print-type-size variant `None`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes print-type-size type: `std::cmp::Ordering`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Less`: 0 bytes print-type-size variant `Equal`: 0 bytes print-type-size variant `Greater`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/no_duplicates.stdout b/tests/ui/print_type_sizes/no_duplicates.stdout index 50180f356ea36..34d9757a19c10 100644 --- a/tests/ui/print_type_sizes/no_duplicates.stdout +++ b/tests/ui/print_type_sizes/no_duplicates.stdout @@ -1,2 +1,75 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `SevenBytes`: 7 bytes, alignment: 1 bytes print-type-size field `.0`: 7 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/packed.stdout b/tests/ui/print_type_sizes/packed.stdout index 58e1bac9eb794..e58666e441077 100644 --- a/tests/ui/print_type_sizes/packed.stdout +++ b/tests/ui/print_type_sizes/packed.stdout @@ -1,3 +1,35 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes print-type-size type: `Packed2C`: 12 bytes, alignment: 2 bytes print-type-size field `.a`: 1 bytes print-type-size field `.b`: 1 bytes @@ -29,3 +61,44 @@ print-type-size field `.a`: 1 bytes print-type-size field `.b`: 1 bytes print-type-size field `.c`: 1 bytes print-type-size field `.d`: 1 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/padding.stdout b/tests/ui/print_type_sizes/padding.stdout index 9afdf76245df7..32f96f8c70cc3 100644 --- a/tests/ui/print_type_sizes/padding.stdout +++ b/tests/ui/print_type_sizes/padding.stdout @@ -1,3 +1,35 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes print-type-size type: `E1`: 12 bytes, alignment: 4 bytes print-type-size discriminant: 1 bytes print-type-size variant `B`: 11 bytes @@ -21,3 +53,44 @@ print-type-size field `.g`: 4 bytes print-type-size field `.a`: 1 bytes print-type-size field `.b`: 1 bytes print-type-size end padding: 2 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/repr-align.stdout b/tests/ui/print_type_sizes/repr-align.stdout index 33671bd8e14bc..66755b81de69d 100644 --- a/tests/ui/print_type_sizes/repr-align.stdout +++ b/tests/ui/print_type_sizes/repr-align.stdout @@ -1,3 +1,15 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes print-type-size type: `E`: 32 bytes, alignment: 16 bytes print-type-size discriminant: 4 bytes print-type-size variant `B`: 28 bytes @@ -11,6 +23,67 @@ print-type-size field `.a`: 4 bytes print-type-size field `.b`: 4 bytes print-type-size field `.d`: 1 bytes print-type-size end padding: 7 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes print-type-size type: `A`: 16 bytes, alignment: 16 bytes print-type-size field `.0`: 4 bytes print-type-size end padding: 12 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/repr_int_c.stdout b/tests/ui/print_type_sizes/repr_int_c.stdout index 254b3c7a8531e..046d9e3d53b3a 100644 --- a/tests/ui/print_type_sizes/repr_int_c.stdout +++ b/tests/ui/print_type_sizes/repr_int_c.stdout @@ -1,3 +1,42 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `ReprCu8`: 4 bytes, alignment: 2 bytes print-type-size discriminant: 1 bytes print-type-size variant `A`: 3 bytes @@ -10,3 +49,37 @@ print-type-size variant `A`: 3 bytes print-type-size padding: 1 bytes print-type-size field `.0`: 2 bytes, alignment: 2 bytes print-type-size variant `B`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/uninhabited.stdout b/tests/ui/print_type_sizes/uninhabited.stdout index 5eb5384bce340..24b32014b8299 100644 --- a/tests/ui/print_type_sizes/uninhabited.stdout +++ b/tests/ui/print_type_sizes/uninhabited.stdout @@ -1,6 +1,79 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `std::result::Result`: 4 bytes, alignment: 4 bytes print-type-size variant `Ok`: 4 bytes print-type-size field `.0`: 4 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes print-type-size type: `std::option::Option`: 0 bytes, alignment: 1 bytes print-type-size variant `None`: 0 bytes print-type-size type: `std::result::Result`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/variants.stdout b/tests/ui/print_type_sizes/variants.stdout index 6411881545843..b14e0fa12dcaf 100644 --- a/tests/ui/print_type_sizes/variants.stdout +++ b/tests/ui/print_type_sizes/variants.stdout @@ -1,3 +1,11 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes print-type-size type: `Enum`: 51 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Large`: 50 bytes @@ -6,5 +14,70 @@ print-type-size variant `Small`: 7 bytes print-type-size field `.0`: 7 bytes print-type-size type: `FiftyBytes`: 50 bytes, alignment: 1 bytes print-type-size field `.0`: 50 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes print-type-size type: `SevenBytes`: 7 bytes, alignment: 1 bytes print-type-size field `.0`: 7 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/print_type_sizes/zero-sized-fields.stdout b/tests/ui/print_type_sizes/zero-sized-fields.stdout index e4d44241e43f6..3f894f2528068 100644 --- a/tests/ui/print_type_sizes/zero-sized-fields.stdout +++ b/tests/ui/print_type_sizes/zero-sized-fields.stdout @@ -1,3 +1,23 @@ +print-type-size type: `std::fmt::Formatter<'_>`: 64 bytes, alignment: 8 bytes +print-type-size field `.width`: 16 bytes +print-type-size field `.precision`: 16 bytes +print-type-size field `.buf`: 16 bytes +print-type-size field `.fill`: 4 bytes +print-type-size field `.flags`: 4 bytes +print-type-size field `.align`: 1 bytes +print-type-size end padding: 7 bytes +print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes +print-type-size field `.pieces`: 16 bytes +print-type-size field `.args`: 16 bytes +print-type-size field `.fmt`: 16 bytes +print-type-size type: `unwind::libunwind::_Unwind_Exception`: 32 bytes, alignment: 8 bytes +print-type-size field `.exception_class`: 8 bytes +print-type-size field `.exception_cleanup`: 8 bytes +print-type-size field `.private`: 16 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes print-type-size type: `S5<(), Empty>`: 16 bytes, alignment: 4 bytes print-type-size field `.w`: 4 bytes print-type-size field `.x`: 4 bytes @@ -8,9 +28,62 @@ print-type-size field `.unit`: 0 bytes print-type-size field `.void`: 0 bytes print-type-size field `.empty`: 0 bytes print-type-size field `.tagz`: 0 bytes +print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes +print-type-size field `.value`: 8 bytes +print-type-size field `.formatter`: 8 bytes +print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::option::Option`: 16 bytes, alignment: 8 bytes +print-type-size discriminant: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes print-type-size type: `S1`: 8 bytes, alignment: 4 bytes print-type-size field `.x`: 4 bytes print-type-size field `.y`: 4 bytes print-type-size field `.tag`: 0 bytes +print-type-size type: `std::option::Option`: 8 bytes, alignment: 8 bytes +print-type-size variant `Some`: 8 bytes +print-type-size field `.0`: 8 bytes +print-type-size variant `None`: 0 bytes +print-type-size type: `std::ptr::DynMetadata`: 8 bytes, alignment: 8 bytes +print-type-size field `.vtable_ptr`: 8 bytes +print-type-size field `.phantom`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Action`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_UA_SEARCH_PHASE`: 0 bytes +print-type-size variant `_UA_CLEANUP_PHASE`: 0 bytes +print-type-size variant `_UA_HANDLER_FRAME`: 0 bytes +print-type-size variant `_UA_FORCE_UNWIND`: 0 bytes +print-type-size variant `_UA_END_OF_STACK`: 0 bytes +print-type-size type: `unwind::libunwind::_Unwind_Reason_Code`: 4 bytes, alignment: 4 bytes +print-type-size discriminant: 4 bytes +print-type-size variant `_URC_NO_REASON`: 0 bytes +print-type-size variant `_URC_FOREIGN_EXCEPTION_CAUGHT`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE2_ERROR`: 0 bytes +print-type-size variant `_URC_FATAL_PHASE1_ERROR`: 0 bytes +print-type-size variant `_URC_NORMAL_STOP`: 0 bytes +print-type-size variant `_URC_END_OF_STACK`: 0 bytes +print-type-size variant `_URC_HANDLER_FOUND`: 0 bytes +print-type-size variant `_URC_INSTALL_CONTEXT`: 0 bytes +print-type-size variant `_URC_CONTINUE_UNWIND`: 0 bytes +print-type-size variant `_URC_FAILURE`: 0 bytes +print-type-size type: `core::fmt::rt::Alignment`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Left`: 0 bytes +print-type-size variant `Right`: 0 bytes +print-type-size variant `Center`: 0 bytes +print-type-size variant `Unknown`: 0 bytes +print-type-size type: `std::result::Result<(), std::fmt::Error>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ok`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Err`: 0 bytes +print-type-size field `.0`: 0 bytes print-type-size type: `Empty`: 0 bytes, alignment: 1 bytes print-type-size type: `Void`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::fmt::Error`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData`: 0 bytes, alignment: 1 bytes +print-type-size type: `unwind::libunwind::_Unwind_Context`: 0 bytes, alignment: 1 bytes