Matthias Krüger
cbe469a8b1
Rollup merge of #139917 - folkertdev:fn-align-multiple, r=jdonszelmann
...
fix for multiple `#[repr(align(N))]` on functions
tracking issue: https://github.com/rust-lang/rust/issues/82232
fixes https://github.com/rust-lang/rust/issues/132464
The behavior of align is specified at https://doc.rust-lang.org/reference/type-layout.html#r-layout.repr.alignment.align
> For align, if the specified alignment is less than the alignment of the type without the align modifier, then the alignment is unaffected.
So in effect that means that the maximum of the specified alignments should be chosen. That is also the current behavior for `align` on ADTs:
```rust
#![feature(fn_align)]
#[repr(C, align(32), align(64))]
struct Foo {
x: u64,
}
const _: () = assert!(core::mem::align_of::<Foo>() == 64);
// See the godbolt LLVM output: the alignment of this function is 32
#[no_mangle]
#[repr(align(32))]
#[repr(align(64))]
fn foo() {}
// The current logic just picks the first alignment: the alignment of this function is 64
#[no_mangle]
#[repr(align(64))]
#[repr(align(32))]
fn bar() {}
```
https://godbolt.org/z/scco435jE
https://github.com/rust-lang/rust/blob/afa859f8121bf2985362a2c8414dc71a825ccf2d/compiler/rustc_middle/src/ty/mod.rs#L1529-L1532
The https://github.com/rust-lang/rust/issues/132464 issue is really about parsing/representing the attribute, which has already been improved and now uses the "parse, don't validate" attribute approach. That means the behavior is already different from what the issue describes: on current `main`, the first value is chosen. This PR fixes a logic error, where we just did not check for the effect of two or more `align` modifiers. In combination, that fixes the issue.
cc ``@jdonszelmann`` if you do have further thoughs here
2025-04-17 00:14:28 +02:00
..
2025-03-19 19:45:46 +01:00
2025-04-07 07:11:52 -04:00
2024-05-31 15:56:43 +10:00
2025-04-06 21:41:47 +02:00
2024-12-15 19:01:45 +08:00
2025-04-13 01:22:59 +02:00
2024-10-31 18:20:11 +08:00
2025-02-11 13:41:35 -08:00
2024-12-19 20:36:51 +08:00
2025-04-05 11:44:38 -07:00
2024-05-31 15:56:43 +10:00
2025-04-15 22:18:10 -05:00
2025-04-07 16:53:11 -03:00
2025-04-04 16:13:57 -07:00
2025-02-11 13:41:35 -08:00
2024-12-11 21:34:48 +11:00
2024-02-22 16:04:04 +00:00
2025-04-13 01:34:25 +01:00
2025-04-11 23:21:31 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-12-19 20:36:51 +08:00
2025-03-11 00:27:32 +01:00
2024-05-31 15:56:43 +10:00
2024-06-25 19:00:02 +02:00
2025-03-28 09:19:57 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-04-05 04:05:04 +00:00
2025-04-11 10:53:45 +00:00
2025-02-27 12:22:59 +01:00
2024-02-22 16:04:04 +00:00
2024-06-19 13:54:55 +01:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-24 09:26:54 +00:00
2025-02-18 16:11:41 +01:00
2025-01-30 11:22:46 +01:00
2024-05-31 15:56:43 +10:00
2025-02-16 18:37:50 +01:00
2025-02-16 18:37:50 +01:00
2025-02-16 18:37:50 +01:00
2024-05-31 15:56:43 +10:00
2025-04-16 12:16:40 +02:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-03-17 14:08:09 +00:00
2025-02-10 21:38:44 +01:00
2025-02-11 13:41:35 -08:00
2025-04-12 22:10:17 -07:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-08-10 10:44:24 +08:00
2024-04-11 21:42:35 -04:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-04-11 17:20:08 +00:00
2025-03-21 17:34:45 -07:00
2025-04-10 09:56:37 +02:00
2025-04-10 09:56:37 +02:00
2025-04-11 09:57:21 +02:00
2025-04-10 09:56:37 +02:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-01-31 22:29:08 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-01-26 03:48:27 -05:00
2025-03-17 14:08:09 +00:00
2024-02-22 16:04:04 +00:00
2025-04-05 11:44:38 -07:00
2024-02-22 16:04:04 +00:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-03-06 21:38:39 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-04-03 21:59:43 +08:00
2024-07-25 15:14:42 -04:00
2024-02-22 16:04:04 +00:00
2024-05-31 15:56:43 +10:00
2024-08-07 14:08:34 +02:00
2025-02-14 18:55:50 +00:00
2025-02-17 16:36:14 -08:00
2025-03-06 22:29:05 +08:00
2024-10-23 04:42:03 +02:00
2024-04-24 13:12:33 +01:00
2025-03-28 09:19:57 +00:00
2024-09-09 19:39:43 -07:00
2024-09-21 01:07:00 -04:00
2024-06-04 01:30:51 -07:00
2024-05-31 15:56:43 +10:00
2025-04-10 09:56:37 +02:00
2025-03-17 14:08:09 +00:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2025-02-03 10:39:32 -05:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2025-03-28 09:19:57 +00:00
2025-02-11 13:41:35 -08:00
2025-04-10 09:56:37 +02:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-10-11 08:43:27 +11:00
2024-02-22 16:04:04 +00:00
2024-06-05 15:40:11 +00:00
2025-04-07 09:36:56 +02:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-04-06 21:41:47 +02:00
2025-04-06 21:41:47 +02:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2025-03-28 09:19:57 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-04-04 16:13:57 -07:00
2024-03-11 09:36:35 -07:00
2024-06-23 00:40:43 -07:00
2025-02-03 10:39:32 -05:00
2024-05-31 15:56:43 +10:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-01-21 06:59:15 -07:00
2024-07-14 13:48:29 +03:00
2025-02-19 15:15:29 +01:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-19 08:41:19 +01:00
2025-04-10 09:56:37 +02:00
2024-03-22 09:55:50 -04:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-04-10 09:56:37 +02:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2025-03-06 22:29:05 +08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-04-06 21:41:47 +02:00
2025-02-11 13:41:35 -08:00
2024-09-18 13:53:31 -07:00
2025-03-17 14:08:09 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-28 09:19:57 +00:00
2024-05-31 15:56:43 +10:00
2024-02-22 16:04:04 +00:00
2024-02-22 16:04:04 +00:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2025-02-11 13:41:35 -08:00
2024-07-14 13:48:29 +03:00
2025-02-11 13:41:35 -08:00
2025-03-12 00:56:43 -07:00
2024-02-22 16:04:04 +00:00
2025-02-11 13:41:35 -08:00
2024-12-10 01:29:43 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2025-01-10 22:53:54 +01:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-12-10 21:41:05 +01:00
2024-02-22 16:04:04 +00:00
2024-09-21 01:07:00 -04:00
2024-05-31 15:56:43 +10:00
2024-02-22 16:04:04 +00:00
2025-02-24 09:26:54 +00:00
2024-02-22 16:04:04 +00:00
2024-04-04 21:59:08 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2024-05-31 15:56:43 +10:00
2024-07-14 13:48:29 +03:00
2025-02-11 13:41:35 -08:00
2025-01-23 17:19:53 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-23 21:23:36 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2025-03-06 10:50:23 +00:00
2025-02-11 13:41:35 -08:00
2024-06-14 13:31:46 +10:00
2024-06-14 13:31:46 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-19 11:32:32 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-03-12 22:39:43 -07:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2024-03-12 19:01:04 -04:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-02 18:53:49 +00:00
2025-03-19 19:45:46 +01:00
2025-02-11 13:41:35 -08:00
2025-02-12 23:01:27 -08:00
2025-02-14 22:24:27 -08:00
2025-03-31 22:38:53 +09:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-13 21:26:48 -08:00
2025-02-11 13:41:35 -08:00
2025-03-30 12:45:04 -04:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-08-07 00:41:48 -04:00
2025-02-24 09:26:54 +00:00
2024-02-22 16:04:04 +00:00
2025-02-11 13:41:35 -08:00
2024-02-22 16:04:04 +00:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-04-09 13:06:10 +03:00
2025-04-09 09:09:37 -07:00
2025-04-09 10:44:49 -07:00
2024-02-22 16:04:04 +00:00
2025-03-06 19:56:21 +00:00
2025-02-24 09:26:54 +00:00
2025-02-06 18:21:13 +03:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-19 11:36:52 -08:00
2025-04-10 09:56:37 +02:00
2024-05-31 15:56:43 +10:00
2024-10-19 13:09:21 +00:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2024-02-22 16:04:04 +00:00
2025-02-25 17:46:05 -05:00
2025-03-28 09:19:57 +00:00
2025-03-19 23:57:49 -04:00
2025-02-19 11:36:52 -08:00
2024-06-19 13:54:55 +01:00
2024-06-19 13:54:55 +01:00
2024-06-19 13:54:55 +01:00
2024-09-18 13:53:31 -07:00
2024-09-18 13:53:31 -07:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-11 13:41:35 -08:00
2025-03-17 14:08:09 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-17 14:08:09 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-27 12:58:18 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-06 23:44:23 +01:00
2024-02-22 16:04:04 +00:00
2025-01-28 19:10:26 +03:00
2025-02-11 13:41:35 -08:00
2024-09-09 19:39:43 -07:00