]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_resolve/lib.rs
Add E0603 error code
[rust.git] / src / librustc_resolve / lib.rs
index f1be821d526e17151a3ffa1d452c0eea08278940..b23cce6d4251af7e65433040867b6bd56b47ae7f 100644 (file)
@@ -1069,6 +1069,10 @@ fn is_macro_def(&self) -> bool {
             _ => false,
         }
     }
+
+    fn descr(&self) -> &'static str {
+        if self.is_extern_crate() { "extern crate" } else { self.def().kind_name() }
+    }
 }
 
 /// Interns the names of the primitive types.
@@ -3424,18 +3428,7 @@ fn report_errors(&mut self) {
 
         for &PrivacyError(span, name, binding) in &self.privacy_errors {
             if !reported_spans.insert(span) { continue }
-            if binding.is_extern_crate() {
-                // Warn when using an inaccessible extern crate.
-                let node_id = match binding.kind {
-                    NameBindingKind::Import { directive, .. } => directive.id,
-                    _ => unreachable!(),
-                };
-                let msg = format!("extern crate `{}` is private", name);
-                self.session.add_lint(lint::builtin::INACCESSIBLE_EXTERN_CRATE, node_id, span, msg);
-            } else {
-                let def = binding.def();
-                self.session.span_err(span, &format!("{} `{}` is private", def.kind_name(), name));
-            }
+            span_err!(self.session, span, E0603, "{} `{}` is private", binding.descr(), name);
         }
     }