Rollup merge of #97301 - semicoleon:unstable-reexport, r=petrochenkov
Allow unstable items to be re-exported unstably without requiring the feature be enabled Closes #94972 The diagnostic may need some work still, and I haven't added a test yet
This commit is contained in:
commit
2035b50d80
6 changed files with 174 additions and 11 deletions
30
src/test/ui/stability-attribute/allow-unstable-reexport.rs
Normal file
30
src/test/ui/stability-attribute/allow-unstable-reexport.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Allow an unstable re-export without requiring a feature gate.
|
||||
// #94972
|
||||
|
||||
// aux-build:lint-stability.rs
|
||||
// aux-build:lint-stability-reexport.rs
|
||||
#![feature(staged_api)]
|
||||
#![stable(feature = "lint_stability", since = "1.0.0")]
|
||||
|
||||
extern crate lint_stability;
|
||||
extern crate lint_stability_reexport;
|
||||
|
||||
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||
pub use lint_stability::unstable;
|
||||
|
||||
// We want to confirm that using a re-export through another crate behaves
|
||||
// the same way as using an item directly
|
||||
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||
pub use lint_stability_reexport::unstable_text;
|
||||
|
||||
// Ensure items which aren't marked as unstable can't re-export unstable items
|
||||
#[stable(feature = "lint_stability", since = "1.0.0")]
|
||||
pub use lint_stability::unstable as unstable2;
|
||||
//~^ ERROR use of unstable library feature 'unstable_test_feature'
|
||||
|
||||
fn main() {
|
||||
// Since we didn't enable the feature in this crate, we still can't
|
||||
// use these items, even though they're in scope from the `use`s which are now allowed.
|
||||
unstable(); //~ ERROR use of unstable library feature 'unstable_test_feature'
|
||||
unstable_text(); //~ ERROR use of unstable library feature 'unstable_test_feature'
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
||||
--> $DIR/allow-unstable-reexport.rs:22:9
|
||||
|
|
||||
LL | pub use lint_stability::unstable as unstable2;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of unstable library feature 'unstable_test_feature'
|
||||
--> $DIR/allow-unstable-reexport.rs:28:5
|
||||
|
|
||||
LL | unstable();
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of unstable library feature 'unstable_test_feature': text
|
||||
--> $DIR/allow-unstable-reexport.rs:29:5
|
||||
|
|
||||
LL | unstable_text();
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#![crate_type = "lib"]
|
||||
#![feature(staged_api)]
|
||||
#![stable(feature = "lint_stability", since = "1.0.0")]
|
||||
|
||||
extern crate lint_stability;
|
||||
|
||||
// Re-exporting without enabling the feature "unstable_test_feature" in this crate
|
||||
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||
pub use lint_stability::unstable_text;
|
||||
Loading…
Add table
Add a link
Reference in a new issue