diff options
| author | bors <bors@rust-lang.org> | 2025-07-01 05:31:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-01 05:31:05 +0000 |
| commit | f46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca (patch) | |
| tree | 17a06668752fe94c0824b6b9788c02e7fbf56f1e /tests/codegen/align-fn.rs | |
| parent | 6988a8fea774a2a20ebebddb7dbf15dd6ef594f9 (diff) | |
| parent | 3944c8ce447404dc45c00e125baf6bbbd728b501 (diff) | |
| download | rust-f46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca.tar.gz rust-f46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca.zip | |
Auto merge of #143267 - matthiaskrgr:rollup-suvzar6, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang/rust#143125 (Disable f16 on Aarch64 without neon for llvm < 20.1.1) - rust-lang/rust#143156 (inherit `#[align]` from trait method prototypes) - rust-lang/rust#143178 (rustdoc default faviocon) - rust-lang/rust#143234 (Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`) - rust-lang/rust#143245 (mbe: Add tests and restructure metavariable expressions) - rust-lang/rust#143257 (Upgrade dependencies in run-make-support) - rust-lang/rust#143263 (linkify CodeSuggestion in doc comments) - rust-lang/rust#143264 (fix: Emit suggestion filename if primary diagnostic span is dummy) Failed merges: - rust-lang/rust#143251 (bootstrap: add build.tidy-extra-checks option) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen/align-fn.rs')
| -rw-r--r-- | tests/codegen/align-fn.rs | 82 |
1 files changed, 65 insertions, 17 deletions
diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index 267da060240..90073ff3081 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -1,10 +1,10 @@ -//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 +//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -Clink-dead-code #![crate_type = "lib"] #![feature(fn_align)] // CHECK: align 16 -#[no_mangle] +#[unsafe(no_mangle)] #[align(16)] pub fn fn_align() {} @@ -12,12 +12,12 @@ pub struct A; impl A { // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn method_align(self) {} // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn associated_fn() {} } @@ -25,46 +25,94 @@ impl A { trait T: Sized { fn trait_fn() {} - // CHECK: align 32 - #[align(32)] fn trait_method(self) {} + + #[align(8)] + fn trait_method_inherit_low(self); + + #[align(32)] + fn trait_method_inherit_high(self); + + #[align(32)] + fn trait_method_inherit_default(self) {} + + #[align(4)] + #[align(128)] + #[align(8)] + fn inherit_highest(self) {} } impl T for A { - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_fn + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_fn() {} - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_method + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_method(self) {} -} -impl T for () {} + // The prototype's align is ignored because the align here is higher. + // CHECK-LABEL: trait_method_inherit_low + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_low(self) {} + + // The prototype's align is used because it is higher. + // CHECK-LABEL: trait_method_inherit_high + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_high(self) {} + + // The prototype's align inherited. + // CHECK-LABEL: trait_method_inherit_default + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + fn trait_method_inherit_default(self) {} + + // The prototype's highest align inherited. + // CHECK-LABEL: inherit_highest + // CHECK-SAME: align 128 + #[unsafe(no_mangle)] + #[align(32)] + #[align(64)] + fn inherit_highest(self) {} +} -pub fn foo() { - ().trait_method(); +trait HasDefaultImpl: Sized { + // CHECK-LABEL: inherit_from_default_method + // CHECK-LABEL: inherit_from_default_method + // CHECK-SAME: align 32 + #[align(32)] + fn inherit_from_default_method(self) {} } +pub struct InstantiateDefaultMethods; + +impl HasDefaultImpl for InstantiateDefaultMethods {} + // CHECK-LABEL: align_specified_twice_1 // CHECK-SAME: align 64 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(64)] pub fn align_specified_twice_1() {} // CHECK-LABEL: align_specified_twice_2 // CHECK-SAME: align 128 -#[no_mangle] +#[unsafe(no_mangle)] #[align(128)] #[align(32)] pub fn align_specified_twice_2() {} // CHECK-LABEL: align_specified_twice_3 // CHECK-SAME: align 256 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(256)] pub fn align_specified_twice_3() {} |
