Crate rustc_privacy

source ·

Modules

errors 🔒

Structs

The embargo visitor, used to determine the exports of the AST.
FindMin 🔒
Visitor used to determine impl visibility and reachability.
Name privacy visitor, checks privacy and reports violations. Most of name privacy checks are performed during the main resolution phase, or later in type checking when field accesses and associated items are resolved. This pass performs remaining checks for fields in struct expressions and patterns.
Obsolete visitors for checking for private items in public interfaces. These visitors are supposed to be kept in frozen state and produce an “old error node set”. For backward compatibility the new visitor reports warnings instead of hard errors when the erroneous node is not in this old set.
SearchInterfaceForPrivateItemsVisitor traverses an item’s interface and finds any private components in it. PrivateItemsInPublicInterfacesVisitor ensures there are no private types and traits in public interfaces.
Visitor, used for AccessLevels table checking
Type privacy visitor, checks types for privacy and reports violations. Both explicitly written types and inferred types of expressions and patterns are checked. Checks are performed on “semantic” types regardless of names and their hygiene.

Traits

Generic infrastructure used to implement specific visitors below. Implemented to visit all DefIds in a type. Visiting DefIds is useful because visibilities and reachabilities are attached to them. The idea is to visit “all components of a type”, as documented in https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md#how-to-determine-visibility-of-a-type. The default type visitor (TypeVisitor) does most of the job, but it has some shortcomings. First, it doesn’t have overridable fn visit_trait_ref, so we have to catch trait DefIds manually. Second, it doesn’t visit some type components like signatures of fn types, or traits in impl Trait, see individual comments in DefIdVisitorSkeleton::visit_ty.

Functions