Skip to content

Commit 1397678

Browse files
committed
rustc: riscv: add tests for cfg-only stable features
1 parent c2571ea commit 1397678

4 files changed

Lines changed: 67 additions & 0 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Ensure cfg-only stable target_features trigger errors when enabled via attribute.
2+
//@ compile-flags: --crate-type=lib
3+
//@ compile-flags: --target=riscv64gc-unknown-none-elf
4+
//@ needs-llvm-components: riscv
5+
//@ add-minicore
6+
//@ ignore-backends: gcc
7+
#![feature(no_core)]
8+
#![no_core]
9+
10+
extern crate minicore;
11+
use minicore::*;
12+
13+
#[target_feature(enable = "v")]
14+
//~^ERROR: the target feature `v` is currently unstable
15+
#[target_feature(enable = "f")]
16+
//~^ERROR: the target feature `f` is allowed in cfg but unstable otherwise
17+
pub unsafe fn my_fun() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0658]: the target feature `v` is currently unstable
2+
--> $DIR/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs:13:18
3+
|
4+
LL | #[target_feature(enable = "v")]
5+
| ^^^^^^^^^^^^
6+
|
7+
= note: see issue #150257 <https://github.com/rust-lang/rust/issues/150257> for more information
8+
= help: add `#![feature(riscv_target_feature)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: the target feature `f` is allowed in cfg but unstable otherwise
12+
--> $DIR/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs:15:18
13+
|
14+
LL | #[target_feature(enable = "f")]
15+
| ^^^^^^^^^^^^
16+
|
17+
= note: see issue #150257 <https://github.com/rust-lang/rust/issues/150257> for more information
18+
= help: add `#![feature(riscv_target_feature)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Ensure cfg-only stable target_features trigger warnings when enabled via compile flag.
2+
//@ check-pass
3+
//@ compile-flags: --crate-type=lib
4+
//@ compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=+v -Ctarget-feature=+f
5+
// FIXME(#147881): *disable* the feature again for minicore as otherwise that will fail to build.
6+
//@ minicore-compile-flags: -Ctarget-feature=-v -Ctarget-feature=-f
7+
//@ needs-llvm-components: riscv
8+
//@ ignore-backends: gcc
9+
//@ add-minicore
10+
#![feature(no_core)]
11+
#![no_core]
12+
13+
extern crate minicore;
14+
use minicore::*;
15+
16+
//~? WARN unstable feature specified for `-Ctarget-feature`
17+
//~? WARN unstable feature specified for `-Ctarget-feature`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: unstable feature specified for `-Ctarget-feature`: `v`
2+
|
3+
= note: this feature is not stably supported; its behavior can change in the future
4+
5+
warning: unstable feature specified for `-Ctarget-feature`: `f`
6+
|
7+
= note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future
8+
9+
warning: 2 warnings emitted
10+

0 commit comments

Comments
 (0)