Skip to content

Commit 4733317

Browse files
committed
Make crate_name a regular function instead of a query
1 parent 2d10c2a commit 4733317

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
187187
foreign_modules => { cdata.get_foreign_modules(tcx) }
188188
crate_hash => { cdata.root.hash }
189189
crate_host_hash => { cdata.host_hash }
190-
crate_name => { cdata.root.name }
191190

192191
extra_filename => { cdata.root.extra_filename.clone() }
193192

compiler/rustc_middle/src/query/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1360,10 +1360,6 @@ rustc_queries! {
13601360
eval_always
13611361
desc { "fetching what a dependency looks like" }
13621362
}
1363-
query crate_name(_: CrateNum) -> Symbol {
1364-
eval_always
1365-
desc { "fetching what a crate is named" }
1366-
}
13671363
query item_children(def_id: DefId) -> &'tcx [Export<hir::HirId>] {
13681364
desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
13691365
}

compiler/rustc_middle/src/ty/context.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,16 @@ impl<'tcx> TyCtxt<'tcx> {
13061306
}
13071307
}
13081308

1309+
#[inline]
1310+
pub fn crate_name(self, crate_num: CrateNum) -> Symbol {
1311+
// Note: Changing the local crate name will invalidate the incremental caches
1312+
if crate_num == LOCAL_CRATE {
1313+
self.crate_name
1314+
} else {
1315+
self.untracked_resolutions.cstore.crate_name(crate_num)
1316+
}
1317+
}
1318+
13091319
#[inline]
13101320
pub fn stable_crate_id(self, crate_num: CrateNum) -> StableCrateId {
13111321
if crate_num == LOCAL_CRATE {
@@ -2842,10 +2852,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
28422852
providers.in_scope_traits_map = |tcx, id| tcx.hir_crate(()).trait_map.get(&id);
28432853
providers.resolutions = |tcx, ()| &tcx.untracked_resolutions;
28442854
providers.module_exports = |tcx, id| tcx.resolutions(()).export_map.get(&id).map(|v| &v[..]);
2845-
providers.crate_name = |tcx, id| {
2846-
assert_eq!(id, LOCAL_CRATE);
2847-
tcx.crate_name
2848-
};
28492855
providers.maybe_unused_trait_import =
28502856
|tcx, id| tcx.resolutions(()).maybe_unused_trait_imports.contains(&id);
28512857
providers.maybe_unused_extern_crates =

0 commit comments

Comments
 (0)