]> git.lizzy.rs Git - rust.git/commitdiff
Make the definite name of the local crate available in the tcx.
authorMichael Woerister <michaelwoerister@posteo.net>
Sun, 14 Feb 2016 17:30:38 +0000 (12:30 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 25 Mar 2016 18:07:17 +0000 (14:07 -0400)
src/librustc/middle/ty/context.rs
src/librustc_driver/driver.rs
src/librustc_driver/test.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)
     }
 }
index b75ccb3f7ee8fdc59a06b8c055d725f9a67f71ed..1af01a412239ef5ed2200790527a12376bab217f 100644 (file)
@@ -818,6 +818,7 @@ macro_rules! try_with_f {
                                region_map,
                                lang_items,
                                index,
+                               name,
                                |tcx| {
         // passes are timed inside typeck
         try_with_f!(typeck::check_crate(tcx, trait_map), (tcx, None, analysis));
index 1a5e7cb54f2e3a0bb60a29bdbe5e706130330c5d..111db3b1d38908726943ee77ad4b7f198d644196 100644 (file)
@@ -146,6 +146,7 @@ fn test_env<F>(source_string: &str,
                                region_map,
                                lang_items,
                                index,
+                               "test_crate",
                                |tcx| {
                                    let infcx = infer::new_infer_ctxt(tcx,
                                                                      &tcx.tables,