forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#97301 - semicoleon:unstable-reexport, r=pet…
…rochenkov Allow unstable items to be re-exported unstably without requiring the feature be enabled Closes rust-lang#94972 The diagnostic may need some work still, and I haven't added a test yet
- Loading branch information
Showing
6 changed files
with
174 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/ui/stability-attribute/allow-unstable-reexport.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/ui/stability-attribute/allow-unstable-reexport.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
9 changes: 9 additions & 0 deletions
9
src/test/ui/stability-attribute/auxiliary/lint-stability-reexport.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |