Skip to content

Commit efe30de

Browse files
committed
Accept LocalDefId as keyt for names_imported_by_glob_use
and `maybe_unused_trait_import` queries
1 parent f27cec9 commit efe30de

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/librustc_middle/query/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,17 +1030,19 @@ rustc_queries! {
10301030
query upvars(_: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
10311031
eval_always
10321032
}
1033-
query maybe_unused_trait_import(_: DefId) -> bool {
1033+
query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
10341034
eval_always
1035+
desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
10351036
}
10361037
query maybe_unused_extern_crates(_: CrateNum)
10371038
-> &'tcx [(DefId, Span)] {
10381039
eval_always
10391040
desc { "looking up all possibly unused extern crates" }
10401041
}
1041-
query names_imported_by_glob_use(_: DefId)
1042+
query names_imported_by_glob_use(def_id: LocalDefId)
10421043
-> &'tcx FxHashSet<ast::Name> {
10431044
eval_always
1045+
desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
10441046
}
10451047

10461048
query stability_index(_: CrateNum) -> &'tcx stability::Index<'tcx> {

src/librustc_middle/ty/context.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,11 @@ pub struct GlobalCtxt<'tcx> {
945945

946946
pub queries: query::Queries<'tcx>,
947947

948-
maybe_unused_trait_imports: FxHashSet<DefId>,
948+
maybe_unused_trait_imports: FxHashSet<LocalDefId>,
949949
maybe_unused_extern_crates: Vec<(DefId, Span)>,
950950
/// A map of glob use to a set of names it actually imports. Currently only
951951
/// used in save-analysis.
952-
glob_map: FxHashMap<DefId, FxHashSet<ast::Name>>,
952+
glob_map: FxHashMap<LocalDefId, FxHashSet<ast::Name>>,
953953
/// Extern prelude entries. The value is `true` if the entry was introduced
954954
/// via `extern crate` item and not `--extern` option or compiler built-in.
955955
pub extern_prelude: FxHashMap<ast::Name, bool>,
@@ -1165,7 +1165,7 @@ impl<'tcx> TyCtxt<'tcx> {
11651165
maybe_unused_trait_imports: resolutions
11661166
.maybe_unused_trait_imports
11671167
.into_iter()
1168-
.map(|id| definitions.local_def_id(id).to_def_id())
1168+
.map(|id| definitions.local_def_id(id))
11691169
.collect(),
11701170
maybe_unused_extern_crates: resolutions
11711171
.maybe_unused_extern_crates
@@ -1175,7 +1175,7 @@ impl<'tcx> TyCtxt<'tcx> {
11751175
glob_map: resolutions
11761176
.glob_map
11771177
.into_iter()
1178-
.map(|(id, names)| (definitions.local_def_id(id).to_def_id(), names))
1178+
.map(|(id, names)| (definitions.local_def_id(id), names))
11791179
.collect(),
11801180
extern_prelude: resolutions.extern_prelude,
11811181
untracked_crate: krate,
@@ -2724,10 +2724,8 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
27242724
assert_eq!(cnum, LOCAL_CRATE);
27252725
&tcx.maybe_unused_extern_crates[..]
27262726
};
2727-
providers.names_imported_by_glob_use = |tcx, id| {
2728-
assert_eq!(id.krate, LOCAL_CRATE);
2729-
tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default())
2730-
};
2727+
providers.names_imported_by_glob_use =
2728+
|tcx, id| tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default());
27312729

27322730
providers.lookup_stability = |tcx, id| {
27332731
let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
11831183

11841184
// Make a comma-separated list of names of imported modules.
11851185
let def_id = self.tcx.hir().local_def_id_from_node_id(id);
1186-
let names = self.tcx.names_imported_by_glob_use(def_id.to_def_id());
1186+
let names = self.tcx.names_imported_by_glob_use(def_id);
11871187
let names: Vec<_> = names.iter().map(|n| n.to_string()).collect();
11881188

11891189
// Otherwise it's a span with wrong macro expansion info, which

0 commit comments

Comments
 (0)