use minicore for target-feature tests

This commit is contained in:
Ralf Jung 2025-10-17 16:20:44 +02:00
parent a41214f9bd
commit 71d89c1cf4
27 changed files with 87 additions and 184 deletions

View file

@ -1,18 +1,13 @@
//@ compile-flags: --crate-type=lib
//@ compile-flags: --target=aarch64-unknown-none-softfloat
//@ needs-llvm-components: aarch64
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#![deny(aarch64_softfloat_neon)]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
#[target_feature(enable = "neon")]
//~^ERROR: enabling the `neon` target feature on the current target is unsound

View file

@ -1,5 +1,5 @@
error: enabling the `neon` target feature on the current target is unsound due to ABI issues
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:17:18
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:12:18
|
LL | #[target_feature(enable = "neon")]
| ^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[target_feature(enable = "neon")]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #134375 <https://github.com/rust-lang/rust/issues/134375>
note: the lint level is defined here
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:6:9
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:7:9
|
LL | #![deny(aarch64_softfloat_neon)]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -16,7 +16,7 @@ error: aborting due to 1 previous error
Future incompatibility report: Future breakage diagnostic:
error: enabling the `neon` target feature on the current target is unsound due to ABI issues
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:17:18
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:12:18
|
LL | #[target_feature(enable = "neon")]
| ^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL | #[target_feature(enable = "neon")]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #134375 <https://github.com/rust-lang/rust/issues/134375>
note: the lint level is defined here
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:6:9
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:7:9
|
LL | #![deny(aarch64_softfloat_neon)]
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
--> $DIR/abi-incompatible-target-feature-attribute.rs:22:90
--> $DIR/abi-incompatible-target-feature-attribute.rs:17:90
|
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
| ^^^^^^^^^^^^

View file

@ -7,17 +7,12 @@
//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf
//@[riscv] needs-llvm-components: riscv
//@ ignore-backends: gcc
#![feature(no_core, lang_items, riscv_target_feature, x87_target_feature)]
//@ add-core-stubs
#![feature(no_core, riscv_target_feature, x87_target_feature)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized {}
extern crate minicore;
use minicore::*;
#[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
//~^ERROR: cannot be enabled with

View file

@ -1,5 +1,5 @@
error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
--> $DIR/abi-incompatible-target-feature-attribute.rs:22:32
--> $DIR/abi-incompatible-target-feature-attribute.rs:17:32
|
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
| ^^^^^^^^^^^^^^^^^^^^^

View file

@ -8,20 +8,13 @@
//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf -Ctarget-feature=+d
//@[riscv] needs-llvm-components: riscv
//@ ignore-backends: gcc
//@ add-core-stubs
#![feature(no_core, lang_items, riscv_target_feature)]
#![feature(no_core, riscv_target_feature)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized {}
#[lang = "freeze"]
pub trait Freeze {}
extern crate minicore;
use minicore::*;
//~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly
//~? WARN unstable feature specified for `-Ctarget-feature`

View file

@ -6,16 +6,11 @@
//@ compile-flags: -Ctarget-feature=-x87
//@ build-pass
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
//~? WARN unstable feature specified for `-Ctarget-feature`: `x87`

View file

@ -4,17 +4,12 @@
//@ needs-llvm-components: x86
//@ build-pass
//@ ignore-backends: gcc
#![feature(no_core, lang_items, x87_target_feature)]
//@ add-core-stubs
#![feature(no_core, x87_target_feature)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
#[target_feature(enable = "x87")]
pub unsafe fn my_fun() {}

View file

@ -17,18 +17,13 @@
// Remove some LLVM warnings that only show up sometimes.
//@ normalize-stderr: "\n[^\n]*(target-abi|lp64f)[^\n]*" -> ""
//@ ignore-backends: gcc
//@ add-core-stubs
#![feature(no_core, lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized {}
extern crate minicore;
use minicore::*;
//~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly
//[x86,riscv]~? WARN unstable feature specified for `-Ctarget-feature`

View file

@ -4,27 +4,16 @@
//@ [aarch64-sve2] compile-flags: -Ctarget-feature=-neon,+sve2 --target=aarch64-unknown-linux-gnu
//@ [aarch64-sve2] needs-llvm-components: aarch64
//@ build-pass
//@ add-core-stubs
#![no_core]
#![crate_type = "rlib"]
#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)]
#![feature(intrinsics, rustc_attrs, no_core, staged_api)]
#![stable(feature = "test", since = "1.0.0")]
// Tests vetting "feature hierarchies" in the cases where we impose them.
// Supporting minimal rust core code
#[lang = "pointee_sized"]
trait PointeeSized {}
#[lang = "meta_sized"]
trait MetaSized: PointeeSized {}
#[lang = "sized"]
trait Sized: MetaSized {}
#[lang = "copy"]
trait Copy {}
impl Copy for bool {}
extern crate minicore;
use minicore::*;
#[stable(feature = "test", since = "1.0.0")]
#[rustc_const_stable(feature = "test", since = "1.0.0")]

View file

@ -2,17 +2,12 @@
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
//@ needs-llvm-components: riscv
//@ ignore-backends: gcc
#![feature(no_core, lang_items, riscv_target_feature)]
//@ add-core-stubs
#![feature(no_core, riscv_target_feature)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
#[target_feature(enable = "d")]
//~^ERROR: cannot be enabled with

View file

@ -1,5 +1,5 @@
error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
--> $DIR/forbidden-hardfloat-target-feature-attribute-e-d.rs:17:18
--> $DIR/forbidden-hardfloat-target-feature-attribute-e-d.rs:12:18
|
LL | #[target_feature(enable = "d")]
| ^^^^^^^^^^^^

View file

@ -2,17 +2,12 @@
//@ compile-flags: --target=riscv64gc-unknown-linux-gnu --crate-type=lib
//@ needs-llvm-components: riscv
//@ ignore-backends: gcc
#![feature(no_core, lang_items, riscv_target_feature)]
//@ add-core-stubs
#![feature(no_core, riscv_target_feature)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized {}
extern crate minicore;
use minicore::*;
#[target_feature(enable = "zdinx")]
//~^ERROR: cannot be enabled with

View file

@ -1,5 +1,5 @@
error: target feature `zfinx` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
--> $DIR/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs:17:18
--> $DIR/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs:12:18
|
LL | #[target_feature(enable = "zdinx")]
| ^^^^^^^^^^^^^^^^

View file

@ -1,18 +1,13 @@
//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib
//@ needs-llvm-components: x86
//@ check-pass
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#![allow(unexpected_cfgs)]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
// complains about the missing macro rather than showing the error... but that's good enough.

View file

@ -2,17 +2,12 @@
//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib
//@ needs-llvm-components: riscv
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
#[target_feature(enable = "forced-atomics")]
//~^ERROR: cannot be enabled with

View file

@ -1,5 +1,5 @@
error: target feature `forced-atomics` cannot be enabled with `#[target_feature]`: unsound because it changes the ABI of atomic operations
--> $DIR/forbidden-target-feature-attribute.rs:17:18
--> $DIR/forbidden-target-feature-attribute.rs:12:18
|
LL | #[target_feature(enable = "forced-atomics")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -3,18 +3,13 @@
//@ needs-llvm-components: riscv
//@ check-pass
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#![allow(unexpected_cfgs)]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this
// complains about the missing macro rather than showing the error... but that's good enough.

View file

@ -5,17 +5,12 @@
// For now this is just a warning.
//@ build-pass
//@ ignore-backends: gcc
//@ add-core-stubs
#![feature(no_core, lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
//~? WARN target feature `forced-atomics` cannot be disabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations

View file

@ -5,17 +5,12 @@
// For now this is just a warning.
//@ build-pass
//@ ignore-backends: gcc
//@ add-core-stubs
#![feature(no_core, lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
//~? WARN target feature `forced-atomics` cannot be enabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations

View file

@ -7,7 +7,7 @@
//@ build-pass
#![no_core]
#![crate_type = "rlib"]
#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)]
#![feature(intrinsics, rustc_attrs, no_core, staged_api)]
#![stable(feature = "test", since = "1.0.0")]
extern crate minicore;

View file

@ -4,17 +4,12 @@
// For now this is just a warning.
//@ build-pass
//@ ignore-backends: gcc
//@ add-core-stubs
#![feature(no_core, lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
//~? WARN target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly

View file

@ -12,17 +12,12 @@
//@ [four] build-pass
//@ [four] compile-flags: -C target-feature=-paca,+pacg -C target-feature=+paca
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
fn main() {}

View file

@ -4,17 +4,12 @@
//@[paca] compile-flags: -Ctarget-feature=+paca
//@[pacg] compile-flags: -Ctarget-feature=+pacg
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
// In this test, demonstrate that +paca and +pacg both result in the tied feature error if there
// isn't something causing an error.

View file

@ -4,18 +4,13 @@
//@[paca] compile-flags: -Ctarget-feature=+paca
//@[pacg] compile-flags: -Ctarget-feature=+pacg
//@ ignore-backends: gcc
//@ add-core-stubs
#![feature(no_core, lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "pointee_sized"]
pub trait PointeeSized {}
#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}
#[lang = "sized"]
pub trait Sized: MetaSized {}
extern crate minicore;
use minicore::*;
// 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

View file

@ -2,7 +2,8 @@
//@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu
//@ needs-llvm-components: aarch64
//@ ignore-backends: gcc
#![feature(no_core, lang_items)]
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
extern crate minicore;

View file

@ -1,5 +1,5 @@
error: the target features paca, pacg must all be either enabled or disabled together
--> $DIR/tied-features.rs:12:5
--> $DIR/tied-features.rs:13:5
|
LL | #[target_feature(enable = "pacg")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[target_feature(enable = "pacg")]
= help: add the missing features in a `target_feature` attribute
error: the target features paca, pacg must all be either enabled or disabled together
--> $DIR/tied-features.rs:24:1
--> $DIR/tied-features.rs:25:1
|
LL | #[target_feature(enable = "paca")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -15,7 +15,7 @@ LL | #[target_feature(enable = "paca")]
= help: add the missing features in a `target_feature` attribute
error: the target features paca, pacg must all be either enabled or disabled together
--> $DIR/tied-features.rs:37:1
--> $DIR/tied-features.rs:38:1
|
LL | #[target_feature(enable = "paca")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^