Skip to content

Commit b69d044

Browse files
committed
Auto merge of #140165 - ChrisDenton:rollup-on2dpr5, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - #139617 (Use posix_spawn on cygwin) - #139921 (improve diagnostic for raw pointer field access with ->) - #140031 (compiletest: Fix deadline bugs in new executor) - #140072 (handle function alignment in miri) - #140104 (Fix auto diff failing on inherent impl blocks) - #140124 (Update books) - #140144 (Handle another negated literal in `eat_token_lit`.) - #140149 (test_nan: ensure the NAN contant is quiet) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 814f412 + 15af173 commit b69d044

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/pass/fn_align.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@compile-flags: -Zmin-function-alignment=8
2+
#![feature(fn_align)]
3+
4+
// When a function uses `repr(align(N))`, the function address should be a multiple of `N`.
5+
6+
#[repr(align(256))]
7+
fn foo() {}
8+
9+
#[repr(align(16))]
10+
fn bar() {}
11+
12+
#[repr(align(4))]
13+
fn baz() {}
14+
15+
fn main() {
16+
assert!((foo as usize).is_multiple_of(256));
17+
assert!((bar as usize).is_multiple_of(16));
18+
19+
// The maximum of `repr(align(N))` and `-Zmin-function-alignment=N` is used.
20+
assert!((baz as usize).is_multiple_of(8));
21+
}

0 commit comments

Comments
 (0)