Skip to content

Commit 7f25b9f

Browse files
committed
Use () for visible_parent_map.
1 parent 437a46d commit 7f25b9f

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,10 @@ pub fn provide(providers: &mut Providers) {
283283
// external item that is visible from at least one local module) to a
284284
// sufficiently visible parent (considering modules that re-export the
285285
// external item to be parents).
286-
visible_parent_map: |tcx, cnum| {
286+
visible_parent_map: |tcx, ()| {
287287
use std::collections::hash_map::Entry;
288288
use std::collections::vec_deque::VecDeque;
289289

290-
assert_eq!(cnum, LOCAL_CRATE);
291290
let mut visible_parent_map: DefIdMap<DefId> = Default::default();
292291

293292
// Issue 46112: We want the map to prefer the shortest
@@ -335,7 +334,7 @@ pub fn provide(providers: &mut Providers) {
335334
Entry::Occupied(mut entry) => {
336335
// If `child` is defined in crate `cnum`, ensure
337336
// that it is mapped to a parent in `cnum`.
338-
if child.krate == cnum && entry.get().krate != cnum {
337+
if child.is_local() && entry.get().is_local() {
339338
entry.insert(parent);
340339
}
341340
}

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,13 +1367,11 @@ rustc_queries! {
13671367
query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
13681368
desc { "calculating the missing lang items in a crate" }
13691369
}
1370-
query visible_parent_map(_: CrateNum)
1371-
-> DefIdMap<DefId> {
1370+
query visible_parent_map(_: ()) -> DefIdMap<DefId> {
13721371
storage(ArenaCacheSelector<'tcx>)
13731372
desc { "calculating the visible parent map" }
13741373
}
1375-
query trimmed_def_paths(_: CrateNum)
1376-
-> FxHashMap<DefId, Symbol> {
1374+
query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
13771375
storage(ArenaCacheSelector<'tcx>)
13781376
desc { "calculating trimmed def paths" }
13791377
}

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashMap;
77
use rustc_data_structures::sso::SsoHashSet;
88
use rustc_hir as hir;
99
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
10-
use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
10+
use rustc_hir::def_id::{DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
1111
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
1212
use rustc_hir::ItemKind;
1313
use rustc_session::config::TrimmedDefPaths;
@@ -285,7 +285,7 @@ pub trait PrettyPrinter<'tcx>:
285285
return Ok((self, false));
286286
}
287287

288-
match self.tcx().trimmed_def_paths(LOCAL_CRATE).get(&def_id) {
288+
match self.tcx().trimmed_def_paths(()).get(&def_id) {
289289
None => Ok((self, false)),
290290
Some(symbol) => {
291291
self.write_str(&symbol.as_str())?;
@@ -361,7 +361,7 @@ pub trait PrettyPrinter<'tcx>:
361361
return Ok((self, false));
362362
}
363363

364-
let visible_parent_map = self.tcx().visible_parent_map(LOCAL_CRATE);
364+
let visible_parent_map = self.tcx().visible_parent_map(());
365365

366366
let mut cur_def_key = self.tcx().def_key(def_id);
367367
debug!("try_print_visible_def_path: cur_def_key={:?}", cur_def_key);
@@ -2286,9 +2286,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
22862286
/// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere.
22872287
///
22882288
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
2289-
fn trimmed_def_paths(tcx: TyCtxt<'_>, crate_num: CrateNum) -> FxHashMap<DefId, Symbol> {
2290-
assert_eq!(crate_num, LOCAL_CRATE);
2291-
2289+
fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
22922290
let mut map = FxHashMap::default();
22932291

22942292
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {

0 commit comments

Comments
 (0)