0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-11-21 22:01:17 +01:00
rust/tests/ui/target-feature/tied-features-no-implication.rs
David Wood 6edd86d58e
tests: add test for #105111
Enabling a tied feature should not enable the other feature
automatically. This was fixed by something in #128796, probably #128221
or #128679.
2024-09-24 15:42:15 +01:00

30 lines
1.2 KiB
Rust

//@ revisions: paca pacg
//@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu
//@ needs-llvm-components: aarch64
//@[paca] compile-flags: -Ctarget-feature=+paca
//@[paca] error-pattern: the target features paca, pacg must all be either enabled or disabled together
//@[pacg] compile-flags: -Ctarget-feature=+pacg
//@[pacg] error-pattern: the name `foo` is defined multiple times
#![feature(no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized {}
// Can't use `compile_error!` here without `core`/`std` but requiring these makes this test only
// work if you have libcore built in the sysroot for `aarch64-unknown-linux-gnu`. Can't run this
// test on any aarch64 platform because they all have different default available features - as
// written, this test depends on `aarch64-unknown-linux-gnu` having -paca,-pacg by default.
// Cause a multiple definition error instead.
fn foo() {}
// Enabling one of the tied features does not imply the other is enabled.
//
// With +paca, this multiple definition doesn't cause an error because +paca hasn't implied
// +pacg. With +pacg, the multiple definition error is emitted (and the tied feature error would
// be).
#[cfg(target_feature = "pacg")]
pub unsafe fn foo() {
}