Skip to content

Commit

Permalink
Add test for mixed stability levels
Browse files Browse the repository at this point in the history
  • Loading branch information
dianne committed Oct 23, 2024
1 parent 00e8a6b commit 0a730d9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/ui/stability-attribute/auxiliary/mixed-levels.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! definitions for ../mixed-levels.rs

#![stable(feature = "stable_feature", since = "1.0.0")]
#![feature(staged_api)]
#![crate_type = "lib"]

#[stable(feature = "stable_a", since = "1.0.0")]
#[stable(feature = "stable_b", since = "1.8.2")]
#[macro_export]
macro_rules! stable_mac {
() => ()
}

#[unstable(feature = "unstable_a", issue = "none")]
#[stable(feature = "stable_a", since = "1.0.0")]
#[macro_export]
macro_rules! unstable_mac {
() => ()
}

#[stable(feature = "stable_feature", since = "1.0.0")]
#[rustc_const_stable(feature = "stable_c", since = "1.8.2")]
#[rustc_const_stable(feature = "stable_d", since = "1.0.0")]
pub const fn const_stable_fn() {}

#[stable(feature = "stable_feature", since = "1.0.0")]
#[rustc_const_unstable(feature = "unstable_c", issue = "none")]
#[rustc_const_stable(feature = "stable_c", since = "1.8.2")]
pub const fn const_unstable_fn() {}
13 changes: 13 additions & 0 deletions tests/ui/stability-attribute/mixed-levels.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Test stability levels for items formerly dependent on multiple unstable features.
//@ aux-build:mixed-levels.rs

extern crate mixed_levels;

const USE_STABLE: () = mixed_levels::const_stable_fn();
const USE_UNSTABLE: () = mixed_levels::const_unstable_fn();
//~^ ERROR `const_unstable_fn` is not yet stable as a const fn

fn main() {
mixed_levels::stable_mac!();
mixed_levels::unstable_mac!(); //~ ERROR use of unstable library feature `unstable_a` [E0658]
}
22 changes: 22 additions & 0 deletions tests/ui/stability-attribute/mixed-levels.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0658]: use of unstable library feature `unstable_a`
--> $DIR/mixed-levels.rs:12:5
|
LL | mixed_levels::unstable_mac!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(unstable_a)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: `const_unstable_fn` is not yet stable as a const fn
--> $DIR/mixed-levels.rs:7:26
|
LL | const USE_UNSTABLE: () = mixed_levels::const_unstable_fn();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use of unstable library feature `unstable_c`
= help: add `#![feature(unstable_c)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

0 comments on commit 0a730d9

Please sign in to comment.