-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
resolve: Cleanup visibility resolution for enum variants and trait items #80762
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 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
11 changes: 6 additions & 5 deletions
11
src/test/ui/privacy/issue-46209-private-enum-variant-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
51 changes: 29 additions & 22 deletions
51
src/test/ui/privacy/issue-46209-private-enum-variant-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 |
---|---|---|
@@ -1,44 +1,51 @@ | ||
error: variant `JuniorGrade` is private and cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32 | ||
error[E0364]: `JuniorGrade` is private, and cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 | ||
| | ||
LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ||
| ^^^^^^^^^^^ | ||
| | ||
note: consider marking `JuniorGrade` as `pub` in the imported module | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 | ||
| | ||
LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ||
| ^^^^^^^^^^^ | ||
... | ||
LL | enum Lieutenant { | ||
| --------------- help: consider making the enum public: `pub enum Lieutenant` | ||
|
||
error: variant `Full` is private and cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:6:45 | ||
error[E0364]: `Full` is private, and cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45 | ||
| | ||
LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ||
| ^^^^ | ||
| | ||
note: consider marking `Full` as `pub` in the imported module | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45 | ||
| | ||
LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ||
| ^^^^ | ||
|
||
error: enum is private and its variants cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:4:13 | ||
error: glob import doesn't reexport anything because no candidate is public enough | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:13 | ||
| | ||
LL | pub use self::Professor::*; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | enum Professor { | ||
| -------------- help: consider making the enum public: `pub enum Professor` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:3:8 | ||
| | ||
LL | #[deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: enum is private and its variants cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:9:13 | ||
error: glob import doesn't reexport anything because no candidate is public enough | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13 | ||
| | ||
LL | pub use self::PettyOfficer::*; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | pub(in rank) enum PettyOfficer { | ||
| ------------------------------ help: consider making the enum public: `pub enum PettyOfficer` | ||
|
||
error: enum is private and its variants cannot be re-exported | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:11:13 | ||
error: glob import doesn't reexport anything because no candidate is public enough | ||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:12:13 | ||
| | ||
LL | pub use self::Crewman::*; | ||
| ^^^^^^^^^^^^^^^^ | ||
... | ||
LL | crate enum Crewman { | ||
| ------------------ help: consider making the enum public: `pub enum Crewman` | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0364`. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a change in behaviour, or is the lint taking precedence over the "enum is private" error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change in behavior, now glob import from enum with private variants behaves identically to a glob import from a module with private items.
Previously, in the world without
pub(restricted)
, this required special logic and separate error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely seems like better behaviour, but is this something that would need to undergo a lang team FCP, or is this a change that has already been discussed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe.
When the error was added in 8f359d5 (as a part of hardening private-in-public errors), the glob case wasn't really discussed.
The glob error was added pretty conservatively to seal any possible sources of leakage, but even then it was inconsistent with behavior of other glob imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's cc them just to make sure, though it's likely this isn't large enough to warrant an FCP.