Skip to content

Commit ebc1fd3

Browse files
committed
rustc: Move crate_disambiguator to queries
1 parent 2d4445f commit ebc1fd3

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ define_dep_nodes!( <'tcx>
539539
[] NativeLibraries(CrateNum),
540540
[] PluginRegistrarFn(CrateNum),
541541
[] DeriveRegistrarFn(CrateNum),
542+
[] CrateDisambiguator(CrateNum),
542543
);
543544

544545
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {

src/librustc/middle/cstore.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ pub trait CrateStore {
254254
/// The name of the crate as it is stored in the crate's metadata.
255255
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
256256
fn crate_hash(&self, cnum: CrateNum) -> Svh;
257-
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
258257

259258
// resolve
260259
fn def_key(&self, def: DefId) -> DefKey;
@@ -355,8 +354,6 @@ impl CrateStore for DummyCrateStore {
355354
bug!("original_crate_name")
356355
}
357356
fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
358-
fn crate_disambiguator(&self, cnum: CrateNum)
359-
-> Symbol { bug!("crate_disambiguator") }
360357

361358
// resolve
362359
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }

src/librustc/ty/context.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -925,14 +925,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
925925
}
926926
}
927927

928-
pub fn crate_disambiguator(self, cnum: CrateNum) -> Symbol {
929-
if cnum == LOCAL_CRATE {
930-
self.sess.local_crate_disambiguator()
931-
} else {
932-
self.sess.cstore.crate_disambiguator(cnum)
933-
}
934-
}
935-
936928
pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
937929
self.global_arenas.generics.alloc(generics)
938930
}

src/librustc/ty/maps.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,12 @@ impl<'tcx> QueryDescription for queries::derive_registrar_fn<'tcx> {
611611
}
612612
}
613613

614+
impl<'tcx> QueryDescription for queries::crate_disambiguator<'tcx> {
615+
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
616+
format!("looking up the disambiguator a crate")
617+
}
618+
}
619+
614620
// If enabled, send a message to the profile-queries thread
615621
macro_rules! profq_msg {
616622
($tcx:expr, $msg:expr) => {
@@ -1191,6 +1197,7 @@ define_maps! { <'tcx>
11911197
[] fn native_libraries: NativeLibraries(CrateNum) -> Rc<Vec<NativeLibrary>>,
11921198
[] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
11931199
[] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
1200+
[] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol,
11941201
}
11951202

11961203
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {

src/librustc/ty/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,12 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
25102510
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
25112511
}
25122512

2513+
fn crate_disambiguator<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
2514+
crate_num: CrateNum) -> Symbol {
2515+
assert_eq!(crate_num, LOCAL_CRATE);
2516+
tcx.sess.local_crate_disambiguator()
2517+
}
2518+
25132519
pub fn provide(providers: &mut ty::maps::Providers) {
25142520
util::provide(providers);
25152521
context::provide(providers);
@@ -2521,6 +2527,7 @@ pub fn provide(providers: &mut ty::maps::Providers) {
25212527
def_span,
25222528
param_env,
25232529
trait_of_item,
2530+
crate_disambiguator,
25242531
trait_impls_of: trait_def::trait_impls_of_provider,
25252532
..*providers
25262533
};

src/librustc_metadata/cstore_impl.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ provide! { <'tcx> tcx, def_id, cdata,
175175
DefId { krate: def_id.krate, index }
176176
})
177177
}
178+
crate_disambiguator => { cdata.disambiguator() }
179+
crate_hash => { cdata.hash() }
180+
original_crate_name => { cdata.name() }
178181
}
179182

180183
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
@@ -288,11 +291,6 @@ impl CrateStore for cstore::CStore {
288291
self.get_crate_hash(cnum)
289292
}
290293

291-
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol
292-
{
293-
self.get_crate_data(cnum).disambiguator()
294-
}
295-
296294
/// Returns the `DefKey` for a given `DefId`. This indicates the
297295
/// parent `DefId` as well as some idea of what kind of data the
298296
/// `DefId` refers to.

0 commit comments

Comments
 (0)