about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-04-17 18:13:34 +0200
committerGitHub <noreply@github.com>2023-04-17 18:13:34 +0200
commiteb0524615c615a2bcaeb7f4998e340771b550669 (patch)
tree1d4ec73bcae29c5c4a4f3b05392b74e25e7cd9c0 /tests/codegen
parent06d12f668ebb84b01c3e68a059fed9fa66b24246 (diff)
parent84de04155c3a1d5e9f71c53bc0d93b46e0417b25 (diff)
downloadrust-eb0524615c615a2bcaeb7f4998e340771b550669.tar.gz
rust-eb0524615c615a2bcaeb7f4998e340771b550669.zip
Rollup merge of #110313 - fee1-dead-contrib:repr_align_method, r=WaffleLapkin
allow `repr(align = x)` on inherent methods

Discussion: https://github.com/rust-lang/rust/issues/82232#issuecomment-905929314
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/align-fn.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs
index c5886cf2808..f3cf614e185 100644
--- a/tests/codegen/align-fn.rs
+++ b/tests/codegen/align-fn.rs
@@ -7,3 +7,43 @@
 #[no_mangle]
 #[repr(align(16))]
 pub fn fn_align() {}
+
+pub struct A;
+
+impl A {
+    // CHECK: align 16
+    #[no_mangle]
+    #[repr(align(16))]
+    pub fn method_align(self) {}
+
+    // CHECK: align 16
+    #[no_mangle]
+    #[repr(align(16))]
+    pub fn associated_fn() {}
+}
+
+trait T: Sized {
+    fn trait_fn() {}
+
+    // CHECK: align 32
+    #[repr(align(32))]
+    fn trait_method(self) {}
+}
+
+impl T for A {
+    // CHECK: align 16
+    #[no_mangle]
+    #[repr(align(16))]
+    fn trait_fn() {}
+
+    // CHECK: align 16
+    #[no_mangle]
+    #[repr(align(16))]
+    fn trait_method(self) {}
+}
+
+impl T for () {}
+
+pub fn foo() {
+    ().trait_method();
+}