Rollup merge of #92032 - petrochenkov:extblockpath, r=oli-obk
hir: Do not introduce dummy type names for `extern` blocks in def paths Use a separate nameless `DefPathData` variant instead. Extracted from https://github.com/rust-lang/rust/pull/91795.
This commit is contained in:
commit
5e8f934149
8 changed files with 36 additions and 31 deletions
|
|
@ -8,6 +8,7 @@ use rustc_data_structures::fx::FxHashSet;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_hir::Mutability;
|
||||
use rustc_metadata::creader::{CStore, LoadedMacro};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
|
@ -165,9 +166,8 @@ crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType)
|
|||
let crate_name = cx.tcx.crate_name(did.krate).to_string();
|
||||
|
||||
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
|
||||
// extern blocks have an empty name
|
||||
let s = elem.data.to_string();
|
||||
if !s.is_empty() { Some(s) } else { None }
|
||||
// Filter out extern blocks
|
||||
(elem.data != DefPathData::ForeignMod).then(|| elem.data.to_string())
|
||||
});
|
||||
let fqn = if let ItemType::Macro = kind {
|
||||
// Check to see if it is a macro 2.0 or built-in macro
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_hir::Node;
|
||||
use rustc_hir::CRATE_HIR_ID;
|
||||
use rustc_middle::middle::privacy::AccessLevel;
|
||||
|
|
@ -45,9 +46,8 @@ impl Module<'hir> {
|
|||
fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<String> {
|
||||
let crate_name = tcx.crate_name(did.krate).to_string();
|
||||
let relative = tcx.def_path(did).data.into_iter().filter_map(|elem| {
|
||||
// extern blocks have an empty name
|
||||
let s = elem.data.to_string();
|
||||
if !s.is_empty() { Some(s) } else { None }
|
||||
// Filter out extern blocks
|
||||
(elem.data != DefPathData::ForeignMod).then(|| elem.data.to_string())
|
||||
});
|
||||
std::iter::once(crate_name).chain(relative).collect()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue