[−][src]Struct rustc_privacy::EmbargoVisitor
The embargo visitor, used to determine the exports of the AST.
Fields
tcx: TyCtxt<'tcx>access_levels: AccessLevelsAccessibility levels for reachable nodes.
macro_reachable: FxHashSet<(HirId, DefId)>A set of pairs corresponding to modules, where the first module is reachable via a macro that's defined in the second module. This cannot be represented as reachable because it can't handle the following case:
pub mod n { // Should be Public
pub(crate) mod p { // Should not be accessible
pub fn f() -> i32 { 12 } // Must be Reachable
}
}
pub macro m() {
n::p::f()
}
prev_level: Option<AccessLevel>Previous accessibility level; None means unreachable.
changed: boolHas something changed in the level map?
Implementations
impl<'tcx> EmbargoVisitor<'tcx>[src]
pub(crate) fn get(&self, id: HirId) -> Option<AccessLevel>[src]
pub(crate) fn update(
&mut self,
id: HirId,
level: Option<AccessLevel>
) -> Option<AccessLevel>[src]
&mut self,
id: HirId,
level: Option<AccessLevel>
) -> Option<AccessLevel>
Updates node level and returns the updated level.
pub(crate) fn reach(
&mut self,
item_id: HirId,
access_level: Option<AccessLevel>
) -> ReachEverythingInTheInterfaceVisitor<'_, 'tcx>[src]
&mut self,
item_id: HirId,
access_level: Option<AccessLevel>
) -> ReachEverythingInTheInterfaceVisitor<'_, 'tcx>
pub(crate) fn update_macro_reachable(
&mut self,
reachable_mod: HirId,
defining_mod: DefId
) -> bool[src]
&mut self,
reachable_mod: HirId,
defining_mod: DefId
) -> bool
Updates the item as being reachable through a macro defined in the given
module. Returns true if the level has changed.
pub(crate) fn update_macro_reachable_mod(
&mut self,
reachable_mod: HirId,
defining_mod: DefId
)[src]
&mut self,
reachable_mod: HirId,
defining_mod: DefId
)
pub(crate) fn update_macro_reachable_def(
&mut self,
hir_id: HirId,
def_kind: DefKind,
vis: Visibility,
module: DefId
)[src]
&mut self,
hir_id: HirId,
def_kind: DefKind,
vis: Visibility,
module: DefId
)
pub(crate) fn update_visibility_of_intermediate_use_statements(
&mut self,
segments: &[PathSegment<'_>]
)[src]
&mut self,
segments: &[PathSegment<'_>]
)
Given the path segments of a ItemKind::Use, then we need
to update the visibility of the intermediate use so that it isn't linted
by unreachable_pub.
This isn't trivial as path.res has the DefId of the eventual target
of the use statement not of the next intermediate use statement.
To do this, consider the last two segments of the path to our intermediate use statement. We expect the penultimate segment to be a module and the last segment to be the name of the item we are exporting. We can then look at the items contained in the module for the use statement with that name and update that item's visibility.
FIXME: This solution won't work with glob imports and doesn't respect namespaces. See https://github.com/rust-lang/rust/pull/57922#discussion_r251234202.
Trait Implementations
impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx>[src]
type Map = Map<'tcx>
pub fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map>[src]
We want to visit items in the context of their containing module and so forth, so supply a crate for doing a deep walk.
pub fn visit_item(&mut self, item: &'tcx Item<'tcx>)[src]
pub fn visit_block(&mut self, b: &'tcx Block<'tcx>)[src]
pub fn visit_mod(&mut self, m: &'tcx Mod<'tcx>, _sp: Span, id: HirId)[src]
pub fn visit_macro_def(&mut self, md: &'tcx MacroDef<'tcx>)[src]
pub fn visit_nested_item(&mut self, id: ItemId)[src]
pub fn visit_nested_trait_item(&mut self, id: TraitItemId)[src]
pub fn visit_nested_impl_item(&mut self, id: ImplItemId)[src]
pub fn visit_nested_body(&mut self, id: BodyId)[src]
pub fn visit_param(&mut self, param: &'v Param<'v>)[src]
pub fn visit_body(&mut self, b: &'v Body<'v>)[src]
pub fn as_deep_visitor(&mut self) -> DeepVisitor<'_, Self>[src]
pub fn visit_id(&mut self, _hir_id: HirId)[src]
pub fn visit_name(&mut self, _span: Span, _name: Symbol)[src]
pub fn visit_ident(&mut self, ident: Ident)[src]
pub fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>)[src]
pub fn visit_local(&mut self, l: &'v Local<'v>)[src]
pub fn visit_stmt(&mut self, s: &'v Stmt<'v>)[src]
pub fn visit_arm(&mut self, a: &'v Arm<'v>)[src]
pub fn visit_pat(&mut self, p: &'v Pat<'v>)[src]
pub fn visit_anon_const(&mut self, c: &'v AnonConst)[src]
pub fn visit_expr(&mut self, ex: &'v Expr<'v>)[src]
pub fn visit_ty(&mut self, t: &'v Ty<'v>)[src]
pub fn visit_generic_param(&mut self, p: &'v GenericParam<'v>)[src]
pub fn visit_generics(&mut self, g: &'v Generics<'v>)[src]
pub fn visit_where_predicate(&mut self, predicate: &'v WherePredicate<'v>)[src]
pub fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>)[src]
pub fn visit_fn(
&mut self,
fk: FnKind<'v>,
fd: &'v FnDecl<'v>,
b: BodyId,
s: Span,
id: HirId
)[src]
&mut self,
fk: FnKind<'v>,
fd: &'v FnDecl<'v>,
b: BodyId,
s: Span,
id: HirId
)
pub fn visit_use(&mut self, path: &'v Path<'v>, hir_id: HirId)[src]
pub fn visit_trait_item(&mut self, ti: &'v TraitItem<'v>)[src]
pub fn visit_trait_item_ref(&mut self, ii: &'v TraitItemRef)[src]
pub fn visit_impl_item(&mut self, ii: &'v ImplItem<'v>)[src]
pub fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef<'v>)[src]
pub fn visit_trait_ref(&mut self, t: &'v TraitRef<'v>)[src]
pub fn visit_param_bound(&mut self, bounds: &'v GenericBound<'v>)[src]
pub fn visit_poly_trait_ref(
&mut self,
t: &'v PolyTraitRef<'v>,
m: TraitBoundModifier
)[src]
&mut self,
t: &'v PolyTraitRef<'v>,
m: TraitBoundModifier
)
pub fn visit_variant_data(
&mut self,
s: &'v VariantData<'v>,
Symbol,
&'v Generics<'v>,
_parent_id: HirId,
Span
)[src]
&mut self,
s: &'v VariantData<'v>,
Symbol,
&'v Generics<'v>,
_parent_id: HirId,
Span
)
pub fn visit_struct_field(&mut self, s: &'v StructField<'v>)[src]
pub fn visit_enum_def(
&mut self,
enum_definition: &'v EnumDef<'v>,
generics: &'v Generics<'v>,
item_id: HirId,
Span
)[src]
&mut self,
enum_definition: &'v EnumDef<'v>,
generics: &'v Generics<'v>,
item_id: HirId,
Span
)
pub fn visit_variant(
&mut self,
v: &'v Variant<'v>,
g: &'v Generics<'v>,
item_id: HirId
)[src]
&mut self,
v: &'v Variant<'v>,
g: &'v Generics<'v>,
item_id: HirId
)
pub fn visit_label(&mut self, label: &'v Label)[src]
pub fn visit_generic_arg(&mut self, generic_arg: &'v GenericArg<'v>)[src]
pub fn visit_lifetime(&mut self, lifetime: &'v Lifetime)[src]
pub fn visit_qpath(&mut self, qpath: &'v QPath<'v>, id: HirId, span: Span)[src]
pub fn visit_path(&mut self, path: &'v Path<'v>, _id: HirId)[src]
pub fn visit_path_segment(
&mut self,
path_span: Span,
path_segment: &'v PathSegment<'v>
)[src]
&mut self,
path_span: Span,
path_segment: &'v PathSegment<'v>
)
pub fn visit_generic_args(
&mut self,
path_span: Span,
generic_args: &'v GenericArgs<'v>
)[src]
&mut self,
path_span: Span,
generic_args: &'v GenericArgs<'v>
)
pub fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding<'v>)[src]
pub fn visit_attribute(&mut self, _attr: &'v Attribute)[src]
pub fn visit_vis(&mut self, vis: &'v Spanned<VisibilityKind<'v>>)[src]
pub fn visit_associated_item_kind(&mut self, kind: &'v AssocItemKind)[src]
pub fn visit_defaultness(&mut self, defaultness: &'v Defaultness)[src]
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for EmbargoVisitor<'tcx>
impl<'tcx> !Send for EmbargoVisitor<'tcx>
impl<'tcx> !Sync for EmbargoVisitor<'tcx>
impl<'tcx> Unpin for EmbargoVisitor<'tcx>
impl<'tcx> !UnwindSafe for EmbargoVisitor<'tcx>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,