Skip to content

Commit 6edd86d

Browse files
committed
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.
1 parent 11e760b commit 6edd86d

6 files changed

+75
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: the target features paca, pacg must all be either enabled or disabled together
2+
3+
error: aborting due to 1 previous error
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: the target features paca, pacg must all be either enabled or disabled together
2+
3+
error: aborting due to 1 previous error
4+
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ revisions: paca pacg
2+
//@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu
3+
//@ needs-llvm-components: aarch64
4+
//@[paca] compile-flags: -Ctarget-feature=+paca
5+
//@[paca] error-pattern: the target features paca, pacg must all be either enabled or disabled together
6+
//@[pacg] compile-flags: -Ctarget-feature=+pacg
7+
//@[paca] error-pattern: the target features paca, pacg must all be either enabled or disabled together
8+
#![feature(no_core, lang_items)]
9+
#![no_core]
10+
11+
#[lang="sized"]
12+
trait Sized {}
13+
14+
// In this test, demonstrate that +paca and +pacg both result in the tied feature error if there
15+
// isn't something causing an error.
16+
// See tied-features-no-implication.rs
17+
18+
#[cfg(target_feature = "pacg")]
19+
pub unsafe fn foo() {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: the target features paca, pacg must all be either enabled or disabled together
2+
3+
error: aborting due to 1 previous error
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0428]: the name `foo` is defined multiple times
2+
--> $DIR/tied-features-no-implication.rs:28:1
3+
|
4+
LL | fn foo() {}
5+
| -------- previous definition of the value `foo` here
6+
...
7+
LL | pub unsafe fn foo() {
8+
| ^^^^^^^^^^^^^^^^^^^ `foo` redefined here
9+
|
10+
= note: `foo` must be defined only once in the value namespace of this module
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0428`.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ revisions: paca pacg
2+
//@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu
3+
//@ needs-llvm-components: aarch64
4+
//@[paca] compile-flags: -Ctarget-feature=+paca
5+
//@[paca] error-pattern: the target features paca, pacg must all be either enabled or disabled together
6+
//@[pacg] compile-flags: -Ctarget-feature=+pacg
7+
//@[pacg] error-pattern: the name `foo` is defined multiple times
8+
#![feature(no_core, lang_items)]
9+
#![no_core]
10+
11+
#[lang="sized"]
12+
trait Sized {}
13+
14+
// Can't use `compile_error!` here without `core`/`std` but requiring these makes this test only
15+
// work if you have libcore built in the sysroot for `aarch64-unknown-linux-gnu`. Can't run this
16+
// test on any aarch64 platform because they all have different default available features - as
17+
// written, this test depends on `aarch64-unknown-linux-gnu` having -paca,-pacg by default.
18+
// Cause a multiple definition error instead.
19+
fn foo() {}
20+
21+
// Enabling one of the tied features does not imply the other is enabled.
22+
//
23+
// With +paca, this multiple definition doesn't cause an error because +paca hasn't implied
24+
// +pacg. With +pacg, the multiple definition error is emitted (and the tied feature error would
25+
// be).
26+
27+
#[cfg(target_feature = "pacg")]
28+
pub unsafe fn foo() {
29+
}

0 commit comments

Comments
 (0)