1use std::fmt::{self, Write};
8use std::hash::Hash;
9
10use rustc_data_structures::fx::FxHashMap;
11use rustc_data_structures::sorted_map::SortedMap;
12use rustc_data_structures::stable_hash::StableHasher;
13use rustc_hashes::Hash64;
14use rustc_index::IndexVec;
15use rustc_macros::{BlobDecodable, Decodable, Encodable, extension};
16use rustc_serialize::Encodable;
17pub use rustc_span::def_id::DefPathHash;
18use rustc_span::def_id::{
19 CRATE_DEF_INDEX, CrateNum, DefIndex, LOCAL_CRATE, LocalDefId, LocalDefIdMap, StableCrateId,
20};
21use rustc_span::{SpanEncoder, Symbol, kw, sym};
22use tracing::{debug, instrument};
23
24use crate::def_path_hash_map::DefPathHashMap;
25
26#[derive(#[automatically_derived]
impl ::core::fmt::Debug for PerParentDisambiguatorState {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"PerParentDisambiguatorState", "parent", &self.parent, "next",
&&self.next)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for PerParentDisambiguatorState {
#[inline]
fn default() -> Self {
PerParentDisambiguatorState {
parent: ::core::default::Default::default(),
next: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]
impl ::core::clone::Clone for PerParentDisambiguatorState {
#[inline]
fn clone(&self) -> Self {
PerParentDisambiguatorState {
parent: ::core::clone::Clone::clone(&self.parent),
next: ::core::clone::Clone::clone(&self.next),
}
}
}Clone)]
27pub struct PerParentDisambiguatorState {
28 #[cfg(debug_assertions)]
29 parent: Option<LocalDefId>,
30 next: FxHashMap<DefPathData, u32>,
31}
32
33impl PerParentDisambiguatorState {
34 #[inline(always)]
35 pub fn new(_parent: LocalDefId) -> PerParentDisambiguatorState {
36 PerParentDisambiguatorState {
37 #[cfg(debug_assertions)]
38 parent: Some(_parent),
39 next: Default::default(),
40 }
41 }
42}
43
44pub trait PerParentDisambiguatorsMap {
fn get_or_create(&mut self, parent: LocalDefId)
-> &mut PerParentDisambiguatorState;
}
impl PerParentDisambiguatorsMap for LocalDefIdMap<PerParentDisambiguatorState>
{
fn get_or_create(&mut self, parent: LocalDefId)
-> &mut PerParentDisambiguatorState {
self.entry(parent).or_insert_with(||
PerParentDisambiguatorState::new(parent))
}
}#[extension(pub trait PerParentDisambiguatorsMap)]
45impl LocalDefIdMap<PerParentDisambiguatorState> {
46 fn get_or_create(&mut self, parent: LocalDefId) -> &mut PerParentDisambiguatorState {
47 self.entry(parent).or_insert_with(|| PerParentDisambiguatorState::new(parent))
48 }
49}
50
51#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DefPathToIndexMap {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DefPathToIndexMap", "before_parallel_alloc",
&self.before_parallel_alloc, "after_parallel_alloc",
&&self.after_parallel_alloc)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for DefPathToIndexMap {
#[inline]
fn default() -> Self {
DefPathToIndexMap {
before_parallel_alloc: ::core::default::Default::default(),
after_parallel_alloc: ::core::default::Default::default(),
}
}
}Default)]
52pub struct DefPathToIndexMap {
53 pub before_parallel_alloc: DefPathHashMap,
57
58 pub after_parallel_alloc: Option<SortedMap<Hash64, LocalDefId>>,
64}
65
66impl DefPathToIndexMap {
67 #[inline]
68 pub fn get(&self, hash: Hash64) -> Option<DefIndex> {
69 self.before_parallel_alloc.get(&hash).or_else(|| {
70 self.after_parallel_alloc
71 .as_ref()
72 .and_then(|map| map.get(&hash).map(|id| id.local_def_index))
73 })
74 }
75
76 #[inline]
81 pub fn insert(&mut self, hash: Hash64, index: DefIndex) -> Option<DefIndex> {
82 match self.after_parallel_alloc.as_mut() {
83 None => self.before_parallel_alloc.insert(&hash, &index),
84 Some(map) => {
85 if let Some(existing) = self.before_parallel_alloc.get(&hash) {
86 return Some(existing);
87 }
88
89 map.insert(hash, LocalDefId { local_def_index: index }).map(|id| id.local_def_index)
90 }
91 }
92 }
93}
94
95#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Definitions {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Definitions",
"stable_crate_id", &self.stable_crate_id, "def_id_to_key",
&self.def_id_to_key, "def_path_hashes", &self.def_path_hashes,
"def_path_hash_to_index", &&self.def_path_hash_to_index)
}
}Debug)]
96pub struct Definitions {
97 stable_crate_id: StableCrateId,
98 def_id_to_key: IndexVec<LocalDefId, DefKey>,
99 def_path_hashes: IndexVec<LocalDefId, Hash64>,
101 def_path_hash_to_index: DefPathToIndexMap,
102}
103
104#[derive(#[automatically_derived]
impl ::core::marker::Copy for DefKey { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DefKey { }
#[automatically_derived]
impl ::core::clone::Clone for DefKey {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Option<DefIndex>>;
let _: ::core::clone::AssertParamIsClone<DisambiguatedDefPathData>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for DefKey { }
#[automatically_derived]
impl ::core::cmp::PartialEq for DefKey {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.parent == other.parent &&
self.disambiguated_data == other.disambiguated_data
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for DefKey {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "DefKey",
"parent", &self.parent, "disambiguated_data",
&&self.disambiguated_data)
}
}Debug, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for DefKey {
fn decode(__decoder: &mut __D) -> Self {
DefKey {
parent: ::rustc_serialize::Decodable::decode(__decoder),
disambiguated_data: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};BlobDecodable)]
108pub struct DefKey {
109 pub parent: Option<DefIndex>,
111
112 pub disambiguated_data: DisambiguatedDefPathData,
114}
115
116impl<E: SpanEncoder> Encodable<E> for DefKey {
117 #[inline]
118 fn encode(&self, e: &mut E) {
119 e.encode_def_key(self.parent, self.disambiguated_data);
120 }
121}
122
123impl DefKey {
124 pub(crate) fn compute_stable_hash(&self, parent: DefPathHash) -> DefPathHash {
125 let mut hasher = StableHasher::new();
126
127 parent.local_hash().hash(&mut hasher);
130
131 let DisambiguatedDefPathData { ref data, disambiguator } = self.disambiguated_data;
132
133 std::mem::discriminant(data).hash(&mut hasher);
134 if let Some(name) = data.hashed_symbol() {
135 name.as_str().hash(&mut hasher);
138 }
139
140 disambiguator.hash(&mut hasher);
141
142 let local_hash = hasher.finish();
143
144 DefPathHash::new(parent.stable_crate_id(), local_hash)
149 }
150
151 #[inline]
152 pub fn get_opt_name(&self) -> Option<Symbol> {
153 self.disambiguated_data.data.get_opt_name()
154 }
155}
156
157#[derive(#[automatically_derived]
impl ::core::marker::Copy for DisambiguatedDefPathData { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DisambiguatedDefPathData { }
#[automatically_derived]
impl ::core::clone::Clone for DisambiguatedDefPathData {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<DefPathData>;
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for DisambiguatedDefPathData { }
#[automatically_derived]
impl ::core::cmp::PartialEq for DisambiguatedDefPathData {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.disambiguator == other.disambiguator && self.data == other.data
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for DisambiguatedDefPathData {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DisambiguatedDefPathData", "data", &self.data, "disambiguator",
&&self.disambiguator)
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for DisambiguatedDefPathData {
fn encode(&self, __encoder: &mut __E) {
let DisambiguatedDefPathData {
data: ref __binding_0, disambiguator: ref __binding_1 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for DisambiguatedDefPathData {
fn decode(__decoder: &mut __D) -> Self {
DisambiguatedDefPathData {
data: ::rustc_serialize::Decodable::decode(__decoder),
disambiguator: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};BlobDecodable)]
164pub struct DisambiguatedDefPathData {
165 pub data: DefPathData,
166 pub disambiguator: u32,
167}
168
169impl DisambiguatedDefPathData {
170 pub fn as_sym(&self, verbose: bool) -> Symbol {
171 match self.data.name() {
172 DefPathDataName::Named(name) => {
173 if verbose && self.disambiguator != 0 {
174 Symbol::intern(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}#{1}", name,
self.disambiguator))
})format!("{}#{}", name, self.disambiguator))
175 } else {
176 name
177 }
178 }
179 DefPathDataName::Anon { namespace } => {
180 if let DefPathData::AnonAssocTy(method) = self.data {
181 Symbol::intern(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}::{{{1}#{2}}}", method,
namespace, self.disambiguator))
})format!("{}::{{{}#{}}}", method, namespace, self.disambiguator))
182 } else {
183 Symbol::intern(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{{{0}#{1}}}", namespace,
self.disambiguator))
})format!("{{{}#{}}}", namespace, self.disambiguator))
184 }
185 }
186 }
187 }
188}
189
190#[derive(#[automatically_derived]
impl ::core::clone::Clone for DefPath {
#[inline]
fn clone(&self) -> Self {
DefPath {
data: ::core::clone::Clone::clone(&self.data),
krate: ::core::clone::Clone::clone(&self.krate),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DefPath {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "DefPath",
"data", &self.data, "krate", &&self.krate)
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for DefPath {
fn encode(&self, __encoder: &mut __E) {
let DefPath { data: ref __binding_0, krate: ref __binding_1
} = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for DefPath {
fn decode(__decoder: &mut __D) -> Self {
DefPath {
data: ::rustc_serialize::Decodable::decode(__decoder),
krate: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
191pub struct DefPath {
192 pub data: Vec<DisambiguatedDefPathData>,
194
195 pub krate: CrateNum,
197}
198
199impl DefPath {
200 pub fn make<FN>(krate: CrateNum, start_index: DefIndex, mut get_key: FN) -> DefPath
201 where
202 FN: FnMut(DefIndex) -> DefKey,
203 {
204 let mut data = ::alloc::vec::Vec::new()vec![];
205 let mut index = Some(start_index);
206 loop {
207 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs:207",
"rustc_hir_id::definitions", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(207u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("DefPath::make: krate={0:?} index={1:?}",
krate, index) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("DefPath::make: krate={:?} index={:?}", krate, index);
208 let p = index.unwrap();
209 let key = get_key(p);
210 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs:210",
"rustc_hir_id::definitions", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(210u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("DefPath::make: key={0:?}",
key) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("DefPath::make: key={:?}", key);
211 match key.disambiguated_data.data {
212 DefPathData::CrateRoot => {
213 if !key.parent.is_none() {
::core::panicking::panic("assertion failed: key.parent.is_none()")
};assert!(key.parent.is_none());
214 break;
215 }
216 _ => {
217 data.push(key.disambiguated_data);
218 index = key.parent;
219 }
220 }
221 }
222 data.reverse();
223 DefPath { data, krate }
224 }
225
226 pub fn to_string_no_crate_verbose(&self) -> String {
230 let mut s = String::with_capacity(self.data.len() * 16);
231
232 for component in &self.data {
233 s.write_fmt(format_args!("::{0}", component.as_sym(true)))write!(s, "::{}", component.as_sym(true)).unwrap();
234 }
235
236 s
237 }
238
239 pub fn to_filename_friendly_no_crate(&self) -> String {
243 let mut s = String::with_capacity(self.data.len() * 16);
244
245 let mut opt_delimiter = None;
246 for component in &self.data {
247 s.extend(opt_delimiter);
248 opt_delimiter = Some('-');
249 s.write_fmt(format_args!("{0}", component.as_sym(true)))write!(s, "{}", component.as_sym(true)).unwrap();
250 }
251
252 s
253 }
254}
255
256#[derive(#[automatically_derived]
impl ::core::marker::Copy for DefPathData { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DefPathData { }
#[automatically_derived]
impl ::core::clone::Clone for DefPathData {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Symbol>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DefPathData {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::CrateRoot =>
::core::fmt::Formatter::write_str(f, "CrateRoot"),
Self::Impl => ::core::fmt::Formatter::write_str(f, "Impl"),
Self::ForeignMod =>
::core::fmt::Formatter::write_str(f, "ForeignMod"),
Self::Use => ::core::fmt::Formatter::write_str(f, "Use"),
Self::GlobalAsm =>
::core::fmt::Formatter::write_str(f, "GlobalAsm"),
Self::TypeNs(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "TypeNs",
&__self_0),
Self::ValueNs(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ValueNs", &__self_0),
Self::MacroNs(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"MacroNs", &__self_0),
Self::LifetimeNs(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"LifetimeNs", &__self_0),
Self::Closure => ::core::fmt::Formatter::write_str(f, "Closure"),
Self::TestBinderConstraints =>
::core::fmt::Formatter::write_str(f, "TestBinderConstraints"),
Self::Ctor => ::core::fmt::Formatter::write_str(f, "Ctor"),
Self::AnonConst =>
::core::fmt::Formatter::write_str(f, "AnonConst"),
Self::OpaqueTy =>
::core::fmt::Formatter::write_str(f, "OpaqueTy"),
Self::OpaqueLifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OpaqueLifetime", &__self_0),
Self::AnonAssocTy(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AnonAssocTy", &__self_0),
Self::SyntheticCoroutineBody =>
::core::fmt::Formatter::write_str(f,
"SyntheticCoroutineBody"),
Self::NestedStatic =>
::core::fmt::Formatter::write_str(f, "NestedStatic"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for DefPathData { }
#[automatically_derived]
impl ::core::cmp::PartialEq for DefPathData {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::TypeNs(__self_0), Self::TypeNs(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::ValueNs(__self_0), Self::ValueNs(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::MacroNs(__self_0), Self::MacroNs(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::LifetimeNs(__self_0), Self::LifetimeNs(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::OpaqueLifetime(__self_0),
Self::OpaqueLifetime(__arg1_0)) => __self_0 == __arg1_0,
(Self::AnonAssocTy(__self_0), Self::AnonAssocTy(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DefPathData {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Symbol>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DefPathData {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::TypeNs(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::ValueNs(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::MacroNs(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::LifetimeNs(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::OpaqueLifetime(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::AnonAssocTy(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for DefPathData {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
DefPathData::CrateRoot => { 0usize }
DefPathData::Impl => { 1usize }
DefPathData::ForeignMod => { 2usize }
DefPathData::Use => { 3usize }
DefPathData::GlobalAsm => { 4usize }
DefPathData::TypeNs(ref __binding_0) => { 5usize }
DefPathData::ValueNs(ref __binding_0) => { 6usize }
DefPathData::MacroNs(ref __binding_0) => { 7usize }
DefPathData::LifetimeNs(ref __binding_0) => { 8usize }
DefPathData::Closure => { 9usize }
DefPathData::TestBinderConstraints => { 10usize }
DefPathData::Ctor => { 11usize }
DefPathData::AnonConst => { 12usize }
DefPathData::OpaqueTy => { 13usize }
DefPathData::OpaqueLifetime(ref __binding_0) => { 14usize }
DefPathData::AnonAssocTy(ref __binding_0) => { 15usize }
DefPathData::SyntheticCoroutineBody => { 16usize }
DefPathData::NestedStatic => { 17usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
DefPathData::CrateRoot => {}
DefPathData::Impl => {}
DefPathData::ForeignMod => {}
DefPathData::Use => {}
DefPathData::GlobalAsm => {}
DefPathData::TypeNs(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
DefPathData::ValueNs(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
DefPathData::MacroNs(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
DefPathData::LifetimeNs(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
DefPathData::Closure => {}
DefPathData::TestBinderConstraints => {}
DefPathData::Ctor => {}
DefPathData::AnonConst => {}
DefPathData::OpaqueTy => {}
DefPathData::OpaqueLifetime(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
DefPathData::AnonAssocTy(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
DefPathData::SyntheticCoroutineBody => {}
DefPathData::NestedStatic => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for DefPathData {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { DefPathData::CrateRoot }
1usize => { DefPathData::Impl }
2usize => { DefPathData::ForeignMod }
3usize => { DefPathData::Use }
4usize => { DefPathData::GlobalAsm }
5usize => {
DefPathData::TypeNs(::rustc_serialize::Decodable::decode(__decoder))
}
6usize => {
DefPathData::ValueNs(::rustc_serialize::Decodable::decode(__decoder))
}
7usize => {
DefPathData::MacroNs(::rustc_serialize::Decodable::decode(__decoder))
}
8usize => {
DefPathData::LifetimeNs(::rustc_serialize::Decodable::decode(__decoder))
}
9usize => { DefPathData::Closure }
10usize => { DefPathData::TestBinderConstraints }
11usize => { DefPathData::Ctor }
12usize => { DefPathData::AnonConst }
13usize => { DefPathData::OpaqueTy }
14usize => {
DefPathData::OpaqueLifetime(::rustc_serialize::Decodable::decode(__decoder))
}
15usize => {
DefPathData::AnonAssocTy(::rustc_serialize::Decodable::decode(__decoder))
}
16usize => { DefPathData::SyntheticCoroutineBody }
17usize => { DefPathData::NestedStatic }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `DefPathData`, expected 0..18, actual {0}",
n));
}
}
}
}
};BlobDecodable)]
258pub enum DefPathData {
259 CrateRoot,
263
264 Impl,
267 ForeignMod,
269 Use,
271 GlobalAsm,
273 TypeNs(Symbol),
275 ValueNs(Symbol),
277 MacroNs(Symbol),
279 LifetimeNs(Symbol),
281 Closure,
283 TestBinderConstraints,
284
285 Ctor,
288 AnonConst,
290 OpaqueTy,
293 OpaqueLifetime(Symbol),
295 AnonAssocTy(Symbol),
298 SyntheticCoroutineBody,
300 NestedStatic,
302}
303
304impl Definitions {
305 pub fn commit_end_of_determinism(&mut self) {
308 if !self.def_path_hash_to_index.after_parallel_alloc.replace(Default::default()).is_none()
{
{
::core::panicking::panic_fmt(format_args!("this function should be called only once"));
}
}assert!(
309 self.def_path_hash_to_index.after_parallel_alloc.replace(Default::default()).is_none(),
310 "this function should be called only once"
311 )
312 }
313
314 #[inline(always)]
315 pub fn def_key(&self, id: LocalDefId) -> DefKey {
316 self.def_id_to_key[id]
317 }
318
319 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("def_path_hash",
"rustc_hir_id::definitions", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(321u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("def_index")
}> =
::tracing::__macro_support::FieldName::new("def_index");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id.local_def_index)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: DefPathHash = loop {};
return __tracing_attr_fake_return;
}
{
DefPathHash::new(self.stable_crate_id,
self.def_path_hashes[id])
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs:321",
"rustc_hir_id::definitions", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(321u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "trace", skip(self, id), fields(def_index=?id.local_def_index), ret)]
322 #[inline(always)]
323 pub fn def_path_hash(&self, id: LocalDefId) -> DefPathHash {
324 DefPathHash::new(self.stable_crate_id, self.def_path_hashes[id])
325 }
326
327 #[inline]
333 pub fn def_path(&self, id: LocalDefId) -> DefPath {
334 DefPath::make(LOCAL_CRATE, id.local_def_index, |index| {
335 self.def_key(LocalDefId { local_def_index: index })
336 })
337 }
338
339 pub fn new(stable_crate_id: StableCrateId) -> Definitions {
341 let key = DefKey {
342 parent: None,
343 disambiguated_data: DisambiguatedDefPathData {
344 data: DefPathData::CrateRoot,
345 disambiguator: 0,
346 },
347 };
348
349 let def_path_hash =
358 DefPathHash::new(stable_crate_id, Hash64::new(stable_crate_id.as_u64()));
359
360 let mut defs = Definitions {
361 stable_crate_id,
362 def_path_hashes: Default::default(),
363 def_id_to_key: Default::default(),
364 def_path_hash_to_index: Default::default(),
365 };
366
367 let root = defs.allocate(key, def_path_hash);
369 {
match (&root.local_def_index, &CRATE_DEF_INDEX) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(root.local_def_index, CRATE_DEF_INDEX);
370
371 defs
372 }
373
374 fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> LocalDefId {
375 if true {
{
match (&self.stable_crate_id, &def_path_hash.stable_crate_id()) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
};debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id());
377 let local_hash = def_path_hash.local_hash();
378
379 let def_id = self.def_id_to_key.push(key);
380 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs:380",
"rustc_hir_id::definitions", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(380u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("def_id_to_key.push() - {1:?} <-> {0:?}",
def_id.local_def_index, key) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("def_id_to_key.push() - {key:?} <-> {:?}", def_id.local_def_index);
381
382 self.def_path_hashes.push(local_hash);
383 if true {
if !(self.def_path_hashes.len() == self.def_id_to_key.len()) {
::core::panicking::panic("assertion failed: self.def_path_hashes.len() == self.def_id_to_key.len()")
};
};debug_assert!(self.def_path_hashes.len() == self.def_id_to_key.len());
384
385 if let Some(existing) =
388 self.def_path_hash_to_index.insert(local_hash, def_id.local_def_index)
389 {
390 let def_path1 = self.def_path(LocalDefId { local_def_index: existing });
391 let def_path2 = self.def_path(def_id);
392
393 {
::core::panicking::panic_fmt(format_args!("found DefPathHash collision between {0:#?} and {1:#?}. Compilation cannot continue.",
def_path1, def_path2));
};panic!(
402 "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \
403 Compilation cannot continue."
404 );
405 }
406
407 def_id
408 }
409
410 pub fn enumerated_keys_and_path_hashes(
411 &self,
412 ) -> impl Iterator<Item = (DefIndex, &DefKey, DefPathHash)> + ExactSizeIterator {
413 self.def_id_to_key
414 .iter_enumerated()
415 .map(move |(def_id, key)| (def_id.local_def_index, key, self.def_path_hash(def_id)))
416 }
417
418 pub fn create_def(
424 &mut self,
425 parent: LocalDefId,
426 data: DefPathData,
427 disambiguator: &mut PerParentDisambiguatorState,
428 ) -> LocalDefId {
429 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs:431",
"rustc_hir_id::definitions", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(431u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("create_def(parent={0}, data={1:?})",
self.def_path(parent).to_string_no_crate_verbose(), data) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
432 "create_def(parent={}, data={data:?})",
433 self.def_path(parent).to_string_no_crate_verbose(),
434 );
435
436 if !(data != DefPathData::CrateRoot) {
::core::panicking::panic("assertion failed: data != DefPathData::CrateRoot")
};assert!(data != DefPathData::CrateRoot);
438
439 let disambiguator = {
441 #[cfg(debug_assertions)]
442 if true {
{
match (&parent, &disambiguator.parent.expect("must be set")) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val,
::core::option::Option::Some(format_args!("provided parent and parent in disambiguator must be the same")));
}
}
}
};
};debug_assert_eq!(
443 parent,
444 disambiguator.parent.expect("must be set"),
445 "provided parent and parent in disambiguator must be the same"
446 );
447
448 let next_disamb = disambiguator.next.entry(data).or_insert(0);
449 let disambiguator = *next_disamb;
450 *next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
451 disambiguator
452 };
453 let key = DefKey {
454 parent: Some(parent.local_def_index),
455 disambiguated_data: DisambiguatedDefPathData { data, disambiguator },
456 };
457
458 let parent_hash = self.def_path_hash(parent);
459 let def_path_hash = key.compute_stable_hash(parent_hash);
460
461 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs:461",
"rustc_hir_id::definitions", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/822182db4c4a1827256881d8c7aa685f0bcf2b11/compiler/rustc_hir_id/src/definitions.rs"),
::tracing_core::__macro_support::Option::Some(461u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_id::definitions"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("create_def: after disambiguation, key = {0:?}",
key) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("create_def: after disambiguation, key = {:?}", key);
462
463 self.allocate(key, def_path_hash)
465 }
466
467 #[inline(always)]
468 pub fn local_def_path_hash_to_def_id(&self, hash: DefPathHash) -> Option<LocalDefId> {
474 if true {
if !(hash.stable_crate_id() == self.stable_crate_id) {
::core::panicking::panic("assertion failed: hash.stable_crate_id() == self.stable_crate_id")
};
};debug_assert!(hash.stable_crate_id() == self.stable_crate_id);
475 self.def_path_hash_to_index
476 .get(hash.local_hash())
477 .map(|local_def_index| LocalDefId { local_def_index })
478 }
479
480 pub fn def_path_hash_to_def_index_map(&self) -> &DefPathToIndexMap {
481 &self.def_path_hash_to_index
482 }
483
484 pub fn num_definitions(&self) -> usize {
485 self.def_path_hashes.len()
486 }
487}
488
489#[derive(#[automatically_derived]
impl ::core::marker::Copy for DefPathDataName { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DefPathDataName { }
#[automatically_derived]
impl ::core::clone::Clone for DefPathDataName {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Symbol>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for DefPathDataName { }
#[automatically_derived]
impl ::core::cmp::PartialEq for DefPathDataName {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Named(__self_0), Self::Named(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Anon { namespace: __self_0 }, Self::Anon {
namespace: __arg1_0 }) => __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for DefPathDataName {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Named(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Named",
&__self_0),
Self::Anon { namespace: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Anon",
"namespace", &__self_0),
}
}
}Debug)]
490pub enum DefPathDataName {
491 Named(Symbol),
492 Anon { namespace: Symbol },
493}
494
495impl DefPathData {
496 pub fn get_opt_name(&self) -> Option<Symbol> {
497 use self::DefPathData::*;
498 match *self {
499 TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name)
500 | OpaqueLifetime(name) => Some(name),
501
502 Impl
503 | ForeignMod
504 | CrateRoot
505 | Use
506 | GlobalAsm
507 | Closure
508 | Ctor
509 | AnonConst
510 | OpaqueTy
511 | AnonAssocTy(..)
512 | SyntheticCoroutineBody
513 | NestedStatic
514 | TestBinderConstraints => None,
515 }
516 }
517
518 fn hashed_symbol(&self) -> Option<Symbol> {
519 use self::DefPathData::*;
520 match *self {
521 TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | AnonAssocTy(name)
522 | OpaqueLifetime(name) => Some(name),
523
524 Impl
525 | ForeignMod
526 | CrateRoot
527 | Use
528 | GlobalAsm
529 | Closure
530 | Ctor
531 | AnonConst
532 | OpaqueTy
533 | SyntheticCoroutineBody
534 | NestedStatic
535 | TestBinderConstraints => None,
536 }
537 }
538
539 pub fn name(&self) -> DefPathDataName {
540 use self::DefPathData::*;
541 match *self {
542 TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name)
543 | OpaqueLifetime(name) => DefPathDataName::Named(name),
544 CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
546 Impl => DefPathDataName::Anon { namespace: kw::Impl },
547 ForeignMod => DefPathDataName::Anon { namespace: kw::Extern },
548 Use => DefPathDataName::Anon { namespace: kw::Use },
549 GlobalAsm => DefPathDataName::Anon { namespace: sym::global_asm },
550 Closure => DefPathDataName::Anon { namespace: sym::closure },
551 Ctor => DefPathDataName::Anon { namespace: sym::constructor },
552 AnonConst => DefPathDataName::Anon { namespace: sym::constant },
553 OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
554 AnonAssocTy(..) => DefPathDataName::Anon { namespace: sym::anon_assoc },
555 SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
556 NestedStatic => DefPathDataName::Anon { namespace: sym::nested },
557 TestBinderConstraints => {
558 DefPathDataName::Anon { namespace: sym::test_binder_constraints }
559 }
560 }
561 }
562}
563
564impl fmt::Display for DefPathData {
565 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
566 match self.name() {
567 DefPathDataName::Named(name) => f.write_str(name.as_str()),
568 DefPathDataName::Anon { namespace } => f.write_fmt(format_args!("{{{{{0}}}}}", namespace))write!(f, "{{{{{namespace}}}}}"),
570 }
571 }
572}