Skip to content

Commit 194b4a2

Browse files
committed
Feed crate_name query
1 parent 408ae0f commit 194b4a2

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

compiler/rustc_interface/src/passes.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,6 @@ pub fn create_global_ctxt<'tcx>(
823823
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
824824
queries.as_dyn(),
825825
rustc_query_impl::query_callbacks(arena),
826-
crate_name,
827826
outputs,
828827
)
829828
})
@@ -834,6 +833,8 @@ pub fn create_global_ctxt<'tcx>(
834833
let feed = tcx.feed_unit_query();
835834
feed.resolver_for_lowering(tcx.arena.alloc(Steal::new(untracked_resolver_for_lowering)));
836835
feed.resolutions(tcx.arena.alloc(untracked_resolutions));
836+
let feed = tcx.feed_local_crate();
837+
feed.crate_name(crate_name);
837838
});
838839
qcx
839840
}

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ rustc_queries! {
16731673

16741674
/// Gets the name of the crate.
16751675
query crate_name(_: CrateNum) -> Symbol {
1676-
eval_always
1676+
feedable
16771677
desc { "fetching what a crate is named" }
16781678
separate_provide_extern
16791679
}

compiler/rustc_middle/src/ty/context.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ impl<'tcx> TyCtxt<'tcx> {
363363
pub fn feed_unit_query(self) -> TyCtxtFeed<'tcx, ()> {
364364
TyCtxtFeed { tcx: self, key: () }
365365
}
366+
pub fn feed_local_crate(self) -> TyCtxtFeed<'tcx, CrateNum> {
367+
TyCtxtFeed { tcx: self, key: LOCAL_CRATE }
368+
}
366369
}
367370

368371
impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY> {
@@ -456,10 +459,6 @@ pub struct GlobalCtxt<'tcx> {
456459
/// Merge this with `selection_cache`?
457460
pub evaluation_cache: traits::EvaluationCache<'tcx>,
458461

459-
/// The definite name of the current crate after taking into account
460-
/// attributes, commandline parameters, etc.
461-
crate_name: Symbol,
462-
463462
/// Data layout specification for the current target.
464463
pub data_layout: TargetDataLayout,
465464

@@ -597,7 +596,6 @@ impl<'tcx> TyCtxt<'tcx> {
597596
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
598597
queries: &'tcx dyn query::QueryEngine<'tcx>,
599598
query_kinds: &'tcx [DepKindStruct<'tcx>],
600-
crate_name: Symbol,
601599
output_filenames: OutputFilenames,
602600
) -> GlobalCtxt<'tcx> {
603601
let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| {
@@ -629,7 +627,6 @@ impl<'tcx> TyCtxt<'tcx> {
629627
pred_rcache: Default::default(),
630628
selection_cache: Default::default(),
631629
evaluation_cache: Default::default(),
632-
crate_name,
633630
data_layout,
634631
alloc_map: Lock::new(interpret::AllocMap::new()),
635632
output_filenames: Arc::new(output_filenames),
@@ -807,7 +804,7 @@ impl<'tcx> TyCtxt<'tcx> {
807804
// statements within the query system and we'd run into endless
808805
// recursion otherwise.
809806
let (crate_name, stable_crate_id) = if def_id.is_local() {
810-
(self.crate_name, self.sess.local_stable_crate_id())
807+
(self.crate_name(LOCAL_CRATE), self.sess.local_stable_crate_id())
811808
} else {
812809
let cstore = &*self.untracked.cstore;
813810
(cstore.crate_name(def_id.krate), cstore.stable_crate_id(def_id.krate))
@@ -2406,10 +2403,6 @@ fn ptr_eq<T, U>(t: *const T, u: *const U) -> bool {
24062403
pub fn provide(providers: &mut ty::query::Providers) {
24072404
providers.module_reexports =
24082405
|tcx, id| tcx.resolutions(()).reexport_map.get(&id).map(|v| &v[..]);
2409-
providers.crate_name = |tcx, id| {
2410-
assert_eq!(id, LOCAL_CRATE);
2411-
tcx.crate_name
2412-
};
24132406
providers.maybe_unused_trait_imports =
24142407
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
24152408
providers.maybe_unused_extern_crates =

0 commit comments

Comments
 (0)