- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Implement pub(restricted) privacy (RFC 1422)
          #32875
        
          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
Conversation
| I didn't allow  Also,  | 
84e1cdb    to
    ef05df9      
    Compare
  
            
          
                src/librustc_resolve/lib.rs
              
                Outdated
          
        
      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 comment is no longer true after d1ef356?
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.
Indeed, fixed.
ef05df9    to
    c2ccd5b      
    Compare
  
            
          
                src/libsyntax/visit.rs
              
                Outdated
          
        
      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.
Foreign items seem to be missing.
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.
And HIR visibilities in librustc\hir\intravisit.rs are not visited.
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.
Foreign items seem to be missing.
Good catch, I'll add them.
And HIR visibilities in librustc\hir\intravisit.rs are not visited.
There's no need to visit visibilities in the HIR currently -- do you think I should add a visit_vis method in intravisit anyway?
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.
do you think I should a visit_vis method in intravisit
Yes, default visitor functions just traverse the tree exhaustively, providing, well, correct defaults.
As an example, overridden visit_paths will not visit paths in visibilities if intravisit doesn't traverse visibilities by default.
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.
Done.
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.
I've just noticed, default folders (fold.rs) have the same problems as visitors.
AST folders don't fold all visibilities and HIR folders don't fold visibilities at all.
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.
Done.
c2ccd5b    to
    358aed4      
    Compare
  
    | I rebased and addressed @petrochenkov's comments. | 
| ☔ The latest upstream changes (presumably #32814) made this pull request unmergeable. Please resolve the merge conflicts. | 
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.
Meta note: Let's make a subdirectory for these tests.
Perhaps src/test/compile-fail/privacy? If we want to further designate tests aimed at the pub(restricted) RFC, then perhaps src/test/compile-fail/privacy/restricted?
| This looks great. I suggest we move the privacy tests to a subdirectory. I want to start giving more structure to our  So, here is my matrix. I've put an  Eventually I'd like to have a system for tagging tests with what they test so we can easily construct matrices like this automatically to get some idea of test coverage. But we're not there yet. r=me with suitable tests added. | 
| @nikomatsakis | 
reexports of private variants are handled correctly.
d699383    to
    a05dd73      
    Compare
  
    | @jseyfried oh, I forgot to label those :) it was "intra-crate" and "cross-crate" | 
| @jseyfried if you want me to review add'l tests, let me know, but if you feel like you've satisfied all the interesting points in that matrix, then r=me | 
| Ok, makes sense. I'll add some more tests and r=you | 
| A note: visibilities do not expect type parameters in paths, but use  | 
the feature `pub_restricted` is enabled.
a05dd73    to
    70eb972      
    Compare
  
    70eb972    to
    e14504a      
    Compare
  
    | @petrochenkov interesting, sounds good. | 
| @bors r=nikomatsakis | 
| 📌 Commit e14504a has been approved by  | 
Implement `pub(restricted)` privacy (RFC 1422) This implements `pub(restricted)` privacy from RFC 1422 (cc #32409) behind a feature gate. `pub(restricted)` paths currently cannot use re-exported modules both for simplicity of implementation and for future compatibility with RFC 1560 (cf #31783). r? @nikomatsakis
resolve: Refactor away `DefModifiers` This refactors away `DefModifiers`, which is unneeded now that rust-lang#32875 has landed. r? @eddyb
This implements
pub(restricted)privacy from rust-lang/rfcs#1422 (cc #32409) behind a feature gate.pub(restricted)paths currently cannot use re-exported modules both for simplicity of implementation and for future compatibility with rust-lang/rfcs#1560 (cc #31783).r? @nikomatsakis