Use () for visible_parent_map.
This commit is contained in:
parent
437a46ddfa
commit
7f25b9f7a6
3 changed files with 8 additions and 13 deletions
|
@ -283,11 +283,10 @@ pub fn provide(providers: &mut Providers) {
|
||||||
// external item that is visible from at least one local module) to a
|
// external item that is visible from at least one local module) to a
|
||||||
// sufficiently visible parent (considering modules that re-export the
|
// sufficiently visible parent (considering modules that re-export the
|
||||||
// external item to be parents).
|
// external item to be parents).
|
||||||
visible_parent_map: |tcx, cnum| {
|
visible_parent_map: |tcx, ()| {
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::collections::vec_deque::VecDeque;
|
use std::collections::vec_deque::VecDeque;
|
||||||
|
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
|
||||||
let mut visible_parent_map: DefIdMap<DefId> = Default::default();
|
let mut visible_parent_map: DefIdMap<DefId> = Default::default();
|
||||||
|
|
||||||
// Issue 46112: We want the map to prefer the shortest
|
// Issue 46112: We want the map to prefer the shortest
|
||||||
|
@ -335,7 +334,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
Entry::Occupied(mut entry) => {
|
Entry::Occupied(mut entry) => {
|
||||||
// If `child` is defined in crate `cnum`, ensure
|
// If `child` is defined in crate `cnum`, ensure
|
||||||
// that it is mapped to a parent in `cnum`.
|
// that it is mapped to a parent in `cnum`.
|
||||||
if child.krate == cnum && entry.get().krate != cnum {
|
if child.is_local() && entry.get().is_local() {
|
||||||
entry.insert(parent);
|
entry.insert(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1367,13 +1367,11 @@ rustc_queries! {
|
||||||
query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
|
query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
|
||||||
desc { "calculating the missing lang items in a crate" }
|
desc { "calculating the missing lang items in a crate" }
|
||||||
}
|
}
|
||||||
query visible_parent_map(_: CrateNum)
|
query visible_parent_map(_: ()) -> DefIdMap<DefId> {
|
||||||
-> DefIdMap<DefId> {
|
|
||||||
storage(ArenaCacheSelector<'tcx>)
|
storage(ArenaCacheSelector<'tcx>)
|
||||||
desc { "calculating the visible parent map" }
|
desc { "calculating the visible parent map" }
|
||||||
}
|
}
|
||||||
query trimmed_def_paths(_: CrateNum)
|
query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
|
||||||
-> FxHashMap<DefId, Symbol> {
|
|
||||||
storage(ArenaCacheSelector<'tcx>)
|
storage(ArenaCacheSelector<'tcx>)
|
||||||
desc { "calculating trimmed def paths" }
|
desc { "calculating trimmed def paths" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::sso::SsoHashSet;
|
use rustc_data_structures::sso::SsoHashSet;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||||
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
|
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
|
||||||
use rustc_hir::ItemKind;
|
use rustc_hir::ItemKind;
|
||||||
use rustc_session::config::TrimmedDefPaths;
|
use rustc_session::config::TrimmedDefPaths;
|
||||||
|
@ -285,7 +285,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
return Ok((self, false));
|
return Ok((self, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.tcx().trimmed_def_paths(LOCAL_CRATE).get(&def_id) {
|
match self.tcx().trimmed_def_paths(()).get(&def_id) {
|
||||||
None => Ok((self, false)),
|
None => Ok((self, false)),
|
||||||
Some(symbol) => {
|
Some(symbol) => {
|
||||||
self.write_str(&symbol.as_str())?;
|
self.write_str(&symbol.as_str())?;
|
||||||
|
@ -361,7 +361,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
return Ok((self, false));
|
return Ok((self, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
let visible_parent_map = self.tcx().visible_parent_map(LOCAL_CRATE);
|
let visible_parent_map = self.tcx().visible_parent_map(());
|
||||||
|
|
||||||
let mut cur_def_key = self.tcx().def_key(def_id);
|
let mut cur_def_key = self.tcx().def_key(def_id);
|
||||||
debug!("try_print_visible_def_path: cur_def_key={:?}", cur_def_key);
|
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
|
||||||
/// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere.
|
/// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere.
|
||||||
///
|
///
|
||||||
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
|
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
|
||||||
fn trimmed_def_paths(tcx: TyCtxt<'_>, crate_num: CrateNum) -> FxHashMap<DefId, Symbol> {
|
fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
|
||||||
assert_eq!(crate_num, LOCAL_CRATE);
|
|
||||||
|
|
||||||
let mut map = FxHashMap::default();
|
let mut map = FxHashMap::default();
|
||||||
|
|
||||||
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
|
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue