fn visit_qpath(&mut self, qpath: &'tcx hir::QPath<'tcx>, id: hir::HirId, span: Span) {
        let def = match qpath {
            hir::QPath::Resolved(_, path) => match path.res {
                Res::Def(kind, def_id) => Some((kind, def_id)),
                _ => None,
            },
            hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
                .maybe_typeck_results
                .and_then(|typeck_results| typeck_results.type_dependent_def(id)),
        };
        let def = def.filter(|(kind, _)| {
            matches!(
                kind,
                DefKind::AssocFn | DefKind::AssocConst | DefKind::AssocTy | DefKind::Static
            )
        });
        if let Some((kind, def_id)) = def {
            let is_local_static =
                if let DefKind::Static = kind { def_id.is_local() } else { false };
            if !self.item_is_accessible(def_id) && !is_local_static {
                let sess = self.tcx.sess;
                let sm = sess.source_map();
                let name = match qpath {
                    hir::QPath::Resolved(..) | hir::QPath::LangItem(..) => {
                        sm.span_to_snippet(qpath.span()).ok()
                    }
                    hir::QPath::TypeRelative(_, segment) => Some(segment.ident.to_string()),
                };
                let kind = kind.descr(def_id);
                let msg = match name {
                    Some(name) => format!("{} `{}` is private", kind, name),
                    None => format!("{} is private", kind),
                };
                sess.struct_span_err(span, &msg)
                    .span_label(span, &format!("private {}", kind))
                    .emit();
                return;
            }
        }

        intravisit::walk_qpath(self, qpath, id, span);
    }
// Prohibit access to associated items with insufficient nominal visibility.
//
// Additionally, until better reachability analysis for macros 2.0 is available,
// we prohibit access to private statics from other crates, this allows to give
// more code internal visibility at link time. (Access to private functions
// is already prohibited by type privacy for function types.)
Prohibit access to associated items with insufficient nominal visibility.
Additionally, until better reachability analysis for macros 2.0 is available,
we prohibit access to private statics from other crates, this allows to give
more code internal visibility at link time. (Access to private functions
is already prohibited by type privacy for function types.)
Prohibit access to associated items with insufficient nominal visibility . Additionally until better reachability analysis for macros 2 . 0 is available we prohibit access to private statics from other crates this allows to give more code internal visibility at link time . ( Access to private functions is already prohibited by type privacy for function types . )
fn visit_qpath(&mut self, qpath: &'tcx hir::QPath<'tcx>, id: hir::HirId, span: Span) {
        let def = match qpath {
            hir::QPath::Resolved(_, path) => match path.res {
                Res::Def(kind, def_id) => Some((kind, def_id)),
                _ => None,
            },
            hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
                .maybe_typeck_results
                .and_then(|typeck_results| typeck_results.type_dependent_def(id)),
        };
        let def = def.filter(|(kind, _)| {
            matches!(
                kind,
                DefKind::AssocFn | DefKind::AssocConst | DefKind::AssocTy | DefKind::Static
            )
        });
        if let Some((kind, def_id)) = def {
            let is_local_static =
                if let DefKind::Static = kind { def_id.is_local() } else { false };
            if !self.item_is_accessible(def_id) && !is_local_static {
                let sess = self.tcx.sess;
                let sm = sess.source_map();
                let name = match qpath {
                    hir::QPath::Resolved(..) | hir::QPath::LangItem(..) => {
                        sm.span_to_snippet(qpath.span()).ok()
                    }
                    hir::QPath::TypeRelative(_, segment) => Some(segment.ident.to_string()),
                };
                let kind = kind.descr(def_id);
                let msg = match name {
                    Some(name) => format!("{} `{}` is private", kind, name),
                    None => format!("{} is private", kind),
                };
                sess.struct_span_err(span, &msg)
                    .span_label(span, &format!("private {}", kind))
                    .emit();
                return;
            }
        }
        intravisit::walk_qpath(self, qpath, id, span);
    }
fn visit_qpath ( & mut self , qpath : & ' tcx hir :: QPath < ' tcx > , id : hir :: HirId , span : Span ) { let def = match qpath { hir :: QPath :: Resolved ( _ , path ) => match path . res { Res :: Def ( kind , def_id ) => Some ( ( kind , def_id ) ) , _ => None , } , hir :: QPath :: TypeRelative ( .. ) | hir :: QPath :: LangItem ( .. ) => self . maybe_typeck_results . and_then ( | typeck_results | typeck_results . type_dependent_def ( id ) ) , } ; let def = def . filter ( | ( kind , _ ) | { matches ! ( kind DefKind AssocFn DefKind AssocConst DefKind AssocTy DefKind Static ) } ) ; if let Some ( ( kind , def_id ) ) = def { let is_local_static = if let DefKind :: Static = kind { def_id . is_local ( ) } else { false } ; if ! self . item_is_accessible ( def_id ) && ! is_local_static { let sess = self . tcx . sess ; let sm = sess . source_map ( ) ; let name = match qpath { hir :: QPath :: Resolved ( .. ) | hir :: QPath :: LangItem ( .. ) => { sm . span_to_snippet ( qpath . span ( ) ) . ok ( ) } hir :: QPath :: TypeRelative ( _ , segment ) => Some ( segment . ident . to_string ( ) ) , } ; let kind = kind . descr ( def_id ) ; let msg = match name { Some ( name ) => format ! ( " " kind name ) , None => format ! ( " " kind ) , } ; sess . struct_span_err ( span , & msg ) . span_label ( span , & format ! ( " " kind ) ) . emit ( ) ; return ; } } intravisit :: walk_qpath ( self , qpath , id , span ) ; }
Prohibit access to associated items with insufficient nominal visibility.
Prohibit access to associated items with insufficient nominal visibility .
&mut self
qpath
&'tcx hir::QPath<'tcx>
id
hir::HirId
span
Span
&mut self
qpath
&'tcx hir::QPath<'tcx>
id
hir::HirId
span
Span