rust/tests/ui/abi/debug.stderr
Jubilee Young 2e19658315 Remove rustc's notion of "preferred" alignment AKA __alignof
In PR 90877 T-lang decided not to remove `intrinsics::pref_align_of`.
However, the intrinsic and its supporting code
1.  is a nightly feature, so can be removed at compiler/libs discretion
2.  requires considerable effort in the compiler to support, as it
    necessarily complicates every single site reasoning about alignment
3.  has been justified based on relevance to codegen, but it is only a
    requirement for C++ (not C, not Rust) stack frame layout for AIX,
    in ways Rust would not consider even with increased C++ interop
4.  is only used by rustc to overalign some globals, not correctness
5.  can be adequately replaced by other rules for globals, as it mostly
    affects alignments for a few types under 16 bytes of alignment
6.  has only one clear benefactor: automating C -> Rust translation
    for GNU extensions like `__alignof`
7.  such code was likely intended to be `alignof` or `_Alignof`,
    because the GNU extension is a "false friend" of the C keyword,
    which makes the choice to support such a mapping very questionable
8.  makes it easy to do incorrect codegen in the compiler by its mere
    presence as usual Rust rules of alignment (e.g. `size == align * N`)
    do not hold with preferred alignment

The implementation is clearly damaging the code quality of the compiler.
Thus it is within the compiler team's purview to simply rip it out.
If T-lang wishes to have this intrinsic restored for c2rust's benefit,
it would have to use a radically different implementation that somehow
does not cause internal incorrectness.

Until then, remove the intrinsic and its supporting code, as one tool
and an ill-considered GCC extension cannot justify risking correctness.

Because we touch a fair amount of the compiler to change this at all,
and unfortunately the duplication of AbiAndPrefAlign is deep-rooted,
we keep an "AbiAlign" type which we can wean code off later.
2025-06-08 16:41:46 -07:00

992 lines
35 KiB
Plaintext

error: fn_abi_of(test) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
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: 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(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=1,
},
),
fields: Primitive,
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I8,
false,
),
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:16:1
|
LL | fn test(_x: u8) -> bool { true }
| ^^^^^^^^^^^^^^^^^^^^^^^
error: fn_abi_of(TestFnPtr) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: bool,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=1,
},
),
fields: Primitive,
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I8,
false,
),
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,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:19:1
|
LL | type TestFnPtr = fn(bool) -> u8;
| ^^^^^^^^^^^^^^
error: fn_abi_of(test_generic) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: *const T,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Pointer(
AddressSpace(
0,
),
),
valid_range: $FULL,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:22:1
|
LL | fn test_generic<T>(_x: *const T) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
--> $DIR/debug.rs:25:1
|
LL | const C: () = ();
| ^^^^^^^^^^^
error: ABIs are not compatible
left ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u8,
layout: Layout {
size: Size(1 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=255,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
right ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: $FULL,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:41:1
|
LL | type TestAbiNe = (fn(u8), fn(u32));
| ^^^^^^^^^^^^^^
error: ABIs are not compatible
left ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: [u8; 32],
layout: Layout {
size: Size(32 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Array {
stride: Size(1 bytes),
count: 32,
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Indirect {
attrs: ArgAttributes {
regular: NoAlias | NoCapture | NonNull | NoUndef,
arg_ext: None,
pointee_size: Size(32 bytes),
pointee_align: Some(
Align(1 bytes),
),
},
meta_attrs: None,
on_stack: false,
},
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
right ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: [u32; 32],
layout: Layout {
size: Size(128 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Array {
stride: Size(4 bytes),
count: 32,
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Indirect {
attrs: ArgAttributes {
regular: NoAlias | NoCapture | NonNull | NoUndef,
arg_ext: None,
pointee_size: Size(128 bytes),
pointee_align: Some(
Align(4 bytes),
),
},
meta_attrs: None,
on_stack: false,
},
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:44:1
|
LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32]));
| ^^^^^^^^^^^^^^^^^^^^
error: ABIs are not compatible
left ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: f32,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Float(
F32,
),
valid_range: $FULL,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
right ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: $FULL,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:47:1
|
LL | type TestAbiNeFloat = (fn(f32), fn(u32));
| ^^^^^^^^^^^^^^^^^^^
error: ABIs are not compatible
left ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: i32,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
true,
),
valid_range: $FULL,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
right ABI = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: u32,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: $FULL,
},
),
fields: Primitive,
largest_niche: None,
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: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:51: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:54:46
|
LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: only the last element of a tuple may have a dynamically sized type
error: unrecognized argument
--> $DIR/debug.rs:56:13
|
LL | #[rustc_abi("assert_eq")]
| ^^^^^^^^^^^
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
--> $DIR/debug.rs:29:5
|
LL | const C: () = ();
| ^^^^^^^^^^^
error: fn_abi_of(assoc_test) = FnAbi {
args: [
ArgAbi {
layout: TyAndLayout {
ty: &S,
layout: Layout {
size: $SOME_SIZE,
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
value: Pointer(
AddressSpace(
0,
),
),
valid_range: $NON_NULL,
},
),
fields: Primitive,
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Pointer(
AddressSpace(
0,
),
),
valid_range: $NON_NULL,
},
),
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Direct(
ArgAttributes {
regular: NoAlias | NonNull | ReadOnly | NoUndef,
arg_ext: None,
pointee_size: Size(2 bytes),
pointee_align: Some(
Align(2 bytes),
),
},
),
},
],
ret: ArgAbi {
layout: TyAndLayout {
ty: (),
layout: Layout {
size: Size(0 bytes),
align: AbiAlign {
abi: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
uninhabited: false,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: $SOME_ALIGN,
randomization_seed: $SEED,
},
},
mode: Ignore,
},
c_variadic: false,
fixed_count: 1,
conv: Rust,
can_unwind: $SOME_BOOL,
}
--> $DIR/debug.rs:34:5
|
LL | fn assoc_test(&self) { }
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0277`.