diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 56cfbf138af00..55c24ad67715a 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2416,8 +2416,8 @@ impl LayoutData { /// Checks if these two `Layout` are equal enough to be considered "the same for all function /// call ABIs". Note however that real ABIs depend on more details that are not reflected in the /// `Layout`; the `PassMode` need to be compared as well. Also note that we assume - /// aggregates are passed via `PassMode::Indirect` or `PassMode::Cast`; more strict - /// checks would otherwise be required. + /// aggregates are passed via `PassMode::Indirect`, `PassMode::IndirectUnsized` or + /// `PassMode::Cast`; more strict checks would otherwise be required. pub fn eq_abi(&self, other: &Self) -> bool { // The one thing that we are not capturing here is that for unsized types, the metadata must // also have the same ABI, and moreover that the same metadata leads to the same size. The diff --git a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs index 48ffc43c5cfa1..9a6854399dde6 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs @@ -126,7 +126,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { assert_eq!(pad_i32_count, 0, "padding support not yet implemented"); cast_target_to_abi_params(cast).into_iter().map(|(_, param)| param).collect() } - PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => { + PassMode::Indirect { attrs, address_space: _, mode } => { assert!( mode != IndirectMode::AmdgpuKernelArg, "unsupported amdgpu kernel argument" @@ -143,8 +143,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { smallvec![apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)] } } - PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), address_space: _, mode } => { - assert!(mode == IndirectMode::Pointer); + PassMode::IndirectUnsized { attrs, meta_attrs } => { smallvec![ apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs), apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs), @@ -188,7 +187,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { None, cast_target_to_abi_params(cast).into_iter().map(|(_, param)| param).collect(), ), - PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => { + PassMode::Indirect { attrs, address_space: _, mode } => { assert!(mode == IndirectMode::Pointer); ( Some(apply_attrs_to_abi_param( @@ -198,7 +197,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { vec![], ) } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { unreachable!("unsized return value") } } @@ -268,7 +267,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( smallvec![a, b] } PassMode::Cast { ref cast, .. } => to_casted_value(fx, arg, cast), - PassMode::Indirect { .. } => { + PassMode::Indirect { .. } | PassMode::IndirectUnsized { .. } => { if is_owned { match arg.force_stack(fx) { (ptr, None) => smallvec![ptr.get_addr(fx)], @@ -328,7 +327,7 @@ pub(super) fn cvalue_for_param<'tcx>( PassMode::Cast { ref cast, .. } => { from_casted_value(fx, &block_params, arg_abi.layout, cast) } - PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Indirect { attrs, address_space: _, mode: _ } => { assert_eq!(block_params.len(), 1, "{:?}", block_params); if let Some(pointee_align) = attrs.pointee_align && pointee_align < arg_abi.layout.align.abi @@ -346,7 +345,7 @@ pub(super) fn cvalue_for_param<'tcx>( CValue::by_ref(Pointer::new(block_params[0]), arg_abi.layout) } } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { assert_eq!(block_params.len(), 2, "{:?}", block_params); CValue::by_ref_unsized(Pointer::new(block_params[0]), block_params[1], arg_abi.layout) } diff --git a/compiler/rustc_codegen_cranelift/src/abi/returning.rs b/compiler/rustc_codegen_cranelift/src/abi/returning.rs index 7f4ee9435b506..e2b028e1be4a8 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/returning.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/returning.rs @@ -17,12 +17,12 @@ pub(super) fn codegen_return_param<'tcx>( let is_ssa = ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.ret.layout.ty); (super::make_local_place(fx, RETURN_PLACE, fx.fn_abi.ret.layout, is_ssa), smallvec![]) } - PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Indirect { attrs: _, address_space: _, mode: _ } => { let ret_param = block_params_iter.next().unwrap(); assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type); (CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.ret.layout), smallvec![ret_param]) } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { unreachable!("unsized return value") } }; @@ -50,7 +50,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>( ) { let (ret_temp_place, return_ptr) = match ret_arg_abi.mode { PassMode::Ignore => (None, None), - PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Indirect { attrs: _, address_space: _, mode: _ } => { if let Some(ret_ptr) = ret_place.try_to_ptr() { // This is an optimization to prevent unnecessary copies of the return value when // the return place is already a memory place as opposed to a register. @@ -61,7 +61,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>( (Some(place), Some(place.to_ptr().get_addr(fx))) } } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { unreachable!("unsized return value") } PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => (None, None), @@ -86,14 +86,14 @@ pub(super) fn codegen_with_call_return_arg<'tcx>( super::pass_mode::from_casted_value(fx, &results, ret_place.layout(), cast); ret_place.write_cvalue(fx, result); } - PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Indirect { attrs: _, address_space: _, mode: _ } => { if let Some(ret_temp_place) = ret_temp_place { // If ret_temp_place is None, it is not necessary to copy the return value. let ret_temp_value = ret_temp_place.to_cvalue(fx); ret_place.write_cvalue(fx, ret_temp_value); } } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { unreachable!("unsized return value") } } @@ -102,11 +102,10 @@ pub(super) fn codegen_with_call_return_arg<'tcx>( /// Codegen a return instruction with the right return value(s) if any. pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) { match fx.fn_abi.ret.mode { - PassMode::Ignore - | PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Ignore | PassMode::Indirect { attrs: _, address_space: _, mode: _ } => { fx.bcx.ins().return_(&[]); } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { unreachable!("unsized return value") } PassMode::Direct(_) => { diff --git a/compiler/rustc_codegen_gcc/src/abi.rs b/compiler/rustc_codegen_gcc/src/abi.rs index 5b88cebb4f174..fff25128260c6 100644 --- a/compiler/rustc_codegen_gcc/src/abi.rs +++ b/compiler/rustc_codegen_gcc/src/abi.rs @@ -131,6 +131,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { argument_tys.push(cx.type_ptr_to(self.ret.layout.gcc_type(cx))); cx.type_void() } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), }; #[cfg(feature = "master")] let mut non_null_args = Vec::new(); @@ -189,12 +190,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { let ty = cast.gcc_type(cx); apply_attrs(ty, &cast.attrs, argument_tys.len()) } - PassMode::Indirect { - attrs: _, - meta_attrs: None, - address_space: _, - mode: IndirectMode::OnStack, - } => { + PassMode::Indirect { attrs: _, address_space: _, mode: IndirectMode::OnStack } => { let x86_interrupt_first_arg = { #[cfg(feature = "master")] { @@ -223,7 +219,6 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { } PassMode::Indirect { attrs: _, - meta_attrs: None, address_space: _, mode: IndirectMode::AmdgpuKernelArg, } => { @@ -232,21 +227,10 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { PassMode::Direct(attrs) => { apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs, argument_tys.len()) } - PassMode::Indirect { - attrs, - meta_attrs: None, - address_space: _, - mode: IndirectMode::Pointer, - } => { + PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::Pointer } => { apply_attrs(cx.type_ptr_to(arg.layout.gcc_type(cx)), &attrs, argument_tys.len()) } - PassMode::Indirect { - attrs, - meta_attrs: Some(meta_attrs), - address_space: _, - mode, - } => { - assert!(mode == IndirectMode::Pointer); + PassMode::IndirectUnsized { attrs, meta_attrs } => { // Construct the type of a (wide) pointer to `ty`, and pass its two fields. // Any two ABI-compatible unsized types have the same metadata type and // moreover the same metadata value leads to the same dynamic size and diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 4d2590ac81e41..c271461b26ba2 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -841,12 +841,10 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { PassMode::Pair(..) => { OperandValue::Pair(next(), next()).store(bx, dst); } - PassMode::Indirect { meta_attrs: Some(_), .. } => { + PassMode::IndirectUnsized { .. } => { bug!("unsized `ArgAbi` cannot be stored"); } - PassMode::Direct(_) - | PassMode::Indirect { meta_attrs: None, .. } - | PassMode::Cast { .. } => { + PassMode::Direct(_) | PassMode::Indirect { .. } | PassMode::Cast { .. } => { let next_arg = next(); self.store(bx, next_arg, dst); } diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index e16f34483a0c5..84e868c58ac46 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -243,12 +243,12 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { match &self.mode { PassMode::Ignore => {} // Sized indirect arguments - PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Indirect { attrs, address_space: _, mode: _ } => { let align = attrs.pointee_align.unwrap_or(self.layout.align.abi); OperandValue::Ref(PlaceValue::new_sized(val, align)).store(bx, dst); } // Unsized indirect arguments cannot be stored - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { bug!("unsized `ArgAbi` cannot be stored"); } PassMode::Cast { cast, pad_i32_count: _ } => { @@ -304,11 +304,11 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { PassMode::Pair(..) => { OperandValue::Pair(next(), next()).store(bx, dst); } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { bug!("unsized `ArgAbi` cannot be stored"); } PassMode::Direct(_) - | PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } + | PassMode::Indirect { attrs: _, address_space: _, mode: _ } | PassMode::Cast { .. } => { let next_arg = next(); self.store(bx, next_arg, dst); @@ -378,6 +378,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { llargument_tys.push(ty); cx.type_void() } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), }; for arg in args { @@ -400,7 +401,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { llargument_tys.push(arg.layout.scalar_pair_element_llvm_type(cx, 1, true)); continue; } - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { // Construct the type of a (wide) pointer to `ty`, and pass its two fields. // Any two ABI-compatible unsized types have the same metadata type and // moreover the same metadata value leads to the same dynamic size and @@ -411,7 +412,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { llargument_tys.push(ptr_layout.scalar_pair_element_llvm_type(cx, 1, true)); continue; } - PassMode::Indirect { attrs: _, meta_attrs: None, address_space, mode: _ } => { + PassMode::Indirect { attrs: _, address_space, mode: _ } => { if let Some(address_space) = address_space { cx.type_ptr_ext(*address_space) } else { @@ -507,7 +508,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { apply_range_attr(llvm::AttributePlace::ReturnValue, scalar); } } - PassMode::Indirect { attrs, meta_attrs: _, address_space: _, mode } => { + PassMode::Indirect { attrs, address_space: _, mode } => { assert!(*mode == IndirectMode::Pointer); let i = apply(attrs); let sret = llvm::CreateStructRetAttr( @@ -526,6 +527,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { ); } } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), PassMode::Cast { cast, pad_i32_count: _ } => { cast.attrs.apply_attrs_to_llfn(llvm::AttributePlace::ReturnValue, cx, llfn); } @@ -534,12 +536,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { for arg in self.args.iter() { match &arg.mode { PassMode::Ignore => {} - PassMode::Indirect { - attrs, - meta_attrs: None, - address_space: _, - mode: IndirectMode::OnStack, - } => { + PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::OnStack } => { let i = apply(attrs); let byval = llvm::CreateByValAttr( cx.llcx, @@ -549,7 +546,6 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { } PassMode::Indirect { attrs, - meta_attrs: None, address_space: _, mode: IndirectMode::AmdgpuKernelArg, } => { @@ -566,12 +562,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { apply_range_attr(llvm::AttributePlace::Argument(i), scalar); } } - PassMode::Indirect { - attrs, - meta_attrs: None, - address_space: _, - mode: IndirectMode::Pointer, - } => { + PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::Pointer } => { let i = apply(attrs); if cx.sess().opts.optimize != config::OptLevel::No { attributes::apply_to_llfn( @@ -581,13 +572,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { ); } } - PassMode::Indirect { - attrs, - meta_attrs: Some(meta_attrs), - address_space: _, - mode, - } => { - assert!(*mode == IndirectMode::Pointer); + PassMode::IndirectUnsized { attrs, meta_attrs } => { apply(attrs); apply(meta_attrs); } @@ -665,7 +650,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { PassMode::Direct(attrs) => { attrs.apply_attrs_to_callsite(llvm::AttributePlace::ReturnValue, bx.cx, callsite); } - PassMode::Indirect { attrs, meta_attrs: _, address_space: _, mode } => { + PassMode::Indirect { attrs, address_space: _, mode } => { assert!(*mode == IndirectMode::Pointer); let i = apply(bx.cx, attrs); let sret = llvm::CreateStructRetAttr( @@ -674,6 +659,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { ); attributes::apply_to_callsite(callsite, llvm::AttributePlace::Argument(i), &[sret]); } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), PassMode::Cast { cast, pad_i32_count: _ } => { cast.attrs.apply_attrs_to_callsite( llvm::AttributePlace::ReturnValue, @@ -686,12 +672,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { for arg in self.args.iter() { match &arg.mode { PassMode::Ignore => {} - PassMode::Indirect { - attrs, - meta_attrs: None, - address_space: _, - mode: IndirectMode::OnStack, - } => { + PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::OnStack } => { let i = apply(bx.cx, attrs); let byval = llvm::CreateByValAttr( bx.cx.llcx, @@ -705,7 +686,6 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { } PassMode::Indirect { attrs, - meta_attrs: None, address_space: _, mode: IndirectMode::AmdgpuKernelArg, } => { @@ -721,20 +701,10 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { ); } PassMode::Direct(attrs) - | PassMode::Indirect { - attrs, - meta_attrs: None, - address_space: _, - mode: IndirectMode::Pointer, - } => { + | PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::Pointer } => { apply(bx.cx, attrs); } - PassMode::Indirect { - attrs, - meta_attrs: Some(meta_attrs), - address_space: _, - mode: _, - } => { + PassMode::IndirectUnsized { attrs, meta_attrs } => { apply(bx.cx, attrs); apply(bx.cx, meta_attrs); } diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index abc71f450a515..b677fb4ccdee9 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -24,7 +24,7 @@ use rustc_middle::ty::layout::{ use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_sanitizers::{cfi, kcfi}; use rustc_session::config::OptLevel; -use rustc_span::Span; +use rustc_span::{Span, bug}; use rustc_target::callconv::{FnAbi, PassMode}; use rustc_target::spec::{Arch, HasTargetSpec, SanitizerSet, Target}; use smallvec::SmallVec; @@ -1555,6 +1555,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { match &fn_abi.ret.mode { PassMode::Ignore | PassMode::Indirect { .. } => self.ret_void(), PassMode::Direct(_) | PassMode::Pair { .. } | PassMode::Cast { .. } => self.ret(call), + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), } } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 454347a5e041e..2fc06f9c0860f 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -2043,6 +2043,9 @@ fn get_args_from_tuple<'ll, 'tcx>( result.push(field.val.llval); tuple_index += 1; } + PassMode::IndirectUnsized { .. } => { + bug!("autodiff/offload args must not be unsized"); + } } } diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index a25624550e3ad..946197c1ec663 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -222,6 +222,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { PassMode::Direct(_) | PassMode::Pair { .. } | PassMode::Cast { .. } => { start_bx.ret(call) } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), } } } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index f99009a0f4243..916b827f8bf4a 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -644,6 +644,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { load_cast(bx, cast_ty, llslot, self.fn_abi.ret.layout.align.abi) } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), }; bx.ret(llval); } @@ -1285,6 +1286,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // Copy the arguments that use `PassMode::Indirect { mode: IndirectMode::Pointer , ..}` // to temporary stack allocations. See the comment above. for (i, arg) in first_args.iter().enumerate() { + if matches!(fn_abi.args[i].mode, PassMode::IndirectUnsized { .. }) { + bug!("extern \"tail\" arguments must not be unsized"); + } + if !matches!( fn_abi.args[i].mode, PassMode::Indirect { mode: IndirectMode::Pointer, .. } @@ -1981,16 +1986,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } _ => bug!("codegen_argument: {:?} invalid for pair argument", op), }, - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { - match op.val { - Ref(PlaceValue { llval: a, llextra: Some(b), .. }) => { - llargs.push(a); - llargs.push(b); - return; - } - _ => bug!("codegen_argument: {:?} invalid for unsized indirect argument", op), + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => match op.val { + Ref(PlaceValue { llval: a, llextra: Some(b), .. }) => { + llargs.push(a); + llargs.push(b); + return; } - } + _ => bug!("codegen_argument: {:?} invalid for unsized indirect argument", op), + }, _ => {} } @@ -2017,7 +2020,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { (scratch.val.llval, scratch.val.align, true) } PassMode::Direct(_) => (op.immediate(), arg.layout.align.abi, false), - PassMode::Ignore | PassMode::Pair(..) => unreachable!("handled above"), + PassMode::Ignore | PassMode::Pair(..) | PassMode::IndirectUnsized { .. } => { + unreachable!("handled above") + } }, Ref(op_place_val) => match arg.mode { PassMode::Indirect { attrs, mode, .. } => { @@ -2044,6 +2049,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { (op_place_val.llval, op_place_val.align, true) } } + PassMode::IndirectUnsized { .. } => unreachable!("handled above"), _ => (op_place_val.llval, op_place_val.align, true), }, ZeroSized => match arg.mode { diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index aefa8356536dc..4f332f1f7b34e 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -336,6 +336,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let size = cast.size(&start_bx).max(layout.size); return LocalRef::Place(PlaceRef::alloca_size(&mut start_bx, size, layout)); } + PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"), _ => {} }; } @@ -561,7 +562,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( match arg.mode { // Sized indirect arguments - PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => { + PassMode::Indirect { attrs, address_space: _, mode } => { // Don't copy an indirect argument to an alloca, the caller already put it // in a temporary alloca and gave it up. // AmdgpuKernelArg/byref arguments must not be modified, so always create a @@ -586,7 +587,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( } } // Unsized indirect arguments - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => { + PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { // As the storage for the indirect argument lives during // the whole function call, we just copy the wide pointer. let llarg = bx.get_param(llarg_idx); diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index 3162463d222ee..7dcb0774a9056 100644 --- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs +++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs @@ -497,6 +497,7 @@ fn wasm_type<'tcx>(signature: &mut String, arg_abi: &ArgAbi<'_, Ty<'tcx>>, ptr_t signature.push_str(wrapped_wasm_type); } PassMode::Indirect { .. } => signature.push_str(ptr_type), + PassMode::IndirectUnsized { .. } => bug!("unsized argument to naked asm"), } } diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index 8fc069d76e9f5..bfd4caa068ac5 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -24,7 +24,9 @@ enum UsesVectorRegisters { /// scalable vector registers or no vector registers. fn passes_vectors_by_value(mode: &PassMode, repr: &BackendRepr) -> UsesVectorRegisters { match mode { - PassMode::Ignore | PassMode::Indirect { .. } => UsesVectorRegisters::No, + PassMode::Ignore | PassMode::Indirect { .. } | PassMode::IndirectUnsized { .. } => { + UsesVectorRegisters::No + } PassMode::Cast { pad_i32_count: _, cast } if cast.prefix.iter().any(|x| matches!(x.kind, RegKind::Vector { .. })) || matches!(cast.rest.unit.kind, RegKind::Vector { .. }) => diff --git a/compiler/rustc_public/src/abi.rs b/compiler/rustc_public/src/abi.rs index 72387fce19797..76790340ec1a0 100644 --- a/compiler/rustc_public/src/abi.rs +++ b/compiler/rustc_public/src/abi.rs @@ -86,14 +86,17 @@ pub enum PassMode { Cast { pad_i32_count: u8, cast: CastTarget }, /// Pass the argument indirectly via a pointer. /// + /// The caller places the value in memory and depending on mode passes a + /// pointer to it, stores it at a fixed stack offset or stores it at a + /// fixed location in a different address space. + Indirect { attrs: ArgAttributes, address_space: Option, mode: IndirectMode }, + /// Pass the unsized argument indirectly via a hidden pointer. + /// /// The caller places the value in memory and passes a pointer to it. - Indirect { + IndirectUnsized { attrs: ArgAttributes, /// Attributes for the metadata pointer (vtable or length) of unsized arguments. - /// Only present for unsized types (e.g., `dyn Trait`, `[T]`). - meta_attrs: Option, - address_space: Option, - mode: IndirectMode, + meta_attrs: ArgAttributes, }, } diff --git a/compiler/rustc_public/src/unstable/convert/stable/abi.rs b/compiler/rustc_public/src/unstable/convert/stable/abi.rs index 1ac0b706ed091..8d8e33eb674b1 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/abi.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/abi.rs @@ -188,12 +188,15 @@ impl<'tcx> Stable<'tcx> for callconv::PassMode { callconv::PassMode::Cast { pad_i32_count, cast } => { PassMode::Cast { pad_i32_count: *pad_i32_count, cast: cast.stable(tables, cx) } } - callconv::PassMode::Indirect { attrs, meta_attrs, address_space, mode } => { - PassMode::Indirect { + callconv::PassMode::Indirect { attrs, address_space, mode } => PassMode::Indirect { + attrs: attrs.stable(tables, cx), + address_space: address_space.stable(tables, cx), + mode: mode.stable(tables, cx), + }, + callconv::PassMode::IndirectUnsized { attrs, meta_attrs } => { + PassMode::IndirectUnsized { attrs: attrs.stable(tables, cx), - meta_attrs: meta_attrs.map(|a| a.stable(tables, cx)), - address_space: address_space.stable(tables, cx), - mode: mode.stable(tables, cx), + meta_attrs: meta_attrs.stable(tables, cx), } } } diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index edc23b6c50b45..332db35d04649 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -79,20 +79,16 @@ pub enum PassMode { Cast { pad_i32_count: u8, cast: Box }, /// Pass the argument indirectly via a hidden pointer. /// - /// The `meta_attrs` value, if any, is for the metadata (vtable or length) of an unsized - /// argument. (This is the only mode that supports unsized arguments.) - /// /// `address_space` specifies if the pointer is in a special address space or the default one. /// /// `mode` can be a special way to pass an argument indirectly. - /// `OnStack` and `AmdgpuKernelArg` cannot be used for unsized arguments, i.e., when - /// `meta_attrs` is `Some`. - Indirect { - attrs: ArgAttributes, - meta_attrs: Option, - address_space: Option, - mode: IndirectMode, - }, + Indirect { attrs: ArgAttributes, address_space: Option, mode: IndirectMode }, + + /// Like `Indirect`, but for unsized parameters. + /// + /// The `meta_attrs` value, is for the metadata (vtable or length) of an unsized argument. + /// (This is the only mode that supports unsized arguments.) `on_stack` is always false. + IndirectUnsized { attrs: ArgAttributes, meta_attrs: ArgAttributes }, } impl PassMode { @@ -109,23 +105,13 @@ impl PassMode { PassMode::Cast { cast: c2, pad_i32_count: pad2 }, ) => c1.eq_abi(c2) && pad1 == pad2, ( - PassMode::Indirect { attrs: a1, meta_attrs: None, address_space: as1, mode: m1 }, - PassMode::Indirect { attrs: a2, meta_attrs: None, address_space: as2, mode: m2 }, + PassMode::Indirect { attrs: a1, address_space: as1, mode: m1 }, + PassMode::Indirect { attrs: a2, address_space: as2, mode: m2 }, ) => a1.eq_abi(a2) && as1 == as2 && m1 == m2, ( - PassMode::Indirect { - attrs: a1, - meta_attrs: Some(e1), - address_space: as1, - mode: m1, - }, - PassMode::Indirect { - attrs: a2, - meta_attrs: Some(e2), - address_space: as2, - mode: m2, - }, - ) => a1.eq_abi(a2) && as1 == as2 && e1.eq_abi(e2) && m1 == m2, + PassMode::IndirectUnsized { attrs: a1, meta_attrs: e1 }, + PassMode::IndirectUnsized { attrs: a2, meta_attrs: e2 }, + ) => a1.eq_abi(a2) && e1.eq_abi(e2), _ => false, } } @@ -452,9 +438,11 @@ impl<'a, Ty> ArgAbi<'a, Ty> { attrs.pointee_size = layout.size; attrs.pointee_align = Some(layout.align.abi); - let meta_attrs = layout.is_unsized().then_some(ArgAttributes::new()); - - PassMode::Indirect { attrs, meta_attrs, address_space: None, mode: IndirectMode::Pointer } + if layout.is_unsized() { + PassMode::IndirectUnsized { attrs, meta_attrs: ArgAttributes::new() } + } else { + PassMode::Indirect { attrs, address_space: None, mode: IndirectMode::Pointer } + } } /// Pass this argument indirectly, by passing a (thin or wide) pointer to the argument instead. @@ -465,12 +453,8 @@ impl<'a, Ty> ArgAbi<'a, Ty> { PassMode::Direct(_) | PassMode::Pair(_, _) => { self.mode = Self::indirect_pass_mode(&self.layout); } - PassMode::Indirect { - attrs: _, - meta_attrs: _, - address_space: _, - mode: IndirectMode::Pointer, - } => { + PassMode::Indirect { attrs: _, address_space: _, mode: IndirectMode::Pointer } + | PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { // already indirect } _ => panic!("Tried to make {:?} indirect", self.mode), @@ -498,12 +482,8 @@ impl<'a, Ty> ArgAbi<'a, Ty> { PassMode::Ignore => { self.mode = Self::indirect_pass_mode(&self.layout); } - PassMode::Indirect { - attrs: _, - meta_attrs: _, - address_space: _, - mode: IndirectMode::Pointer, - } => { + PassMode::Indirect { attrs: _, address_space: _, mode: IndirectMode::Pointer } + | PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => { // already indirect } _ => panic!("Tried to make {:?} indirect (expected `PassMode::Ignore`)", self.mode), @@ -530,7 +510,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { assert!(!self.layout.is_unsized(), "used byval ABI for unsized layout"); self.make_indirect(); match self.mode { - PassMode::Indirect { ref mut attrs, meta_attrs: _, address_space: _, ref mut mode } => { + PassMode::Indirect { ref mut attrs, address_space: _, ref mut mode } => { *mode = IndirectMode::OnStack; // Some platforms, like 32-bit x86, change the alignment of the type when passing @@ -553,7 +533,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { assert!(!self.layout.is_unsized(), "used amdgpu kernel arg ABI for unsized layout"); self.make_indirect(); match self.mode { - PassMode::Indirect { attrs: _, meta_attrs: _, ref mut address_space, ref mut mode } => { + PassMode::Indirect { attrs: _, ref mut address_space, ref mut mode } => { *mode = IndirectMode::AmdgpuKernelArg; *address_space = addrspace; } @@ -610,21 +590,15 @@ impl<'a, Ty> ArgAbi<'a, Ty> { } pub fn is_indirect(&self) -> bool { - matches!(self.mode, PassMode::Indirect { .. }) + matches!(self.mode, PassMode::Indirect { .. } | PassMode::IndirectUnsized { .. }) } pub fn is_sized_indirect(&self) -> bool { - matches!( - self.mode, - PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } - ) + matches!(self.mode, PassMode::Indirect { attrs: _, address_space: _, mode: _ }) } pub fn is_unsized_indirect(&self) -> bool { - matches!( - self.mode, - PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } - ) + matches!(self.mode, PassMode::IndirectUnsized { attrs: _, meta_attrs: _ }) } pub fn is_ignore(&self) -> bool { @@ -925,8 +899,11 @@ impl<'a, Ty> FnAbi<'a, Ty> { BackendRepr::Memory { .. } => { // Compute `Aggregate` ABI. - let is_indirect_not_on_stack = - matches!(arg.mode, PassMode::Indirect { mode: IndirectMode::Pointer, .. }); + let is_indirect_not_on_stack = matches!( + arg.mode, + PassMode::Indirect { mode: IndirectMode::Pointer, .. } + | PassMode::IndirectUnsized { .. } + ); assert!(is_indirect_not_on_stack); let size = arg.layout.size; @@ -1037,7 +1014,7 @@ mod size_asserts { use super::*; // tidy-alphabetical-start - static_assert_size!(ArgAbi<'_, usize>, 64); - static_assert_size!(FnAbi<'_, usize>, 88); + static_assert_size!(ArgAbi<'_, usize>, 56); + static_assert_size!(FnAbi<'_, usize>, 80); // tidy-alphabetical-end } diff --git a/compiler/rustc_target/src/callconv/nvptx64.rs b/compiler/rustc_target/src/callconv/nvptx64.rs index 3919b7a69a78b..32ed6c0342e2d 100644 --- a/compiler/rustc_target/src/callconv/nvptx64.rs +++ b/compiler/rustc_target/src/callconv/nvptx64.rs @@ -58,7 +58,7 @@ where match arg.mode { super::PassMode::Ignore | super::PassMode::Direct(_) => return, super::PassMode::Pair(_, _) => {} - super::PassMode::Cast { .. } => unreachable!(), + super::PassMode::Cast { .. } | super::PassMode::IndirectUnsized { .. } => unreachable!(), super::PassMode::Indirect { .. } => {} } diff --git a/compiler/rustc_target/src/callconv/x86.rs b/compiler/rustc_target/src/callconv/x86.rs index 3476f41e3bc75..78a5a22620aec 100644 --- a/compiler/rustc_target/src/callconv/x86.rs +++ b/compiler/rustc_target/src/callconv/x86.rs @@ -200,13 +200,12 @@ pub(crate) fn fill_inregs<'a, Ty, C>( for arg in fn_abi.args.iter_mut() { let attrs = match arg.mode { - PassMode::Ignore - | PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => { + PassMode::Ignore | PassMode::Indirect { attrs: _, address_space: _, mode: _ } => { continue; } PassMode::Direct(ref mut attrs) => attrs, PassMode::Pair(..) - | PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } + | PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } | PassMode::Cast { .. } => { unreachable!("x86 shouldn't be passing arguments by {:?}", arg.mode) } diff --git a/compiler/rustc_target/src/callconv/xtensa.rs b/compiler/rustc_target/src/callconv/xtensa.rs index 49005adeb33c0..f3c74cec804bf 100644 --- a/compiler/rustc_target/src/callconv/xtensa.rs +++ b/compiler/rustc_target/src/callconv/xtensa.rs @@ -29,9 +29,10 @@ where classify_arg_ty(cx, arg, &mut arg_gprs_left, true); // Ret args cannot be passed via stack, we lower to indirect and let the backend handle the invisible reference match arg.mode { - super::PassMode::Indirect { attrs: _, meta_attrs: _, address_space: _, ref mut mode } => { + super::PassMode::Indirect { attrs: _, address_space: _, ref mut mode } => { *mode = IndirectMode::Pointer; } + super::PassMode::IndirectUnsized { .. } => panic!("unsized returns are not supported"), _ => {} } } diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 448167ff90874..0f7771cb78b0b 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -500,7 +500,7 @@ fn fn_abi_sanity_check<'tcx>( // `Cast` means "transmute to `CastType`"; that only makes sense for sized types. assert!(arg.layout.is_sized()); } - PassMode::Indirect { meta_attrs: None, attrs, .. } => { + PassMode::Indirect { attrs, .. } => { // No metadata, must be sized. // Conceptually, unsized arguments must be copied around, which requires dynamically // determining their size, which we cannot do without metadata. Consult @@ -509,9 +509,11 @@ fn fn_abi_sanity_check<'tcx>( // Indirect returns are arguments from an ABI perspective. fn_arg_attrs_sanity_check(attrs, false); } - PassMode::Indirect { meta_attrs: Some(meta_attrs), attrs, address_space: _, mode } => { - // With metadata. Must be unsized and not on the stack. - assert!(arg.layout.is_unsized() && *mode == IndirectMode::Pointer); + PassMode::IndirectUnsized { attrs, meta_attrs } => { + // With metadata. Must be unsized. + assert!(arg.layout.is_unsized()); + // And must not be a return value + assert!(!is_ret); // Also, must not be `extern` type. let tail = tcx.struct_tail_for_codegen(arg.layout.ty, cx.typing_env); if matches!(tail.kind(), ty::Foreign(..)) { diff --git a/tests/ui-fulldeps/rustc_public/check_abi.rs b/tests/ui-fulldeps/rustc_public/check_abi.rs index 92d6f28f8fd8c..6c99265c468ac 100644 --- a/tests/ui-fulldeps/rustc_public/check_abi.rs +++ b/tests/ui-fulldeps/rustc_public/check_abi.rs @@ -14,6 +14,12 @@ extern crate rustc_middle; #[macro_use] extern crate rustc_public; +use std::assert_matches; +use std::collections::HashSet; +use std::convert::TryFrom; +use std::io::Write; +use std::ops::ControlFlow; + use rustc_public::abi::{ ArgAbi, ArgExtension, CallConvention, FieldsShape, IndirectMode, IntegerLength, PassMode, Primitive, Scalar, ValueRepr, VariantsShape, @@ -23,11 +29,6 @@ use rustc_public::mir::mono::Instance; use rustc_public::target::MachineInfo; use rustc_public::ty::{AdtDef, RigidTy, Ty, TyKind}; use rustc_public::{CrateDef, CrateItem, CrateItems, ItemKind}; -use std::assert_matches; -use std::collections::HashSet; -use std::convert::TryFrom; -use std::io::Write; -use std::ops::ControlFlow; const CRATE_NAME: &str = "input"; @@ -127,13 +128,11 @@ fn check_primitive(abi: &ArgAbi) { /// Check the return value: `Result`. fn check_result(abi: &ArgAbi) { assert!(abi.ty.kind().is_enum()); - let PassMode::Indirect { ref attrs, ref meta_attrs, address_space: _, mode } = abi.mode else { + let PassMode::Indirect { ref attrs, address_space: _, mode } = abi.mode else { panic!("Expected PassMode::Indirect for Result, got: {:?}", abi.mode); }; // Indirect arguments have a pointee alignment (the pointer must be aligned). assert!(attrs.pointee_align().is_some()); - // Result is a sized type, so no metadata pointer. - assert!(meta_attrs.is_none()); assert!(mode == IndirectMode::Pointer); let layout = abi.layout.shape(); assert!(layout.is_sized()); diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr index e5cad2199491b..0c7a6b664526d 100644 --- a/tests/ui/abi/c-zst.powerpc-linux.stderr +++ b/tests/ui/abi/c-zst.powerpc-linux.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(pass_zst) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr index e5cad2199491b..0c7a6b664526d 100644 --- a/tests/ui/abi/c-zst.s390x-linux.stderr +++ b/tests/ui/abi/c-zst.s390x-linux.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(pass_zst) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/abi/c-zst.sparc-linux.stderr b/tests/ui/abi/c-zst.sparc-linux.stderr index e5cad2199491b..0c7a6b664526d 100644 --- a/tests/ui/abi/c-zst.sparc-linux.stderr +++ b/tests/ui/abi/c-zst.sparc-linux.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(pass_zst) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/abi/c-zst.sparc-none.stderr b/tests/ui/abi/c-zst.sparc-none.stderr index e5cad2199491b..0c7a6b664526d 100644 --- a/tests/ui/abi/c-zst.sparc-none.stderr +++ b/tests/ui/abi/c-zst.sparc-none.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(pass_zst) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr index e5cad2199491b..0c7a6b664526d 100644 --- a/tests/ui/abi/c-zst.sparc64-linux.stderr +++ b/tests/ui/abi/c-zst.sparc64-linux.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(pass_zst) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr index e5cad2199491b..0c7a6b664526d 100644 --- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr +++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(pass_zst) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index c0a124208b21e..666910789dfb7 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -167,6 +167,18 @@ macro_rules! test_abi_compatible { type TestC = (extern "C" fn($t1) -> $t1, extern "C" fn($t2) -> $t2); } }; + ($name:ident, $t1:ty, $t2:ty, unsized) => { + mod $name { + use super::*; + // Declaring a `type` doesn't even check well-formedness, so we also declare a function. + fn check_wf(_x: $t1, _y: $t2) {} + // Test argument only in case of unsized types, `Rust` and `C` ABIs. + #[rustc_abi(assert_eq)] + type TestRust = (fn($t1), fn($t2)); + #[rustc_abi(assert_eq)] + type TestC = (extern "C" fn($t1), extern "C" fn($t2)); + } + }; } struct Zst; @@ -296,8 +308,8 @@ macro_rules! test_transparent_unsized { ($name:ident, $t:ty) => { mod $name { use super::*; - test_abi_compatible!(wrap1, $t, TransparentWrapper1<$t>); - test_abi_compatible!(wrap2, $t, TransparentWrapper2<$t>); + test_abi_compatible!(wrap1, $t, TransparentWrapper1<$t>, unsized); + test_abi_compatible!(wrap2, $t, TransparentWrapper2<$t>, unsized); } }; } diff --git a/tests/ui/abi/debug.generic.stderr b/tests/ui/abi/debug.generic.stderr index 1793674fa462a..fd72327d42fd7 100644 --- a/tests/ui/abi/debug.generic.stderr +++ b/tests/ui/abi/debug.generic.stderr @@ -1,5 +1,5 @@ error: the `rustc_abi` attribute cannot be used on constants - --> $DIR/debug.rs:42:3 + --> $DIR/debug.rs:48:3 | LL | #[rustc_abi(debug)] | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[rustc_abi(debug)] = help: the `rustc_abi` attribute can be applied to functions and type aliases error: the `rustc_abi` attribute cannot be used on associated consts - --> $DIR/debug.rs:46:7 + --> $DIR/debug.rs:52:7 | LL | #[rustc_abi(debug)] | ^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[rustc_abi(debug)] = help: the `rustc_abi` attribute can be applied to functions and type aliases error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/debug.rs:74:3 + --> $DIR/debug.rs:80:3 | LL | #[rustc_abi("assert_eq")] | ^^^^^^^^^------------- @@ -112,6 +112,98 @@ error: fn_abi_of(test) = FnAbi { LL | fn test(_x: u8) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^ +error: fn_abi_of(test_unsized) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: [u8], + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: false, + }, + fields: Array { + stride: Size(1 bytes), + count: 0, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: IndirectUnsized { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: Some( + Align(1 bytes), + ), + }, + meta_attrs: ArgAttributes { + regular: , + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: bool, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + u8 is 0..=1, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: u8, + valid_range: 0..=1, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:37:1 + | +LL | fn test_unsized(_x: [u8]) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: fn_abi_of(TestFnPtr) = FnAbi { args: [ ArgAbi { @@ -188,7 +280,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:37:1 + --> $DIR/debug.rs:43:1 | LL | type TestFnPtr = fn(bool) -> u8; | ^^^^^^^^^^^^^^ @@ -259,13 +351,13 @@ error: fn_abi_of(test_generic) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:40:1 + --> $DIR/debug.rs:46:1 | LL | fn test_generic(_x: *const T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:43:1 + --> $DIR/debug.rs:49:1 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -403,7 +495,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:59:1 + --> $DIR/debug.rs:65:1 | LL | type TestAbiNe = (fn(u8), fn(u32)); | ^^^^^^^^^^^^^^ @@ -445,7 +537,6 @@ error: ABIs are not compatible Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -519,7 +610,6 @@ error: ABIs are not compatible Align(4 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -557,7 +647,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:62:1 + --> $DIR/debug.rs:68:1 | LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32])); | ^^^^^^^^^^^^^^^^^^^^ @@ -695,7 +785,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:65:1 + --> $DIR/debug.rs:71:1 | LL | type TestAbiNeFloat = (fn(f32), fn(u32)); | ^^^^^^^^^^^^^^^^^^^ @@ -833,13 +923,13 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:69:1 + --> $DIR/debug.rs:75:1 | LL | type TestAbiNeSign = (fn(i32), fn(u32)); | ^^^^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/debug.rs:72:46 + --> $DIR/debug.rs:78:46 | LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -848,7 +938,7 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = note: only the last element of a tuple may have a dynamically sized type error: the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:47:5 + --> $DIR/debug.rs:53:5 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -927,12 +1017,12 @@ error: fn_abi_of(assoc_test) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:52:5 + --> $DIR/debug.rs:58:5 | LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 15 previous errors Some errors have detailed explanations: E0277, E0539. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.loongarch64.stderr b/tests/ui/abi/debug.loongarch64.stderr index 29ec7846101f1..15d76f6e32078 100644 --- a/tests/ui/abi/debug.loongarch64.stderr +++ b/tests/ui/abi/debug.loongarch64.stderr @@ -1,5 +1,5 @@ error: the `rustc_abi` attribute cannot be used on constants - --> $DIR/debug.rs:42:3 + --> $DIR/debug.rs:48:3 | LL | #[rustc_abi(debug)] | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[rustc_abi(debug)] = help: the `rustc_abi` attribute can be applied to functions and type aliases error: the `rustc_abi` attribute cannot be used on associated consts - --> $DIR/debug.rs:46:7 + --> $DIR/debug.rs:52:7 | LL | #[rustc_abi(debug)] | ^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[rustc_abi(debug)] = help: the `rustc_abi` attribute can be applied to functions and type aliases error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/debug.rs:74:3 + --> $DIR/debug.rs:80:3 | LL | #[rustc_abi("assert_eq")] | ^^^^^^^^^------------- @@ -112,6 +112,98 @@ error: fn_abi_of(test) = FnAbi { LL | fn test(_x: u8) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^ +error: fn_abi_of(test_unsized) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: [u8], + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: false, + }, + fields: Array { + stride: Size(1 bytes), + count: 0, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: IndirectUnsized { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: Some( + Align(1 bytes), + ), + }, + meta_attrs: ArgAttributes { + regular: , + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: bool, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + u8 is 0..=1, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: u8, + valid_range: 0..=1, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:37:1 + | +LL | fn test_unsized(_x: [u8]) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: fn_abi_of(TestFnPtr) = FnAbi { args: [ ArgAbi { @@ -188,7 +280,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:37:1 + --> $DIR/debug.rs:43:1 | LL | type TestFnPtr = fn(bool) -> u8; | ^^^^^^^^^^^^^^ @@ -259,13 +351,13 @@ error: fn_abi_of(test_generic) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:40:1 + --> $DIR/debug.rs:46:1 | LL | fn test_generic(_x: *const T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:43:1 + --> $DIR/debug.rs:49:1 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -403,7 +495,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:59:1 + --> $DIR/debug.rs:65:1 | LL | type TestAbiNe = (fn(u8), fn(u32)); | ^^^^^^^^^^^^^^ @@ -445,7 +537,6 @@ error: ABIs are not compatible Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -519,7 +610,6 @@ error: ABIs are not compatible Align(4 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -557,7 +647,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:62:1 + --> $DIR/debug.rs:68:1 | LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32])); | ^^^^^^^^^^^^^^^^^^^^ @@ -695,7 +785,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:65:1 + --> $DIR/debug.rs:71:1 | LL | type TestAbiNeFloat = (fn(f32), fn(u32)); | ^^^^^^^^^^^^^^^^^^^ @@ -833,13 +923,13 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:69:1 + --> $DIR/debug.rs:75:1 | LL | type TestAbiNeSign = (fn(i32), fn(u32)); | ^^^^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/debug.rs:72:46 + --> $DIR/debug.rs:78:46 | LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -848,7 +938,7 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = note: only the last element of a tuple may have a dynamically sized type error: the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:47:5 + --> $DIR/debug.rs:53:5 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -927,12 +1017,12 @@ error: fn_abi_of(assoc_test) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:52:5 + --> $DIR/debug.rs:58:5 | LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 15 previous errors Some errors have detailed explanations: E0277, E0539. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.riscv64.stderr b/tests/ui/abi/debug.riscv64.stderr index 29ec7846101f1..15d76f6e32078 100644 --- a/tests/ui/abi/debug.riscv64.stderr +++ b/tests/ui/abi/debug.riscv64.stderr @@ -1,5 +1,5 @@ error: the `rustc_abi` attribute cannot be used on constants - --> $DIR/debug.rs:42:3 + --> $DIR/debug.rs:48:3 | LL | #[rustc_abi(debug)] | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[rustc_abi(debug)] = help: the `rustc_abi` attribute can be applied to functions and type aliases error: the `rustc_abi` attribute cannot be used on associated consts - --> $DIR/debug.rs:46:7 + --> $DIR/debug.rs:52:7 | LL | #[rustc_abi(debug)] | ^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[rustc_abi(debug)] = help: the `rustc_abi` attribute can be applied to functions and type aliases error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/debug.rs:74:3 + --> $DIR/debug.rs:80:3 | LL | #[rustc_abi("assert_eq")] | ^^^^^^^^^------------- @@ -112,6 +112,98 @@ error: fn_abi_of(test) = FnAbi { LL | fn test(_x: u8) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^ +error: fn_abi_of(test_unsized) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: [u8], + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: false, + }, + fields: Array { + stride: Size(1 bytes), + count: 0, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: IndirectUnsized { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: Some( + Align(1 bytes), + ), + }, + meta_attrs: ArgAttributes { + regular: , + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: bool, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + u8 is 0..=1, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: u8, + valid_range: 0..=1, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:37:1 + | +LL | fn test_unsized(_x: [u8]) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: fn_abi_of(TestFnPtr) = FnAbi { args: [ ArgAbi { @@ -188,7 +280,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:37:1 + --> $DIR/debug.rs:43:1 | LL | type TestFnPtr = fn(bool) -> u8; | ^^^^^^^^^^^^^^ @@ -259,13 +351,13 @@ error: fn_abi_of(test_generic) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:40:1 + --> $DIR/debug.rs:46:1 | LL | fn test_generic(_x: *const T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:43:1 + --> $DIR/debug.rs:49:1 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -403,7 +495,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:59:1 + --> $DIR/debug.rs:65:1 | LL | type TestAbiNe = (fn(u8), fn(u32)); | ^^^^^^^^^^^^^^ @@ -445,7 +537,6 @@ error: ABIs are not compatible Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -519,7 +610,6 @@ error: ABIs are not compatible Align(4 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -557,7 +647,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:62:1 + --> $DIR/debug.rs:68:1 | LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32])); | ^^^^^^^^^^^^^^^^^^^^ @@ -695,7 +785,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:65:1 + --> $DIR/debug.rs:71:1 | LL | type TestAbiNeFloat = (fn(f32), fn(u32)); | ^^^^^^^^^^^^^^^^^^^ @@ -833,13 +923,13 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:69:1 + --> $DIR/debug.rs:75:1 | LL | type TestAbiNeSign = (fn(i32), fn(u32)); | ^^^^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/debug.rs:72:46 + --> $DIR/debug.rs:78:46 | LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -848,7 +938,7 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = note: only the last element of a tuple may have a dynamically sized type error: the `rustc_abi` attribute can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:47:5 + --> $DIR/debug.rs:53:5 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -927,12 +1017,12 @@ error: fn_abi_of(assoc_test) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:52:5 + --> $DIR/debug.rs:58:5 | LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 15 previous errors Some errors have detailed explanations: E0277, E0539. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.rs b/tests/ui/abi/debug.rs index 68228979d6900..8b897492e7865 100644 --- a/tests/ui/abi/debug.rs +++ b/tests/ui/abi/debug.rs @@ -16,7 +16,7 @@ //@ [generic] ignore-riscv64 //@ [generic] ignore-loongarch64 //@ ignore-backends: gcc -#![feature(rustc_attrs)] +#![feature(rustc_attrs, unsized_fn_params)] #![crate_type = "lib"] #![feature(no_core)] #![no_std] @@ -33,6 +33,12 @@ fn test(_x: u8) -> bool { true } +#[rustc_abi(debug)] +fn test_unsized(_x: [u8]) -> bool { + //~^ ERROR: fn_abi + true +} + #[rustc_abi(debug)] type TestFnPtr = fn(bool) -> u8; //~ ERROR: fn_abi diff --git a/tests/ui/abi/pass-indirectly-attr.stderr b/tests/ui/abi/pass-indirectly-attr.stderr index 5821e6279bb85..76d07c553a1a0 100644 --- a/tests/ui/abi/pass-indirectly-attr.stderr +++ b/tests/ui/abi/pass-indirectly-attr.stderr @@ -47,7 +47,6 @@ error: fn_abi_of(extern_c) = FnAbi { Align(1 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr index c9e77ac941901..59d4e18e4cd7c 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(take_va_list) = FnAbi { Align(8 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, diff --git a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr index 04320a5312361..b7e29098d6fe6 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr @@ -34,7 +34,6 @@ error: fn_abi_of(take_va_list) = FnAbi { Align(8 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -113,7 +112,6 @@ error: fn_abi_of(take_va_list_sysv64) = FnAbi { Align(8 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, }, @@ -194,7 +192,6 @@ error: fn_abi_of(take_va_list_win64) = FnAbi { Align(8 bytes), ), }, - meta_attrs: None, address_space: None, mode: Pointer, },