-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow unstable items to be re-exported unstably without requiring the feature be enabled #97301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.