Skip to content

Commit 240cc10

Browse files
committed
add more revisions to cover more architectures
1 parent c73687f commit 240cc10

10 files changed

+89
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
2+
--> $DIR/abi-incompatible-target-feature-attribute.rs:15:90
3+
|
4+
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
5+
| ^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`.
2-
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
3-
//@ needs-llvm-components: riscv
4-
#![feature(no_core, lang_items, riscv_target_feature)]
2+
// ignore-tidy-linelength
3+
//@ compile-flags: --crate-type=lib
4+
//@ revisions: x86 riscv
5+
//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu
6+
//@[x86] needs-llvm-components: x86
7+
//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf
8+
//@[riscv] needs-llvm-components: riscv
9+
#![feature(no_core, lang_items, riscv_target_feature, x87_target_feature)]
510
#![no_core]
611

712
#[lang = "sized"]
813
pub trait Sized {}
914

10-
#[target_feature(enable = "d")]
15+
#[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
1116
//~^ERROR: cannot be enabled with
1217
pub unsafe fn my_fun() {}

tests/ui/target-feature/abi-incompatible-target-feature-attribute.stderr

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
2+
--> $DIR/abi-incompatible-target-feature-attribute.rs:15:32
3+
|
4+
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: target feature `d` must be disabled to ensure that the ABI of the current target can be implemented correctly
2+
|
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
5+
6+
warning: unstable feature specified for `-Ctarget-feature`: `d`
7+
|
8+
= note: this feature is not stably supported; its behavior can change in the future
9+
10+
warning: unstable feature specified for `-Ctarget-feature`: `f`
11+
|
12+
= note: this feature is not stably supported; its behavior can change in the future
13+
14+
warning: unstable feature specified for `-Ctarget-feature`: `zicsr`
15+
|
16+
= note: this feature is not stably supported; its behavior can change in the future
17+
18+
warning: 4 warnings emitted
19+
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`.
2-
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
3-
//@ needs-llvm-components: x86
4-
//@ compile-flags: -Ctarget-feature=+soft-float
5-
// For now this is just a warning.
6-
//@ build-pass
2+
// These are just warnings for now.
3+
//@ check-pass
4+
//@ compile-flags: --crate-type=lib
5+
//@ revisions: x86 riscv
6+
//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=+soft-float
7+
//@[x86] needs-llvm-components: x86
8+
//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf -Ctarget-feature=+d
9+
//@[riscv] needs-llvm-components: riscv
710

811
#![feature(no_core, lang_items, riscv_target_feature)]
912
#![no_core]
1013

1114
#[lang = "sized"]
1215
pub trait Sized {}
16+
#[lang = "freeze"]
17+
pub trait Freeze {}
1318

14-
//~? WARN target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctl
15-
//~? WARN unstable feature specified for `-Ctarget-feature`: `soft-float`
19+
//~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly
20+
//~? WARN unstable feature specified for `-Ctarget-feature`
21+
//[riscv]~? WARN unstable feature specified for `-Ctarget-feature`
22+
//[riscv]~? WARN unstable feature specified for `-Ctarget-feature`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly
2+
|
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
5+
6+
warning: unstable feature specified for `-Ctarget-feature`: `d`
7+
|
8+
= note: this feature is not stably supported; its behavior can change in the future
9+
10+
warning: both target-abi and the triple-implied ABI are invalid, ignoring and using feature-implied ABI
11+
warning: 'lp64f' has not been standardized
12+
warning: 2 warnings emitted
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly
2+
|
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
5+
6+
warning: unstable feature specified for `-Ctarget-feature`: `d`
7+
|
8+
= note: this feature is not stably supported; its behavior can change in the future
9+
10+
Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
11+
warning: 2 warnings emitted
12+

tests/ui/target-feature/abi-required-target-feature-flag-disable.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
//! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`.
22
//! Also covers the case of a feature indirectly disabling another via feature implications.
33
//@ compile-flags: --crate-type=lib
4-
//@ revisions: x86 x86-implied aarch64
4+
//@ revisions: x86 x86-implied aarch64 riscv loongarch
55
//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-x87
66
//@[x86] needs-llvm-components: x86
77
//@[x86-implied] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-sse
88
//@[x86-implied] needs-llvm-components: x86
99
//@[aarch64] compile-flags: --target=aarch64-unknown-linux-gnu -Ctarget-feature=-neon
1010
//@[aarch64] needs-llvm-components: aarch64
11+
//@[riscv] compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=-d
12+
//@[riscv] needs-llvm-components: riscv
13+
//@[loongarch] compile-flags: --target=loongarch64-unknown-none -Ctarget-feature=-d
14+
//@[loongarch] needs-llvm-components: loongarch
1115
// For now this is just a warning.
1216
//@ build-pass
1317

@@ -18,4 +22,4 @@
1822
pub trait Sized {}
1923

2024
//~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly
21-
//[x86]~? WARN unstable feature specified for `-Ctarget-feature`
25+
//[x86,riscv,loongarch]~? WARN unstable feature specified for `-Ctarget-feature`

0 commit comments

Comments
 (0)