]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/ty/context.rs
Make the definite name of the local crate available in the tcx.
[rust.git] / src / librustc / middle / ty / context.rs
index 03c13115aea626fc91fc16747cbe1326594619f0..4e81297a789a849536d4cf72c06b79985b4df2aa 100644 (file)
@@ -43,7 +43,7 @@
 use std::rc::Rc;
 use syntax::ast::{self, Name, NodeId};
 use syntax::attr;
-use syntax::parse::token::special_idents;
+use syntax::parse::token::{self, special_idents};
 
 use rustc_front::hir;
 
@@ -415,6 +415,10 @@ pub struct TyCtxt<'tcx> {
     /// fragmented data to the set of unfragmented pieces that
     /// constitute it.
     pub fragment_infos: RefCell<DefIdMap<Vec<ty::FragmentInfo>>>,
+
+    /// The definite name of the current crate after taking into account
+    /// attributes, commandline parameters, etc.
+    pub crate_name: token::InternedString,
 }
 
 impl<'tcx> TyCtxt<'tcx> {
@@ -511,6 +515,7 @@ pub fn create_and_enter<F, R>(s: &'tcx Session,
                                  region_maps: RegionMaps,
                                  lang_items: middle::lang_items::LanguageItems,
                                  stability: stability::Index<'tcx>,
+                                 crate_name: &str,
                                  f: F) -> R
                                  where F: FnOnce(&TyCtxt<'tcx>) -> R
     {
@@ -570,7 +575,8 @@ pub fn create_and_enter<F, R>(s: &'tcx Session,
             const_qualif_map: RefCell::new(NodeMap()),
             custom_coerce_unsized_kinds: RefCell::new(DefIdMap()),
             cast_kinds: RefCell::new(NodeMap()),
-            fragment_infos: RefCell::new(DefIdMap())
+            fragment_infos: RefCell::new(DefIdMap()),
+            crate_name: token::intern_and_get_ident(crate_name),
        }, f)
     }
 }