@@ -41,9 +41,6 @@ use rustc::lint;
4141use rustc:: middle:: def:: { self , Def } ;
4242use rustc:: middle:: def_id:: DefId ;
4343use rustc:: middle:: privacy:: { AccessLevel , AccessLevels } ;
44- use rustc:: middle:: privacy:: ImportUse :: * ;
45- use rustc:: middle:: privacy:: LastPrivate :: * ;
46- use rustc:: middle:: privacy:: PrivateDep :: * ;
4744use rustc:: middle:: privacy:: ExternalExports ;
4845use rustc:: middle:: ty;
4946use rustc:: util:: nodemap:: { NodeMap , NodeSet } ;
@@ -718,7 +715,6 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
718715 source_did : Option < DefId > ,
719716 msg : & str )
720717 -> CheckResult {
721- use rustc_front:: hir:: Item_ :: ItemExternCrate ;
722718 debug ! ( "ensure_public(span={:?}, to_check={:?}, source_did={:?}, msg={:?})" ,
723719 span, to_check, source_did, msg) ;
724720 let def_privacy = self . def_privacy ( to_check) ;
@@ -740,20 +736,6 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
740736 let def_id = source_did. unwrap_or ( to_check) ;
741737 let node_id = self . tcx . map . as_local_node_id ( def_id) ;
742738
743- // Warn when using a inaccessible extern crate.
744- if let Some ( node_id) = self . tcx . map . as_local_node_id ( to_check) {
745- match self . tcx . map . get ( node_id) {
746- ast_map:: Node :: NodeItem ( & hir:: Item { node : ItemExternCrate ( _) , name, .. } ) => {
747- self . tcx . sess . add_lint ( lint:: builtin:: INACCESSIBLE_EXTERN_CRATE ,
748- node_id,
749- span,
750- format ! ( "extern crate `{}` is private" , name) ) ;
751- return None ;
752- }
753- _ => { }
754- }
755- }
756-
757739 let ( err_span, err_msg) = if Some ( id) == node_id {
758740 return Some ( ( span, format ! ( "{} is private" , msg) , None ) ) ;
759741 } else {
@@ -842,90 +824,6 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
842824 name) ) ) ;
843825 }
844826
845- // Checks that a path is in scope.
846- fn check_path ( & mut self , span : Span , path_id : ast:: NodeId , last : ast:: Name ) {
847- debug ! ( "privacy - path {}" , self . nodestr( path_id) ) ;
848- let path_res = * self . tcx . def_map . borrow ( ) . get ( & path_id) . unwrap ( ) ;
849- let ck = |tyname : & str | {
850- let ck_public = |def : DefId | {
851- debug ! ( "privacy - ck_public {:?}" , def) ;
852- let origdid = path_res. def_id ( ) ;
853- self . ensure_public ( span,
854- def,
855- Some ( origdid) ,
856- & format ! ( "{} `{}`" , tyname, last) )
857- } ;
858-
859- match path_res. last_private {
860- LastMod ( AllPublic ) => { } ,
861- LastMod ( DependsOn ( def) ) => {
862- self . report_error ( ck_public ( def) ) ;
863- } ,
864- LastImport { value_priv,
865- value_used : check_value,
866- type_priv,
867- type_used : check_type } => {
868- // This dance with found_error is because we don't want to
869- // report a privacy error twice for the same directive.
870- let found_error = match ( type_priv, check_type) {
871- ( Some ( DependsOn ( def) ) , Used ) => {
872- !self . report_error ( ck_public ( def) )
873- } ,
874- _ => false ,
875- } ;
876- if !found_error {
877- match ( value_priv, check_value) {
878- ( Some ( DependsOn ( def) ) , Used ) => {
879- self . report_error ( ck_public ( def) ) ;
880- } ,
881- _ => { } ,
882- }
883- }
884- // If an import is not used in either namespace, we still
885- // want to check that it could be legal. Therefore we check
886- // in both namespaces and only report an error if both would
887- // be illegal. We only report one error, even if it is
888- // illegal to import from both namespaces.
889- match ( value_priv, check_value, type_priv, check_type) {
890- ( Some ( p) , Unused , None , _) |
891- ( None , _, Some ( p) , Unused ) => {
892- let p = match p {
893- AllPublic => None ,
894- DependsOn ( def) => ck_public ( def) ,
895- } ;
896- if p. is_some ( ) {
897- self . report_error ( p) ;
898- }
899- } ,
900- ( Some ( v) , Unused , Some ( t) , Unused ) => {
901- let v = match v {
902- AllPublic => None ,
903- DependsOn ( def) => ck_public ( def) ,
904- } ;
905- let t = match t {
906- AllPublic => None ,
907- DependsOn ( def) => ck_public ( def) ,
908- } ;
909- if let ( Some ( _) , Some ( t) ) = ( v, t) {
910- self . report_error ( Some ( t) ) ;
911- }
912- } ,
913- _ => { } ,
914- }
915- } ,
916- }
917- } ;
918- // FIXME(#12334) Imports can refer to definitions in both the type and
919- // value namespaces. The privacy information is aware of this, but the
920- // def map is not. Therefore the names we work out below will not always
921- // be accurate and we can get slightly wonky error messages (but type
922- // checking is always correct).
923- let def = path_res. full_def ( ) ;
924- if def != Def :: Err {
925- ck ( def. kind_name ( ) ) ;
926- }
927- }
928-
929827 // Checks that a method is in scope.
930828 fn check_method ( & mut self , span : Span , method_def_id : DefId ,
931829 name : ast:: Name ) {
@@ -1067,25 +965,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
1067965 intravisit:: walk_foreign_item ( self , fi) ;
1068966 self . in_foreign = false ;
1069967 }
1070-
1071- fn visit_path ( & mut self , path : & hir:: Path , id : ast:: NodeId ) {
1072- if !path. segments . is_empty ( ) {
1073- self . check_path ( path. span , id, path. segments . last ( ) . unwrap ( ) . identifier . name ) ;
1074- intravisit:: walk_path ( self , path) ;
1075- }
1076- }
1077-
1078- fn visit_path_list_item ( & mut self , prefix : & hir:: Path , item : & hir:: PathListItem ) {
1079- let name = if let hir:: PathListIdent { name, .. } = item. node {
1080- name
1081- } else if !prefix. segments . is_empty ( ) {
1082- prefix. segments . last ( ) . unwrap ( ) . identifier . name
1083- } else {
1084- self . tcx . sess . bug ( "`self` import in an import list with empty prefix" ) ;
1085- } ;
1086- self . check_path ( item. span , item. node . id ( ) , name) ;
1087- intravisit:: walk_path_list_item ( self , prefix, item) ;
1088- }
1089968}
1090969
1091970////////////////////////////////////////////////////////////////////////////////
0 commit comments