]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/session/mod.rs
Add new error code
[rust.git] / src / librustc / session / mod.rs
index 814246330a4c2f7b8da5e640ebbb536c83910423..827fa72f034045e90701bc34d8679a4745c7c35c 100644 (file)
@@ -11,8 +11,9 @@
 pub use self::code_stats::{CodeStats, DataTypeKind, FieldInfo};
 pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo};
 
-use dep_graph::{DepGraph, DepNode};
-use hir::def_id::{DefId, CrateNum, DefIndex, CRATE_DEF_INDEX};
+use dep_graph::DepGraph;
+use hir::def_id::{CrateNum, DefIndex};
+
 use lint;
 use middle::cstore::CrateStore;
 use middle::dependency_format;
@@ -32,7 +33,7 @@
 use syntax::symbol::Symbol;
 use syntax::{ast, codemap};
 use syntax::feature_gate::AttributeType;
-use syntax_pos::{Span, MultiSpan, FileMap};
+use syntax_pos::{Span, MultiSpan};
 
 use rustc_back::{LinkerFlavor, PanicStrategy};
 use rustc_back::target::Target;
@@ -46,7 +47,6 @@
 use std::rc::Rc;
 use std::fmt;
 use std::time::Duration;
-use std::sync::Arc;
 
 mod code_stats;
 pub mod config;
@@ -158,14 +158,14 @@ pub fn local_crate_disambiguator(&self) -> Symbol {
     pub fn struct_span_warn<'a, S: Into<MultiSpan>>(&'a self,
                                                     sp: S,
                                                     msg: &str)
-                                                    -> DiagnosticBuilder<'a>  {
+                                                    -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_span_warn(sp, msg)
     }
     pub fn struct_span_warn_with_code<'a, S: Into<MultiSpan>>(&'a self,
                                                               sp: S,
                                                               msg: &str,
                                                               code: &str)
-                                                              -> DiagnosticBuilder<'a>  {
+                                                              -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_span_warn_with_code(sp, msg, code)
     }
     pub fn struct_warn<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a>  {
@@ -174,30 +174,34 @@ pub fn struct_warn<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a>  {
     pub fn struct_span_err<'a, S: Into<MultiSpan>>(&'a self,
                                                    sp: S,
                                                    msg: &str)
-                                                   -> DiagnosticBuilder<'a>  {
+                                                   -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_span_err(sp, msg)
     }
     pub fn struct_span_err_with_code<'a, S: Into<MultiSpan>>(&'a self,
                                                              sp: S,
                                                              msg: &str,
                                                              code: &str)
-                                                             -> DiagnosticBuilder<'a>  {
+                                                             -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_span_err_with_code(sp, msg, code)
     }
-    pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a>  {
+    // FIXME: This method should be removed (every error should have an associated error code).
+    pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_err(msg)
     }
+    pub fn struct_err_with_code<'a>(&'a self, msg: &str, code: &str) -> DiagnosticBuilder<'a> {
+        self.diagnostic().struct_err_with_code(msg, code)
+    }
     pub fn struct_span_fatal<'a, S: Into<MultiSpan>>(&'a self,
                                                      sp: S,
                                                      msg: &str)
-                                                     -> DiagnosticBuilder<'a>  {
+                                                     -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_span_fatal(sp, msg)
     }
     pub fn struct_span_fatal_with_code<'a, S: Into<MultiSpan>>(&'a self,
                                                                sp: S,
                                                                msg: &str,
                                                                code: &str)
-                                                               -> DiagnosticBuilder<'a>  {
+                                                               -> DiagnosticBuilder<'a> {
         self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
     }
     pub fn struct_fatal<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a>  {
@@ -626,21 +630,6 @@ pub fn build_session_(sopts: config::Options,
     };
     let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
 
-    // Hook up the codemap with a callback that allows it to register FileMap
-    // accesses with the dependency graph.
-    let cm_depgraph = dep_graph.clone();
-    let codemap_dep_tracking_callback = Box::new(move |filemap: &FileMap| {
-        let def_id = DefId {
-            krate: CrateNum::from_u32(filemap.crate_of_origin),
-            index: CRATE_DEF_INDEX,
-        };
-        let name = Arc::new(filemap.name.clone());
-        let dep_node = DepNode::FileMap(def_id, name);
-
-        cm_depgraph.read(dep_node);
-    });
-    codemap.set_dep_tracking_callback(codemap_dep_tracking_callback);
-
     let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
     let default_sysroot = match sopts.maybe_sysroot {
         Some(_) => None,