Skip to content

Commit 3a756fe

Browse files
michaelwoeristernikomatsakis
authored andcommitted
Make the definite name of the local crate available in the tcx.
1 parent 32a2e9a commit 3a756fe

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/librustc/middle/ty/context.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use std::hash::{Hash, Hasher};
4343
use std::rc::Rc;
4444
use syntax::ast::{self, Name, NodeId};
4545
use syntax::attr;
46-
use syntax::parse::token::special_idents;
46+
use syntax::parse::token::{self, special_idents};
4747

4848
use rustc_front::hir;
4949

@@ -415,6 +415,10 @@ pub struct TyCtxt<'tcx> {
415415
/// fragmented data to the set of unfragmented pieces that
416416
/// constitute it.
417417
pub fragment_infos: RefCell<DefIdMap<Vec<ty::FragmentInfo>>>,
418+
419+
/// The definite name of the current crate after taking into account
420+
/// attributes, commandline parameters, etc.
421+
pub crate_name: token::InternedString,
418422
}
419423

420424
impl<'tcx> TyCtxt<'tcx> {
@@ -511,6 +515,7 @@ impl<'tcx> TyCtxt<'tcx> {
511515
region_maps: RegionMaps,
512516
lang_items: middle::lang_items::LanguageItems,
513517
stability: stability::Index<'tcx>,
518+
crate_name: &str,
514519
f: F) -> R
515520
where F: FnOnce(&TyCtxt<'tcx>) -> R
516521
{
@@ -570,7 +575,8 @@ impl<'tcx> TyCtxt<'tcx> {
570575
const_qualif_map: RefCell::new(NodeMap()),
571576
custom_coerce_unsized_kinds: RefCell::new(DefIdMap()),
572577
cast_kinds: RefCell::new(NodeMap()),
573-
fragment_infos: RefCell::new(DefIdMap())
578+
fragment_infos: RefCell::new(DefIdMap()),
579+
crate_name: token::intern_and_get_ident(crate_name),
574580
}, f)
575581
}
576582
}

src/librustc_driver/driver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
818818
region_map,
819819
lang_items,
820820
index,
821+
name,
821822
|tcx| {
822823
// passes are timed inside typeck
823824
try_with_f!(typeck::check_crate(tcx, trait_map), (tcx, None, analysis));

src/librustc_driver/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn test_env<F>(source_string: &str,
146146
region_map,
147147
lang_items,
148148
index,
149+
"test_crate",
149150
|tcx| {
150151
let infcx = infer::new_infer_ctxt(tcx,
151152
&tcx.tables,

0 commit comments

Comments
 (0)