diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 8d6e1d8941b72..4036f7aa68870 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -207,7 +207,12 @@ pub(crate) unsafe fn create_module<'ll>( } } - // Ensure the data-layout values hardcoded remain the defaults. + if sess.target.os == "aix" { + // See https://github.com/llvm/llvm-project/issues/133599 + target_data_layout = target_data_layout.replace("-f64:32:64", ""); + } + + // Ensure our hardcoded data-layout values remain the defaults. { let tm = crate::back::write::create_informational_target_machine(tcx.sess, false); unsafe { diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index fd2e2ba39acec..56f46433e5dde 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -1017,7 +1017,5 @@ lint_useless_ptr_null_checks_fn_ret = returned pointer of `{$fn_name}` call is n lint_useless_ptr_null_checks_ref = references are not nullable, so checking them for null will always return false .label = expression has type `{$orig_ty}` -lint_uses_power_alignment = repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - lint_variant_size_differences = enum variant is more than three times larger ({$largest} bytes) than the next largest diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 9d3c74a9a2b80..7ce95e852e159 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1741,10 +1741,6 @@ pub(crate) struct OverflowingLiteral<'a> { pub lit: String, } -#[derive(LintDiagnostic)] -#[diag(lint_uses_power_alignment)] -pub(crate) struct UsesPowerAlignment; - #[derive(LintDiagnostic)] #[diag(lint_unused_comparisons)] pub(crate) struct UnusedComparisons; diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index fec23354c9122..12491e699ecd4 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1,7 +1,7 @@ use std::iter; use std::ops::ControlFlow; -use rustc_abi::{BackendRepr, TagEncoding, VariantIdx, Variants, WrappingRange}; +use rustc_abi::{BackendRepr, TagEncoding, Variants, WrappingRange}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::DiagMessage; use rustc_hir::intravisit::VisitorExt; @@ -9,8 +9,7 @@ use rustc_hir::{AmbigArg, Expr, ExprKind, HirId, LangItem}; use rustc_middle::bug; use rustc_middle::ty::layout::{LayoutOf, SizeSkeleton}; use rustc_middle::ty::{ - self, Adt, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, - TypeVisitableExt, + self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, }; use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; use rustc_span::def_id::LocalDefId; @@ -26,7 +25,7 @@ use crate::lints::{ AmbiguousWidePointerComparisonsExpectSuggestion, AtomicOrderingFence, AtomicOrderingLoad, AtomicOrderingStore, ImproperCTypes, InvalidAtomicOrderingDiag, InvalidNanComparisons, InvalidNanComparisonsSuggestion, UnpredictableFunctionPointerComparisons, - UnpredictableFunctionPointerComparisonsSuggestion, UnusedComparisons, UsesPowerAlignment, + UnpredictableFunctionPointerComparisonsSuggestion, UnusedComparisons, VariantSizeDifferencesDiag, }; use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent}; @@ -752,62 +751,7 @@ declare_lint! { "proper use of libc types in foreign item definitions" } -declare_lint! { - /// The `uses_power_alignment` lint detects specific `repr(C)` - /// aggregates on AIX. - /// In its platform C ABI, AIX uses the "power" (as in PowerPC) alignment - /// rule (detailed in https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=data-using-alignment-modes#alignment), - /// which can also be set for XLC by `#pragma align(power)` or - /// `-qalign=power`. Aggregates with a floating-point type as the - /// recursively first field (as in "at offset 0") modify the layout of - /// *subsequent* fields of the associated structs to use an alignment value - /// where the floating-point type is aligned on a 4-byte boundary. - /// - /// Effectively, subsequent floating-point fields act as-if they are `repr(packed(4))`. This - /// would be unsound to do in a `repr(C)` type without all the restrictions that come with - /// `repr(packed)`. Rust instead chooses a layout that maintains soundness of Rust code, at the - /// expense of incompatibility with C code. - /// - /// ### Example - /// - /// ```rust,ignore (fails on non-powerpc64-ibm-aix) - /// #[repr(C)] - /// pub struct Floats { - /// a: f64, - /// b: u8, - /// c: f64, - /// } - /// ``` - /// - /// This will produce: - /// - /// ```text - /// warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - /// --> :5:3 - /// | - /// 5 | c: f64, - /// | ^^^^^^ - /// | - /// = note: `#[warn(uses_power_alignment)]` on by default - /// ``` - /// - /// ### Explanation - /// - /// The power alignment rule specifies that the above struct has the - /// following alignment: - /// - offset_of!(Floats, a) == 0 - /// - offset_of!(Floats, b) == 8 - /// - offset_of!(Floats, c) == 12 - /// - /// However, Rust currently aligns `c` at `offset_of!(Floats, c) == 16`. - /// Using offset 12 would be unsound since `f64` generally must be 8-aligned on this target. - /// Thus, a warning is produced for the above struct. - USES_POWER_ALIGNMENT, - Warn, - "Structs do not follow the power alignment rule under repr(C)" -} - -declare_lint_pass!(ImproperCTypesDefinitions => [IMPROPER_CTYPES_DEFINITIONS, USES_POWER_ALIGNMENT]); +declare_lint_pass!(ImproperCTypesDefinitions => [IMPROPER_CTYPES_DEFINITIONS]); #[derive(Clone, Copy)] pub(crate) enum CItemKind { @@ -1647,68 +1591,6 @@ impl ImproperCTypesDefinitions { vis.check_type_for_ffi_and_report_errors(span, fn_ptr_ty, true, false); } } - - fn check_arg_for_power_alignment<'tcx>( - &mut self, - cx: &LateContext<'tcx>, - ty: Ty<'tcx>, - ) -> bool { - assert!(cx.tcx.sess.target.os == "aix"); - // Structs (under repr(C)) follow the power alignment rule if: - // - the first field of the struct is a floating-point type that - // is greater than 4-bytes, or - // - the first field of the struct is an aggregate whose - // recursively first field is a floating-point type greater than - // 4 bytes. - if ty.is_floating_point() && ty.primitive_size(cx.tcx).bytes() > 4 { - return true; - } else if let Adt(adt_def, _) = ty.kind() - && adt_def.is_struct() - && adt_def.repr().c() - && !adt_def.repr().packed() - && adt_def.repr().align.is_none() - { - let struct_variant = adt_def.variant(VariantIdx::ZERO); - // Within a nested struct, all fields are examined to correctly - // report if any fields after the nested struct within the - // original struct are misaligned. - for struct_field in &struct_variant.fields { - let field_ty = cx.tcx.type_of(struct_field.did).instantiate_identity(); - if self.check_arg_for_power_alignment(cx, field_ty) { - return true; - } - } - } - return false; - } - - fn check_struct_for_power_alignment<'tcx>( - &mut self, - cx: &LateContext<'tcx>, - item: &'tcx hir::Item<'tcx>, - ) { - let adt_def = cx.tcx.adt_def(item.owner_id.to_def_id()); - // repr(C) structs also with packed or aligned representation - // should be ignored. - if adt_def.repr().c() - && !adt_def.repr().packed() - && adt_def.repr().align.is_none() - && cx.tcx.sess.target.os == "aix" - && !adt_def.all_fields().next().is_none() - { - let struct_variant_data = item.expect_struct().2; - for field_def in struct_variant_data.fields().iter().skip(1) { - // Struct fields (after the first field) are checked for the - // power alignment rule, as fields after the first are likely - // to be the fields that are misaligned. - let def_id = field_def.def_id; - let ty = cx.tcx.type_of(def_id).instantiate_identity(); - if self.check_arg_for_power_alignment(cx, ty) { - cx.emit_span_lint(USES_POWER_ALIGNMENT, field_def.span, UsesPowerAlignment); - } - } - } - } } /// `ImproperCTypesDefinitions` checks items outside of foreign items (e.g. stuff that isn't in @@ -1732,11 +1614,7 @@ impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDefinitions { } // See `check_fn`.. hir::ItemKind::Fn { .. } => {} - // Structs are checked based on if they follow the power alignment - // rule (under repr(C)). - hir::ItemKind::Struct(..) => { - self.check_struct_for_power_alignment(cx, item); - } + hir::ItemKind::Struct(..) => {} // See `check_field_def`.. hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) => {} // Doesn't define something that can contain a external type to be checked. diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs index a140518899970..a38e6555d559b 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs @@ -17,7 +17,12 @@ pub(crate) fn target() -> Target { std: None, // ? }, pointer_width: 64, - data_layout: "E-m:a-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), + // Note that the f64:32:64 deviates from what LLVM thinks should be the case, + // because LLVM doesn't know the layout actually used for AIX's C ABI, + // as clang reimplements it instead of trusting the datalayout string implicitly. + // See https://github.com/llvm/llvm-project/issues/133599 for more. + data_layout: "E-m:a-Fi64-i64:64-f64:32:64-i128:128-n32:64-S128-v256:256:256-v512:512:512" + .into(), arch: "powerpc64".into(), options: base, } diff --git a/tests/ui/layout/reprc-power-alignment.rs b/tests/ui/layout/reprc-power-alignment.rs index f144094d43fbc..0c8911f8830f0 100644 --- a/tests/ui/layout/reprc-power-alignment.rs +++ b/tests/ui/layout/reprc-power-alignment.rs @@ -1,176 +1,209 @@ -//@ check-pass //@ compile-flags: --target powerpc64-ibm-aix //@ needs-llvm-components: powerpc //@ add-core-stubs -#![feature(no_core)] +#![feature(no_core, rustc_attrs)] #![no_core] #![no_std] extern crate minicore; use minicore::*; -#[warn(uses_power_alignment)] - +#[rustc_layout(align)] #[repr(C)] -pub struct Floats { +pub struct Floats { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } a: f64, b: u8, - c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + c: f64, d: f32, } -pub struct Floats2 { +#[rustc_layout(align)] +pub struct Floats2 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } a: f64, b: u32, c: f64, } +#[rustc_layout(align)] #[repr(C)] -pub struct Floats3 { +pub struct Floats3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } a: f32, b: f32, c: i64, } +#[rustc_layout(align)] #[repr(C)] -pub struct Floats4 { +pub struct Floats4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } a: u64, b: u32, c: f32, } +#[rustc_layout(align)] #[repr(C)] -pub struct Floats5 { +pub struct Floats5 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } a: f32, - b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + b: f64, c: f32, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg1 { +pub struct FloatAgg1 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } x: Floats, - y: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: f64, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg2 { +pub struct FloatAgg2 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } x: i64, - y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: Floats, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg3 { +pub struct FloatAgg3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } x: FloatAgg1, - // NOTE: the "power" alignment rule is infectious to nested struct fields. - y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - z: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: FloatAgg2, + z: FloatAgg2, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg4 { +pub struct FloatAgg4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } x: FloatAgg1, - y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: FloatAgg2, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg5 { +pub struct FloatAgg5 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } x: FloatAgg1, - y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - z: FloatAgg3, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: FloatAgg2, + z: FloatAgg3, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg6 { +pub struct FloatAgg6 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } x: i64, - y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: Floats, z: u8, } +#[rustc_layout(align)] #[repr(C)] -pub struct FloatAgg7 { +pub struct FloatAgg7 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } x: i64, - y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + y: Floats, z: u8, zz: f32, } +#[rustc_layout(align)] #[repr(C)] -pub struct A { +pub struct A { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } d: f64, } + +#[rustc_layout(align)] #[repr(C)] -pub struct B { +pub struct B { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } a: A, f: f32, - d: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + d: f64, } + +#[rustc_layout(align)] #[repr(C)] -pub struct C { +pub struct C { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } c: u8, - b: B, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + b: B, } + +#[rustc_layout(align)] #[repr(C)] -pub struct D { +pub struct D { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } x: f64, } + +#[rustc_layout(align)] #[repr(C)] -pub struct E { +pub struct E { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } x: i32, - d: D, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + d: D, } + +#[rustc_layout(align)] #[repr(C)] -pub struct F { +pub struct F { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } a: u8, - b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + b: f64, } + +#[rustc_layout(align)] #[repr(C)] -pub struct G { +pub struct G { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } a: u8, b: u8, - c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + c: f64, d: f32, - e: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type + e: f64, } -// Should not warn on #[repr(packed)]. + +#[rustc_layout(align)] #[repr(packed)] -pub struct H { +pub struct H { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) } a: u8, b: u8, c: f64, d: f32, e: f64, } + +#[rustc_layout(align)] #[repr(C, packed)] -pub struct I { +pub struct I { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) } a: u8, b: u8, c: f64, d: f32, e: f64, } + + +#[rustc_layout(align)] #[repr(C)] -pub struct J { +pub struct J { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) } a: u8, b: I, } -// The lint also ignores diagnosing #[repr(align(n))]. + +#[rustc_layout(align)] #[repr(C, align(8))] -pub struct K { +pub struct K { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } a: u8, b: u8, c: f64, d: f32, e: f64, } + +#[rustc_layout(align)] #[repr(C)] -pub struct L { +pub struct L { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } a: u8, b: K, } + +#[rustc_layout(align)] #[repr(C, align(8))] -pub struct M { +pub struct M { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } a: u8, b: K, c: L, } + fn main() { } diff --git a/tests/ui/layout/reprc-power-alignment.stderr b/tests/ui/layout/reprc-power-alignment.stderr index 18664e4d655d3..5a563dfe54914 100644 --- a/tests/ui/layout/reprc-power-alignment.stderr +++ b/tests/ui/layout/reprc-power-alignment.stderr @@ -1,112 +1,152 @@ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:18:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:13:1 | -LL | c: f64, - | ^^^^^^ +LL | pub struct Floats { + | ^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:21:1 + | +LL | pub struct Floats2 { + | ^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:29:1 | -note: the lint level is defined here - --> $DIR/reprc-power-alignment.rs:12:8 +LL | pub struct Floats3 { + | ^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:37:1 | -LL | #[warn(uses_power_alignment)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | pub struct Floats4 { + | ^^^^^^^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:45:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:45:1 | -LL | b: f64, - | ^^^^^^ +LL | pub struct Floats5 { + | ^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:53:1 + | +LL | pub struct FloatAgg1 { + | ^^^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:60:1 + | +LL | pub struct FloatAgg2 { + | ^^^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:67:1 + | +LL | pub struct FloatAgg3 { + | ^^^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:75:1 + | +LL | pub struct FloatAgg4 { + | ^^^^^^^^^^^^^^^^^^^^ + +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:82:1 | - = note: `#[warn(uses_power_alignment)]` on by default +LL | pub struct FloatAgg5 { + | ^^^^^^^^^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:52:5 +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:90:1 | -LL | y: f64, - | ^^^^^^ +LL | pub struct FloatAgg6 { + | ^^^^^^^^^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:58:5 +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:98:1 | -LL | y: Floats, - | ^^^^^^^^^ +LL | pub struct FloatAgg7 { + | ^^^^^^^^^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:65:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:107:1 | -LL | y: FloatAgg2, - | ^^^^^^^^^^^^ +LL | pub struct A { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:66:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:113:1 | -LL | z: FloatAgg2, - | ^^^^^^^^^^^^ +LL | pub struct B { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:72:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:121:1 | -LL | y: FloatAgg2, - | ^^^^^^^^^^^^ +LL | pub struct C { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:78:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:128:1 | -LL | y: FloatAgg2, - | ^^^^^^^^^^^^ +LL | pub struct D { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:79:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:134:1 | -LL | z: FloatAgg3, - | ^^^^^^^^^^^^ +LL | pub struct E { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:85:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:141:1 | -LL | y: Floats, - | ^^^^^^^^^ +LL | pub struct F { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:92:5 +error: align: AbiAlign { abi: Align(4 bytes) } + --> $DIR/reprc-power-alignment.rs:148:1 | -LL | y: Floats, - | ^^^^^^^^^ +LL | pub struct G { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:105:3 +error: align: AbiAlign { abi: Align(1 bytes) } + --> $DIR/reprc-power-alignment.rs:158:1 | -LL | d: f64, - | ^^^^^^ +LL | pub struct H { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:110:3 +error: align: AbiAlign { abi: Align(1 bytes) } + --> $DIR/reprc-power-alignment.rs:168:1 | -LL | b: B, - | ^^^^ +LL | pub struct I { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:119:3 +error: align: AbiAlign { abi: Align(1 bytes) } + --> $DIR/reprc-power-alignment.rs:179:1 | -LL | d: D, - | ^^^^ +LL | pub struct J { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:124:3 +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:186:1 | -LL | b: f64, - | ^^^^^^ +LL | pub struct K { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:130:5 +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:196:1 | -LL | c: f64, - | ^^^^^^ +LL | pub struct L { + | ^^^^^^^^^^^^ -warning: repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type - --> $DIR/reprc-power-alignment.rs:132:5 +error: align: AbiAlign { abi: Align(8 bytes) } + --> $DIR/reprc-power-alignment.rs:203:1 | -LL | e: f64, - | ^^^^^^ +LL | pub struct M { + | ^^^^^^^^^^^^ -warning: 17 warnings emitted +error: aborting due to 25 previous errors diff --git a/tests/ui/lint/clashing-extern-fn.rs b/tests/ui/lint/clashing-extern-fn.rs index e4477c9620221..cdf0768e304bc 100644 --- a/tests/ui/lint/clashing-extern-fn.rs +++ b/tests/ui/lint/clashing-extern-fn.rs @@ -248,7 +248,6 @@ mod sameish_members { mod same_sized_members_clash { mod a { - #[allow(uses_power_alignment)] #[repr(C)] struct Point3 { x: f32, diff --git a/tests/ui/lint/clashing-extern-fn.stderr b/tests/ui/lint/clashing-extern-fn.stderr index 0c27547a6ed8f..a4531bcbc634a 100644 --- a/tests/ui/lint/clashing-extern-fn.stderr +++ b/tests/ui/lint/clashing-extern-fn.stderr @@ -1,5 +1,5 @@ warning: `extern` block uses type `Option`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:483:55 + --> $DIR/clashing-extern-fn.rs:482:55 | LL | fn hidden_niche_transparent_no_niche() -> Option; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -9,7 +9,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option>>`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:487:46 + --> $DIR/clashing-extern-fn.rs:486:46 | LL | fn hidden_niche_unsafe_cell() -> Option>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -18,7 +18,7 @@ LL | fn hidden_niche_unsafe_cell() -> Option`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:502:54 + --> $DIR/clashing-extern-fn.rs:501:54 | LL | fn pt_non_zero_usize_opt_full_range() -> Option; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -160,7 +160,7 @@ LL | fn draw_point(p: Point); found `unsafe extern "C" fn(sameish_members::b::Point)` warning: `origin` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:270:13 + --> $DIR/clashing-extern-fn.rs:269:13 | LL | fn origin() -> Point3; | ---------------------- `origin` previously declared here @@ -172,7 +172,7 @@ LL | fn origin() -> Point3; found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3` warning: `transparent_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:293:13 + --> $DIR/clashing-extern-fn.rs:292:13 | LL | fn transparent_incorrect() -> T; | -------------------------------- `transparent_incorrect` previously declared here @@ -184,7 +184,7 @@ LL | fn transparent_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `missing_return_type` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:311:13 + --> $DIR/clashing-extern-fn.rs:310:13 | LL | fn missing_return_type() -> usize; | ---------------------------------- `missing_return_type` previously declared here @@ -196,7 +196,7 @@ LL | fn missing_return_type(); found `unsafe extern "C" fn()` warning: `non_zero_usize` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:329:13 + --> $DIR/clashing-extern-fn.rs:328:13 | LL | fn non_zero_usize() -> core::num::NonZero; | ------------------------------------------------- `non_zero_usize` previously declared here @@ -208,7 +208,7 @@ LL | fn non_zero_usize() -> usize; found `unsafe extern "C" fn() -> usize` warning: `non_null_ptr` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:331:13 + --> $DIR/clashing-extern-fn.rs:330:13 | LL | fn non_null_ptr() -> core::ptr::NonNull; | ----------------------------------------------- `non_null_ptr` previously declared here @@ -220,7 +220,7 @@ LL | fn non_null_ptr() -> *const usize; found `unsafe extern "C" fn() -> *const usize` warning: `option_non_zero_usize_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:425:13 + --> $DIR/clashing-extern-fn.rs:424:13 | LL | fn option_non_zero_usize_incorrect() -> usize; | ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here @@ -232,7 +232,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `option_non_null_ptr_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:427:13 + --> $DIR/clashing-extern-fn.rs:426:13 | LL | fn option_non_null_ptr_incorrect() -> *const usize; | --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here @@ -244,7 +244,7 @@ LL | fn option_non_null_ptr_incorrect() -> *const isize; found `unsafe extern "C" fn() -> *const isize` warning: `hidden_niche_transparent_no_niche` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:483:13 + --> $DIR/clashing-extern-fn.rs:482:13 | LL | fn hidden_niche_transparent_no_niche() -> usize; | ------------------------------------------------ `hidden_niche_transparent_no_niche` previously declared here @@ -256,7 +256,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option Option` warning: `hidden_niche_unsafe_cell` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:487:13 + --> $DIR/clashing-extern-fn.rs:486:13 | LL | fn hidden_niche_unsafe_cell() -> usize; | --------------------------------------- `hidden_niche_unsafe_cell` previously declared here @@ -268,7 +268,7 @@ LL | fn hidden_niche_unsafe_cell() -> Option Option>>` warning: `pt_non_null_ptr` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:516:13 + --> $DIR/clashing-extern-fn.rs:515:13 | LL | fn pt_non_null_ptr() -> pattern_type!(usize is 1..); | ---------------------------------------------------- `pt_non_null_ptr` previously declared here