From b5d9ac6c5ad47647f9c80b4e61029d3004625d63 Mon Sep 17 00:00:00 2001 From: dianne Date: Tue, 22 Oct 2024 19:28:33 -0700 Subject: [PATCH] Add test for mixed stability levels --- .../auxiliary/mixed-levels.rs | 29 +++++++++++++++++++ tests/ui/stability-attribute/mixed-levels.rs | 13 +++++++++ .../stability-attribute/mixed-levels.stderr | 22 ++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 tests/ui/stability-attribute/auxiliary/mixed-levels.rs create mode 100644 tests/ui/stability-attribute/mixed-levels.rs create mode 100644 tests/ui/stability-attribute/mixed-levels.stderr diff --git a/tests/ui/stability-attribute/auxiliary/mixed-levels.rs b/tests/ui/stability-attribute/auxiliary/mixed-levels.rs new file mode 100644 index 0000000000000..0e8a6b8917d1e --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/mixed-levels.rs @@ -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() {} diff --git a/tests/ui/stability-attribute/mixed-levels.rs b/tests/ui/stability-attribute/mixed-levels.rs new file mode 100644 index 0000000000000..6948dc174afae --- /dev/null +++ b/tests/ui/stability-attribute/mixed-levels.rs @@ -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] +} diff --git a/tests/ui/stability-attribute/mixed-levels.stderr b/tests/ui/stability-attribute/mixed-levels.stderr new file mode 100644 index 0000000000000..3d3e26f4e08a8 --- /dev/null +++ b/tests/ui/stability-attribute/mixed-levels.stderr @@ -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`.