1use std::iter::TrustedLen;
4use std::path::{Path, PathBuf};
5use std::sync::{Arc, OnceLock};
6use std::{io, mem};
7
8pub(super) use cstore_impl::provide;
9use rustc_ast as ast;
10use rustc_attr_ir::CanonicalSymbols;
11use rustc_attr_ir::diagnostic_items::DiagnosticItems;
12use rustc_crate_store::{CrateSource, ExternCrate};
13use rustc_data_structures::fingerprint::Fingerprint;
14use rustc_data_structures::fx::FxIndexMap;
15use rustc_data_structures::owned_slice::OwnedSlice;
16use rustc_data_structures::sync::Lock;
17use rustc_data_structures::unhash::UnhashMap;
18use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
19use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
20use rustc_hir::Safety;
21use rustc_hir::def::Res;
22use rustc_hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE};
23use rustc_hir::definitions::{DefPath, DefPathData};
24use rustc_index::Idx;
25use rustc_middle::middle::lib_features::LibFeatures;
26use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
27use rustc_middle::ty::codec::{TyDecoder, forward_all_decoder_methods_to};
28use rustc_middle::ty::{RestrictionKind, Visibility};
29use rustc_proc_macro::bridge::client::Client as ProcMacroClient;
30use rustc_serialize::opaque::MemDecoder;
31use rustc_serialize::{Decodable, Decoder};
32use rustc_session::config::TargetModifier;
33use rustc_session::config::mitigation_coverage::DeniedPartialMitigation;
34use rustc_span::def_id::ModId;
35use rustc_span::hygiene::HygieneDecodeContext;
36use rustc_span::{
37 BlobDecoder, BytePos, ByteSymbol, DUMMY_SP, Pos, RemapPathScopeComponents, SpanData,
38 SpanDecoder, Symbol, SyntaxContext, bug, kw,
39};
40use tracing::debug;
41
42use crate::creader::CStore;
43use crate::eii::EiiMapEncodedKeyValue;
44use crate::rmeta::remapped_def_id::RemappedRawDefId;
45use crate::rmeta::table::IsDefault;
46use crate::rmeta::*;
47
48mod cstore_impl;
49
50pub(crate) struct MetadataBlob(OwnedSlice);
54
55impl std::ops::Deref for MetadataBlob {
56 type Target = [u8];
57
58 #[inline]
59 fn deref(&self) -> &[u8] {
60 &self.0[..]
61 }
62}
63
64impl MetadataBlob {
65 pub(crate) fn new(slice: OwnedSlice) -> Result<Self, ()> {
67 if MemDecoder::new(&slice, 0).is_ok() { Ok(Self(slice)) } else { Err(()) }
68 }
69
70 pub(crate) fn bytes(&self) -> &OwnedSlice {
73 &self.0
74 }
75}
76
77pub(crate) type CrateNumMap = IndexVec<CrateNum, CrateNum>;
82
83pub(crate) type TargetModifiers = Vec<TargetModifier>;
86
87pub(crate) type DeniedPartialMitigations = Vec<DeniedPartialMitigation>;
91
92pub(crate) struct CrateMetadata {
93 blob: MetadataBlob,
95
96 root: CrateRoot,
99 unhashed: CrateRootUnhashed,
101 trait_impls: FxIndexMap<RemappedRawDefId, LazyArray<(LocalDefId, Option<SimplifiedType>)>>,
108 incoherent_impls: FxIndexMap<SimplifiedType, LazyArray<LocalDefId>>,
116 raw_proc_macros: Option<&'static [ProcMacroClient]>,
118 source_map_import_info: Lock<Vec<Option<ImportedSourceFile>>>,
120 def_path_hash_map: DefPathHashMapRef<'static>,
122 expn_hash_map: OnceLock<UnhashMap<ExpnHash, ExpnIndex>>,
124 alloc_decoding_state: AllocDecodingState,
126 def_key_cache: Lock<FxHashMap<DefIndex, DefKey>>,
128
129 cnum: CrateNum,
132 cnum_map: CrateNumMap,
135 dep_kind: CrateDepKind,
137 source: Arc<CrateSource>,
139 private_dep: bool,
143 host_hash: Option<Svh>,
145 used: bool,
147
148 hygiene_context: HygieneDecodeContext,
154
155 extern_crate: Option<ExternCrate>,
159}
160
161#[derive(#[automatically_derived]impl ::core::clone::Clone for ImportedSourceFile {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
ImportedSourceFile {
original_start_pos: ::core::clone::Clone::clone(&self.original_start_pos),
original_end_pos: ::core::clone::Clone::clone(&self.original_end_pos),
translated_source_file: ::core::clone::Clone::clone(&self.translated_source_file),
}
}
}Clone)]
164struct ImportedSourceFile {
165 original_start_pos: rustc_span::BytePos,
167 original_end_pos: rustc_span::BytePos,
169 translated_source_file: Arc<rustc_span::SourceFile>,
171}
172
173pub(super) struct BlobDecodeContext<'a> {
177 opaque: MemDecoder<'a>,
178 blob: &'a MetadataBlob,
179 lazy_state: LazyState,
180}
181
182pub(super) trait LazyDecoder: BlobDecoder {
188 fn set_lazy_state(&mut self, state: LazyState);
189 fn get_lazy_state(&self) -> LazyState;
190
191 fn read_lazy<T>(&mut self) -> LazyValue<T> {
192 self.read_lazy_offset_then(|pos| LazyValue::from_position(pos))
193 }
194
195 fn read_lazy_array<T>(&mut self, len: usize) -> LazyArray<T> {
196 self.read_lazy_offset_then(|pos| LazyArray::from_position_and_num_elems(pos, len))
197 }
198
199 fn read_lazy_table<Ie, Id, T>(
200 &mut self,
201 width_and_sparse: usize,
202 len: usize,
203 ) -> LazyTable<Ie, Id, T> {
204 self.read_lazy_offset_then(|pos| {
205 LazyTable::from_position_and_encoded_size(pos, width_and_sparse, len)
206 })
207 }
208
209 #[inline]
210 fn read_lazy_offset_then<T>(&mut self, f: impl Fn(NonZero<usize>) -> T) -> T {
211 let distance = self.read_usize();
212 let position = match self.get_lazy_state() {
213 LazyState::NoNode => ::rustc_span::macros::bug_impl(None,
format_args!("read_lazy_with_meta: outside of a metadata node"),
Location::caller())bug!("read_lazy_with_meta: outside of a metadata node"),
214 LazyState::NodeStart(start) => {
215 let start = start.get();
216 if !(distance <= start) {
::core::panicking::panic("assertion failed: distance <= start")
};assert!(distance <= start);
217 start - distance
218 }
219 LazyState::Previous(last_pos) => last_pos.get() + distance,
220 };
221 let position = NonZero::new(position).unwrap();
222 self.set_lazy_state(LazyState::Previous(position));
223 f(position)
224 }
225}
226
227impl<'a> LazyDecoder for BlobDecodeContext<'a> {
228 fn set_lazy_state(&mut self, state: LazyState) {
229 self.lazy_state = state;
230 }
231
232 fn get_lazy_state(&self) -> LazyState {
233 self.lazy_state
234 }
235}
236
237pub(super) struct MetadataDecodeContext<'a, 'tcx> {
242 blob_decoder: BlobDecodeContext<'a>,
243 cdata: &'a CrateMetadata,
244 tcx: TyCtxt<'tcx>,
245
246 alloc_decoding_session: AllocDecodingSession<'a>,
248}
249
250impl<'a, 'tcx> LazyDecoder for MetadataDecodeContext<'a, 'tcx> {
251 fn set_lazy_state(&mut self, state: LazyState) {
252 self.blob_decoder.lazy_state = state;
253 }
254
255 fn get_lazy_state(&self) -> LazyState {
256 self.blob_decoder.lazy_state
257 }
258}
259
260pub(super) trait MetaBlob<'a>: Copy {
261 fn blob(&self) -> &'a MetadataBlob;
262}
263
264pub(super) trait MetaDecoder: Copy {
265 type Context: BlobDecoder + LazyDecoder;
266
267 fn decoder(self, pos: usize) -> Self::Context;
268}
269
270impl<'a> MetaBlob<'a> for &'a MetadataBlob {
271 fn blob(&self) -> &'a MetadataBlob {
272 self
273 }
274}
275
276impl<'a> MetaDecoder for &'a MetadataBlob {
277 type Context = BlobDecodeContext<'a>;
278
279 fn decoder(self, pos: usize) -> Self::Context {
280 BlobDecodeContext {
281 opaque: MemDecoder::new(self, pos).unwrap(),
289 lazy_state: LazyState::NoNode,
290 blob: self.blob(),
291 }
292 }
293}
294
295impl<'a> MetaBlob<'a> for &'a CrateMetadata {
296 fn blob(&self) -> &'a MetadataBlob {
297 &self.blob
298 }
299}
300
301impl<'a, 'tcx> MetaDecoder for (&'a CrateMetadata, TyCtxt<'tcx>) {
302 type Context = MetadataDecodeContext<'a, 'tcx>;
303
304 fn decoder(self, pos: usize) -> MetadataDecodeContext<'a, 'tcx> {
305 MetadataDecodeContext {
306 blob_decoder: self.0.blob().decoder(pos),
307 cdata: self.0,
308 tcx: self.1,
309 alloc_decoding_session: self.0.alloc_decoding_state.new_decoding_session(),
310 }
311 }
312}
313
314impl<T: ParameterizedOverTcx> LazyValue<T> {
315 #[inline]
316 fn decode<'tcx, M: MetaDecoder>(self, metadata: M) -> T::Value<'tcx>
317 where
318 T::Value<'tcx>: Decodable<M::Context>,
319 {
320 let mut dcx = metadata.decoder(self.position.get());
321 dcx.set_lazy_state(LazyState::NodeStart(self.position));
322 T::Value::decode(&mut dcx)
323 }
324}
325
326struct DecodeIterator<T, D> {
327 elem_counter: std::ops::Range<usize>,
328 dcx: D,
329 _phantom: PhantomData<fn() -> T>,
330}
331
332impl<D: Decoder, T: Decodable<D>> Iterator for DecodeIterator<T, D> {
333 type Item = T;
334
335 #[inline(always)]
336 fn next(&mut self) -> Option<Self::Item> {
337 self.elem_counter.next().map(|_| T::decode(&mut self.dcx))
338 }
339
340 #[inline(always)]
341 fn size_hint(&self) -> (usize, Option<usize>) {
342 self.elem_counter.size_hint()
343 }
344}
345
346impl<D: Decoder, T: Decodable<D>> ExactSizeIterator for DecodeIterator<T, D> {
347 fn len(&self) -> usize {
348 self.elem_counter.len()
349 }
350}
351
352unsafe impl<D: Decoder, T: Decodable<D>> TrustedLen for DecodeIterator<T, D> {}
353
354impl<T: ParameterizedOverTcx> LazyArray<T> {
355 #[inline]
356 fn decode<'tcx, M: MetaDecoder>(self, metadata: M) -> DecodeIterator<T::Value<'tcx>, M::Context>
357 where
358 T::Value<'tcx>: Decodable<M::Context>,
359 {
360 let mut dcx = metadata.decoder(self.position.get());
361 dcx.set_lazy_state(LazyState::NodeStart(self.position));
362 DecodeIterator { elem_counter: (0..self.num_elems), dcx, _phantom: PhantomData }
363 }
364}
365
366impl<'a, 'tcx> MetadataDecodeContext<'a, 'tcx> {
367 #[inline]
368 fn map_encoded_cnum_to_current(&self, cnum: CrateNum) -> CrateNum {
369 self.cdata.map_encoded_cnum_to_current(cnum)
370 }
371}
372
373impl<'a> BlobDecodeContext<'a> {
374 #[inline]
375 pub(crate) fn blob(&self) -> &'a MetadataBlob {
376 self.blob
377 }
378
379 fn decode_symbol_or_byte_symbol<S>(
380 &mut self,
381 new_from_index: impl Fn(u32) -> S,
382 read_and_intern_str_or_byte_str_this: impl Fn(&mut Self) -> S,
383 read_and_intern_str_or_byte_str_opaque: impl Fn(&mut MemDecoder<'a>) -> S,
384 ) -> S {
385 let tag = self.read_u8();
386
387 match tag {
388 SYMBOL_STR => read_and_intern_str_or_byte_str_this(self),
389 SYMBOL_OFFSET => {
390 let pos = self.read_usize();
392
393 self.opaque.with_position(pos, |d| read_and_intern_str_or_byte_str_opaque(d))
395 }
396 SYMBOL_PREDEFINED => new_from_index(self.read_u32()),
397 _ => ::core::panicking::unreachable_default_msg()unreachable!(),
398 }
399 }
400}
401
402impl<'a, 'tcx> TyDecoder<'tcx> for MetadataDecodeContext<'a, 'tcx> {
403 const CLEAR_CROSS_CRATE: bool = true;
404
405 fn cached_ty_for_shorthand<F>(&mut self, shorthand: usize, or_insert_with: F) -> Ty<'tcx>
406 where
407 F: FnOnce(&mut Self) -> Ty<'tcx>,
408 {
409 let tcx = self.tcx;
410
411 let key = ty::CReaderCacheKey { cnum: Some(self.cdata.cnum), pos: shorthand };
412
413 if let Some(&ty) = tcx.caches.ty_rcache.borrow().get(&key) {
414 return ty;
415 }
416
417 let ty = or_insert_with(self);
418 tcx.caches.ty_rcache.borrow_mut().insert(key, ty);
419 ty
420 }
421
422 fn with_position<F, R>(&mut self, pos: usize, f: F) -> R
423 where
424 F: FnOnce(&mut Self) -> R,
425 {
426 let new_opaque = self.blob_decoder.opaque.split_at(pos);
427 let old_opaque = mem::replace(&mut self.blob_decoder.opaque, new_opaque);
428 let old_state = mem::replace(&mut self.blob_decoder.lazy_state, LazyState::NoNode);
429 let r = f(self);
430 self.blob_decoder.opaque = old_opaque;
431 self.blob_decoder.lazy_state = old_state;
432 r
433 }
434
435 fn decode_alloc_id(&mut self) -> rustc_middle::mir::interpret::AllocId {
436 let ads = self.alloc_decoding_session;
437 ads.decode_alloc_id(self)
438 }
439}
440
441impl<'a, 'tcx> rustc_middle::ty::InternerDecoder for MetadataDecodeContext<'a, 'tcx> {
442 type Interner = TyCtxt<'tcx>;
443
444 #[inline]
445 fn interner(&self) -> TyCtxt<'tcx> {
446 self.tcx
447 }
448}
449
450impl<'a, 'tcx> Decodable<MetadataDecodeContext<'a, 'tcx>> for ExpnIndex {
451 #[inline]
452 fn decode(d: &mut MetadataDecodeContext<'a, 'tcx>) -> ExpnIndex {
453 ExpnIndex::from_u32(d.read_u32())
454 }
455}
456
457impl<'a, 'tcx> SpanDecoder for MetadataDecodeContext<'a, 'tcx> {
458 fn decode_attr_id(&mut self) -> rustc_span::AttrId {
459 self.tcx.sess.psess.attr_id_generator.mk_attr_id()
460 }
461
462 fn decode_crate_num(&mut self) -> CrateNum {
463 let cnum = CrateNum::from_u32(self.read_u32());
464 self.map_encoded_cnum_to_current(cnum)
465 }
466
467 fn decode_def_id(&mut self) -> DefId {
468 DefId { krate: Decodable::decode(self), index: Decodable::decode(self) }
469 }
470
471 fn decode_syntax_context(&mut self) -> SyntaxContext {
472 let cdata = self.cdata;
473 let tcx = self.tcx;
474
475 let cname = cdata.root.name();
476 rustc_span::hygiene::decode_syntax_context(
477 self,
478 &cdata.hygiene_context,
479 |_, external_ctxt| {
480 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:480",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(480u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::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!("SpecializedDecoder<SyntaxContext>: decoding {0:?}",
external_ctxt) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("SpecializedDecoder<SyntaxContext>: decoding {:?}", external_ctxt);
481 cdata
482 .root
483 .syntax_contexts
484 .get(cdata, external_ctxt)
485 .unwrap_or_else(|| {
486 {
::core::panicking::panic_fmt(format_args!("Missing SyntaxContext {0:?} for crate {1:?}",
external_ctxt, cname));
}panic!("Missing SyntaxContext {external_ctxt:?} for crate {cname:?}")
487 })
488 .decode((cdata, tcx))
489 },
490 )
491 }
492
493 fn decode_expn_id(&mut self) -> ExpnId {
494 let tcx = self.tcx;
495 let cnum = CrateNum::decode(self);
496 let index = u32::decode(self);
497
498 let expn_id = rustc_span::hygiene::decode_expn_id(cnum, index, |expn_id| {
499 let ExpnId { krate: cnum, local_id: index } = expn_id;
500 if true {
{
match (&cnum, &LOCAL_CRATE) {
(left_val, right_val) => {
if *left_val == *right_val {
let kind = ::core::panicking::AssertKind::Ne;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
};debug_assert_ne!(cnum, LOCAL_CRATE);
503 let cstore;
504 let cdata = if cnum == self.cdata.cnum {
505 self.cdata
506 } else {
507 cstore = CStore::from_tcx(tcx);
508 cstore.get_crate_data(cnum)
509 };
510 let expn_data = cdata.root.expn_data.get(cdata, index).unwrap().decode((cdata, tcx));
511 let expn_hash = cdata.root.expn_hashes.get(cdata, index).unwrap().decode((cdata, tcx));
512 (expn_data, expn_hash)
513 });
514 expn_id
515 }
516
517 fn decode_span(&mut self) -> Span {
518 let start = self.position();
519 let tag = SpanTag(self.peek_byte());
520 let data = if tag.kind() == SpanKind::Indirect {
521 self.read_u8();
523 let bytes_needed = tag.length().unwrap().0 as usize;
525 let mut total = [0u8; usize::BITS as usize / 8];
526 total[..bytes_needed].copy_from_slice(self.read_raw_bytes(bytes_needed));
527 let offset_or_position = usize::from_le_bytes(total);
528 let position = if tag.is_relative_offset() {
529 start - offset_or_position
530 } else {
531 offset_or_position
532 };
533 self.with_position(position, SpanData::decode)
534 } else {
535 SpanData::decode(self)
536 };
537 data.span()
538 }
539}
540
541impl<'a, 'tcx> BlobDecoder for MetadataDecodeContext<'a, 'tcx> {
542 fn decode_def_index(&mut self) -> DefIndex {
543 self.blob_decoder.decode_def_index()
544 }
545 fn decode_symbol(&mut self) -> Symbol {
546 self.blob_decoder.decode_symbol()
547 }
548
549 fn decode_byte_symbol(&mut self) -> ByteSymbol {
550 self.blob_decoder.decode_byte_symbol()
551 }
552
553 fn decode_local_def_id(&mut self) -> LocalDefId {
554 self.blob_decoder.decode_local_def_id()
555 }
556}
557
558impl<'a> BlobDecoder for BlobDecodeContext<'a> {
559 fn decode_def_index(&mut self) -> DefIndex {
560 DefIndex::from_u32(self.read_u32())
561 }
562 fn decode_symbol(&mut self) -> Symbol {
563 self.decode_symbol_or_byte_symbol(
564 Symbol::new,
565 |this| Symbol::intern(this.read_str()),
566 |opaque| Symbol::intern(opaque.read_str()),
567 )
568 }
569
570 fn decode_byte_symbol(&mut self) -> ByteSymbol {
571 self.decode_symbol_or_byte_symbol(
572 ByteSymbol::new,
573 |this| ByteSymbol::intern(this.read_byte_str()),
574 |opaque| ByteSymbol::intern(opaque.read_byte_str()),
575 )
576 }
577
578 fn decode_local_def_id(&mut self) -> LocalDefId {
584 LocalDefId { local_def_index: Decodable::decode(self) }
585 }
586}
587
588impl<'a, 'tcx> Decodable<MetadataDecodeContext<'a, 'tcx>> for SpanData {
589 fn decode(decoder: &mut MetadataDecodeContext<'a, 'tcx>) -> SpanData {
590 let tag = SpanTag::decode(decoder);
591 let ctxt = tag.context().unwrap_or_else(|| SyntaxContext::decode(decoder));
592
593 if tag.kind() == SpanKind::Partial {
594 return DUMMY_SP.with_ctxt(ctxt).data();
595 }
596
597 if true {
if !(tag.kind() == SpanKind::Local || tag.kind() == SpanKind::Foreign) {
::core::panicking::panic("assertion failed: tag.kind() == SpanKind::Local || tag.kind() == SpanKind::Foreign")
};
};debug_assert!(tag.kind() == SpanKind::Local || tag.kind() == SpanKind::Foreign);
598
599 let lo = BytePos::decode(decoder);
600 let len = tag.length().unwrap_or_else(|| BytePos::decode(decoder));
601 let hi = lo + len;
602
603 let tcx = decoder.tcx;
604
605 let metadata_index = u32::decode(decoder);
607
608 let source_file = if tag.kind() == SpanKind::Local {
637 decoder.cdata.imported_source_file(tcx, metadata_index)
638 } else {
639 if decoder.cdata.root.is_proc_macro_crate() {
642 let cnum = u32::decode(decoder);
645 {
::core::panicking::panic_fmt(format_args!("Decoding of crate {0:?} tried to access proc-macro dep {1:?}",
decoder.cdata.root.header.name, cnum));
};panic!(
646 "Decoding of crate {:?} tried to access proc-macro dep {:?}",
647 decoder.cdata.root.header.name, cnum
648 );
649 }
650 let cnum = CrateNum::decode(decoder);
652 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:652",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(652u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::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!("SpecializedDecoder<Span>::specialized_decode: loading source files from cnum {0:?}",
cnum) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
653 "SpecializedDecoder<Span>::specialized_decode: loading source files from cnum {:?}",
654 cnum
655 );
656
657 let cstore = CStore::from_tcx(tcx);
658 let foreign_cdata = cstore.get_crate_data(cnum);
659 foreign_cdata.imported_source_file(tcx, metadata_index)
660 };
661
662 if true {
if !(lo + source_file.original_start_pos <= source_file.original_end_pos)
{
{
::core::panicking::panic_fmt(format_args!("Malformed encoded span: lo={0:?} source_file.original_start_pos={1:?} source_file.original_end_pos={2:?}",
lo, source_file.original_start_pos,
source_file.original_end_pos));
}
};
};debug_assert!(
664 lo + source_file.original_start_pos <= source_file.original_end_pos,
665 "Malformed encoded span: lo={:?} source_file.original_start_pos={:?} source_file.original_end_pos={:?}",
666 lo,
667 source_file.original_start_pos,
668 source_file.original_end_pos
669 );
670
671 if true {
if !(hi + source_file.original_start_pos <= source_file.original_end_pos)
{
{
::core::panicking::panic_fmt(format_args!("Malformed encoded span: hi={0:?} source_file.original_start_pos={1:?} source_file.original_end_pos={2:?}",
hi, source_file.original_start_pos,
source_file.original_end_pos));
}
};
};debug_assert!(
673 hi + source_file.original_start_pos <= source_file.original_end_pos,
674 "Malformed encoded span: hi={:?} source_file.original_start_pos={:?} source_file.original_end_pos={:?}",
675 hi,
676 source_file.original_start_pos,
677 source_file.original_end_pos
678 );
679
680 let lo = lo + source_file.translated_source_file.start_pos;
681 let hi = hi + source_file.translated_source_file.start_pos;
682
683 SpanData { lo, hi, ctxt, parent: None }
685 }
686}
687
688impl<D: LazyDecoder, T> Decodable<D> for LazyValue<T> {
689 fn decode(decoder: &mut D) -> Self {
690 decoder.read_lazy()
691 }
692}
693
694impl<D: LazyDecoder, T> Decodable<D> for LazyArray<T> {
695 #[inline]
696 fn decode(decoder: &mut D) -> Self {
697 let len = decoder.read_usize();
698 if len == 0 { LazyArray::default() } else { decoder.read_lazy_array(len) }
699 }
700}
701
702impl<Ie: Idx, Id: Idx, D: LazyDecoder, T> Decodable<D> for LazyTable<Ie, Id, T> {
703 fn decode(decoder: &mut D) -> Self {
704 let width_and_sparse = decoder.read_usize();
705 let len = decoder.read_usize();
706 decoder.read_lazy_table(width_and_sparse, len)
707 }
708}
709
710impl<'a, 'tcx> Decoder for MetadataDecodeContext<'a, 'tcx> {
711 #[inline]
fn read_usize(&mut self) -> usize { self.blob_decoder.opaque.read_usize() }
#[inline]
fn read_u128(&mut self) -> u128 { self.blob_decoder.opaque.read_u128() }
#[inline]
fn read_u64(&mut self) -> u64 { self.blob_decoder.opaque.read_u64() }
#[inline]
fn read_u32(&mut self) -> u32 { self.blob_decoder.opaque.read_u32() }
#[inline]
fn read_u16(&mut self) -> u16 { self.blob_decoder.opaque.read_u16() }
#[inline]
fn read_u8(&mut self) -> u8 { self.blob_decoder.opaque.read_u8() }
#[inline]
fn read_isize(&mut self) -> isize { self.blob_decoder.opaque.read_isize() }
#[inline]
fn read_i128(&mut self) -> i128 { self.blob_decoder.opaque.read_i128() }
#[inline]
fn read_i64(&mut self) -> i64 { self.blob_decoder.opaque.read_i64() }
#[inline]
fn read_i32(&mut self) -> i32 { self.blob_decoder.opaque.read_i32() }
#[inline]
fn read_i16(&mut self) -> i16 { self.blob_decoder.opaque.read_i16() }
#[inline]
fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
self.blob_decoder.opaque.read_raw_bytes(len)
}
#[inline]
fn peek_byte(&self) -> u8 { self.blob_decoder.opaque.peek_byte() }
#[inline]
fn position(&self) -> usize { self.blob_decoder.opaque.position() }forward_all_decoder_methods_to!(|self| self.blob_decoder.opaque);
712}
713
714impl<'a> Decoder for BlobDecodeContext<'a> {
715 #[inline]
fn read_usize(&mut self) -> usize { self.opaque.read_usize() }
#[inline]
fn read_u128(&mut self) -> u128 { self.opaque.read_u128() }
#[inline]
fn read_u64(&mut self) -> u64 { self.opaque.read_u64() }
#[inline]
fn read_u32(&mut self) -> u32 { self.opaque.read_u32() }
#[inline]
fn read_u16(&mut self) -> u16 { self.opaque.read_u16() }
#[inline]
fn read_u8(&mut self) -> u8 { self.opaque.read_u8() }
#[inline]
fn read_isize(&mut self) -> isize { self.opaque.read_isize() }
#[inline]
fn read_i128(&mut self) -> i128 { self.opaque.read_i128() }
#[inline]
fn read_i64(&mut self) -> i64 { self.opaque.read_i64() }
#[inline]
fn read_i32(&mut self) -> i32 { self.opaque.read_i32() }
#[inline]
fn read_i16(&mut self) -> i16 { self.opaque.read_i16() }
#[inline]
fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
self.opaque.read_raw_bytes(len)
}
#[inline]
fn peek_byte(&self) -> u8 { self.opaque.peek_byte() }
#[inline]
fn position(&self) -> usize { self.opaque.position() }forward_all_decoder_methods_to!(|self| self.opaque);
716}
717
718impl MetadataBlob {
719 pub(crate) fn check_compatibility(
720 &self,
721 cfg_version: &'static str,
722 ) -> Result<(), Option<String>> {
723 if !self.starts_with(METADATA_HEADER) {
724 if self.starts_with(b"rust") {
725 return Err(Some("<unknown rustc version>".to_owned()));
726 }
727 return Err(None);
728 }
729
730 let found_version =
731 LazyValue::<String>::from_position(NonZero::new(VERSION_OFFSET).unwrap()).decode(self);
732 if rustc_version(cfg_version) != found_version {
733 return Err(Some(found_version));
734 }
735
736 Ok(())
737 }
738
739 fn root_pos(&self) -> NonZero<usize> {
740 let pos_bytes = self[ROOT_POS_OFFSET..][..8].try_into().unwrap();
741 let pos = u64::from_le_bytes(pos_bytes);
742 NonZero::new(pos as usize).unwrap()
743 }
744
745 fn unhashed_pos(&self) -> NonZero<usize> {
746 let pos_bytes = self[UNHASHED_POS_OFFSET..][..8].try_into().unwrap();
747 let pos = u64::from_le_bytes(pos_bytes);
748 NonZero::new(pos as usize).unwrap()
749 }
750
751 pub(crate) fn get_header(&self) -> CrateHeader {
752 let pos = self.root_pos();
753 LazyValue::<CrateHeader>::from_position(pos).decode(self)
754 }
755
756 pub(crate) fn get_root(&self) -> CrateRoot {
757 let pos = self.root_pos();
758 LazyValue::<CrateRoot>::from_position(pos).decode(self)
759 }
760
761 pub(crate) fn get_root_unhashed(&self) -> CrateRootUnhashed {
762 let pos = self.unhashed_pos();
763 LazyValue::<CrateRootUnhashed>::from_position(pos).decode(self)
764 }
765
766 pub(crate) fn get_dep_extra_filenames(&self) -> IndexVec<CrateNum, String> {
767 self.get_root_unhashed().dep_extra_filenames
768 }
769
770 pub(crate) fn get_crate_hash(&self) -> Svh {
771 let bytes: [u8; CRATE_HASH_LEN] =
772 self[CRATE_HASH_OFFSET..][..CRATE_HASH_LEN].try_into().unwrap();
773 Svh::new(Fingerprint::from_le_bytes(bytes))
774 }
775
776 pub(crate) fn list_crate_metadata(
777 &self,
778 out: &mut dyn io::Write,
779 ls_kinds: &[String],
780 ) -> io::Result<()> {
781 let root = self.get_root();
782 let extra_filename = self.get_root_unhashed().extra_filename;
783
784 let all_ls_kinds = ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
["root".to_owned(), "lang_items".to_owned(), "features".to_owned(),
"items".to_owned(), "target_modifiers".to_owned()]))vec![
785 "root".to_owned(),
786 "lang_items".to_owned(),
787 "features".to_owned(),
788 "items".to_owned(),
789 "target_modifiers".to_owned(),
790 ];
791 let ls_kinds = if ls_kinds.contains(&"all".to_owned()) { &all_ls_kinds } else { ls_kinds };
792
793 for kind in ls_kinds {
794 match &**kind {
795 "root" => {
796 out.write_fmt(format_args!("Crate info:\n"))writeln!(out, "Crate info:")?;
797 out.write_fmt(format_args!("name {0}{1}\n", root.name(), extra_filename))writeln!(out, "name {}{}", root.name(), extra_filename)?;
798 out.write_fmt(format_args!("hash {0} stable_crate_id {1:?}\n",
self.get_crate_hash(), root.stable_crate_id))writeln!(
799 out,
800 "hash {} stable_crate_id {:?}",
801 self.get_crate_hash(),
802 root.stable_crate_id
803 )?;
804 out.write_fmt(format_args!("proc_macro {0:?}\n",
root.proc_macro_data.is_some()))writeln!(out, "proc_macro {:?}", root.proc_macro_data.is_some())?;
805 out.write_fmt(format_args!("triple {0}\n", root.header.triple.tuple()))writeln!(out, "triple {}", root.header.triple.tuple())?;
806 out.write_fmt(format_args!("edition {0}\n", root.edition))writeln!(out, "edition {}", root.edition)?;
807 out.write_fmt(format_args!("symbol_mangling_version {0:?}\n",
root.symbol_mangling_version))writeln!(out, "symbol_mangling_version {:?}", root.symbol_mangling_version)?;
808 out.write_fmt(format_args!("required_panic_strategy {0:?} panic_in_drop_strategy {1:?}\n",
root.required_panic_strategy, root.panic_in_drop_strategy))writeln!(
809 out,
810 "required_panic_strategy {:?} panic_in_drop_strategy {:?}",
811 root.required_panic_strategy, root.panic_in_drop_strategy
812 )?;
813 out.write_fmt(format_args!("has_global_allocator {0} has_alloc_error_handler {1} has_panic_handler {2} has_default_lib_allocator {3}\n",
root.has_global_allocator, root.has_alloc_error_handler,
root.has_panic_handler, root.has_default_lib_allocator))writeln!(
814 out,
815 "has_global_allocator {} has_alloc_error_handler {} has_panic_handler {} has_default_lib_allocator {}",
816 root.has_global_allocator,
817 root.has_alloc_error_handler,
818 root.has_panic_handler,
819 root.has_default_lib_allocator
820 )?;
821 out.write_fmt(format_args!("compiler_builtins {0} needs_allocator {1} needs_panic_runtime {2} no_builtins {3} panic_runtime {4} profiler_runtime {5}\n",
root.compiler_builtins, root.needs_allocator,
root.needs_panic_runtime, root.no_builtins, root.panic_runtime,
root.profiler_runtime))writeln!(
822 out,
823 "compiler_builtins {} needs_allocator {} needs_panic_runtime {} no_builtins {} panic_runtime {} profiler_runtime {}",
824 root.compiler_builtins,
825 root.needs_allocator,
826 root.needs_panic_runtime,
827 root.no_builtins,
828 root.panic_runtime,
829 root.profiler_runtime
830 )?;
831
832 out.write_fmt(format_args!("=External Dependencies=\n"))writeln!(out, "=External Dependencies=")?;
833 let dylib_dependency_formats =
834 root.dylib_dependency_formats.decode(self).collect::<Vec<_>>();
835 let dep_extra_filenames = self.get_dep_extra_filenames();
838 for (i, dep) in root.crate_deps.decode(self).enumerate() {
839 let CrateDep { name, hash, host_hash, kind, is_private } = dep;
840 let number = i + 1;
841 let extra_filename = dep_extra_filenames
842 .get(CrateNum::new(number))
843 .map_or("", |name| name.as_str());
844
845 out.write_fmt(format_args!("{2} {3}{4} hash {5} host_hash {6:?} kind {7:?} {0}{1}\n",
if is_private { "private" } else { "public" },
if dylib_dependency_formats.is_empty() {
String::new()
} else {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" linkage {0:?}",
dylib_dependency_formats[i]))
})
}, number, name, extra_filename, hash, host_hash, kind))writeln!(
846 out,
847 "{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?} {privacy}{linkage}",
848 privacy = if is_private { "private" } else { "public" },
849 linkage = if dylib_dependency_formats.is_empty() {
850 String::new()
851 } else {
852 format!(" linkage {:?}", dylib_dependency_formats[i])
853 }
854 )?;
855 }
856 out.write_fmt(format_args!("\n"))write!(out, "\n")?;
857 }
858
859 "lang_items" => {
860 out.write_fmt(format_args!("=Lang items=\n"))writeln!(out, "=Lang items=")?;
861 for (id, lang_item) in root.lang_items.decode(self) {
862 out.write_fmt(format_args!("{0} = crate{1}\n", lang_item.name(),
DefPath::make(LOCAL_CRATE, id.local_def_index,
|parent|
root.tables.def_keys.get(self,
parent).unwrap().decode(self)).to_string_no_crate_verbose()))writeln!(
863 out,
864 "{} = crate{}",
865 lang_item.name(),
866 DefPath::make(LOCAL_CRATE, id.local_def_index, |parent| root
867 .tables
868 .def_keys
869 .get(self, parent)
870 .unwrap()
871 .decode(self))
872 .to_string_no_crate_verbose()
873 )?;
874 }
875 for lang_item in root.lang_items_missing.decode(self) {
876 out.write_fmt(format_args!("{0} = <missing>\n", lang_item.name()))writeln!(out, "{} = <missing>", lang_item.name())?;
877 }
878 out.write_fmt(format_args!("\n"))write!(out, "\n")?;
879 }
880
881 "features" => {
882 out.write_fmt(format_args!("=Lib features=\n"))writeln!(out, "=Lib features=")?;
883 for (feature, since) in root.lib_features.decode(self) {
884 out.write_fmt(format_args!("{0}{1}\n", feature,
if let FeatureStability::AcceptedSince(since) = since {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" since {0}", since))
})
} else { String::new() }))writeln!(
885 out,
886 "{}{}",
887 feature,
888 if let FeatureStability::AcceptedSince(since) = since {
889 format!(" since {since}")
890 } else {
891 String::new()
892 }
893 )?;
894 }
895 out.write_fmt(format_args!("\n"))write!(out, "\n")?;
896 }
897
898 "items" => {
899 out.write_fmt(format_args!("=Items=\n"))writeln!(out, "=Items=")?;
900
901 fn print_item(
902 blob: &MetadataBlob,
903 out: &mut dyn io::Write,
904 item: DefIndex,
905 indent: usize,
906 ) -> io::Result<()> {
907 let root = blob.get_root();
908
909 let def_kind = root.tables.def_kind.get(blob, item).unwrap();
910 let def_key = root.tables.def_keys.get(blob, item).unwrap().decode(blob);
911 #[allow(rustc::symbol_intern_string_literal)]
912 let def_name = if item == CRATE_DEF_INDEX {
913 kw::Crate
914 } else {
915 def_key
916 .disambiguated_data
917 .data
918 .get_opt_name()
919 .unwrap_or_else(|| Symbol::intern("???"))
920 };
921 let visibility = root
922 .tables
923 .visibility
924 .get(blob, item)
925 .unwrap()
926 .decode(blob)
927 .map_id(|id| {
928 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("crate{0}",
DefPath::make(LOCAL_CRATE, id.local_def_index,
|parent|
{
root.tables.def_keys.get(blob, parent).unwrap().decode(blob)
}).to_string_no_crate_verbose()))
})format!(
929 "crate{}",
930 DefPath::make(LOCAL_CRATE, id.local_def_index, |parent| {
931 root.tables.def_keys.get(blob, parent).unwrap().decode(blob)
932 })
933 .to_string_no_crate_verbose()
934 )
935 });
936 out.write_fmt(format_args!("{3: <4$}{0:?} {1:?} {2} {{", visibility, def_kind,
def_name, "", indent))write!(
937 out,
938 "{nil: <indent$}{:?} {:?} {} {{",
939 visibility,
940 def_kind,
941 def_name,
942 nil = "",
943 )?;
944
945 if let Some(children) =
946 root.tables.module_children_non_reexports.get(blob, item)
947 {
948 out.write_fmt(format_args!("\n"))write!(out, "\n")?;
949 for child in children.decode(blob) {
950 print_item(blob, out, child.local_def_index, indent + 4)?;
951 }
952 out.write_fmt(format_args!("{0: <1$}}}\n", "", indent))writeln!(out, "{nil: <indent$}}}", nil = "")?;
953 } else {
954 out.write_fmt(format_args!("}}\n"))writeln!(out, "}}")?;
955 }
956
957 Ok(())
958 }
959
960 print_item(self, out, CRATE_DEF_INDEX, 0)?;
961
962 out.write_fmt(format_args!("\n"))write!(out, "\n")?;
963 }
964 "target_modifiers" => {
965 out.write_fmt(format_args!("=Target modifiers=\n"))writeln!(out, "=Target modifiers=")?;
966
967 for modifier in root.decode_target_modifiers(self) {
968 let extended = modifier.extend();
969
970 out.write_fmt(format_args!("-{0}{1}={2} [{3}]\n", extended.prefix,
extended.name, modifier.value_name, extended.tech_value))writeln!(
971 out,
972 "-{}{}={} [{}]",
973 extended.prefix,
974 extended.name,
975 modifier.value_name,
976 extended.tech_value,
977 )?;
978 }
979 }
980
981 _ => {
982 out.write_fmt(format_args!("unknown -Zls kind. allowed values are: all, root, lang_items, features, items, target_modifiers\n"))writeln!(
983 out,
984 "unknown -Zls kind. allowed values are: all, root, lang_items, features, items, \
985 target_modifiers"
986 )?;
987 }
988 }
989 }
990
991 Ok(())
992 }
993
994 pub(crate) fn get_proc_macro_info(&self) -> Vec<ProcMacroKind> {
995 self.get_root()
996 .proc_macro_data
997 .unwrap()
998 .macros
999 .decode(self)
1000 .map(|(_id, kind)| kind.decode(self))
1001 .collect::<Vec<_>>()
1002 }
1003}
1004
1005impl CrateRoot {
1006 pub(crate) fn is_proc_macro_crate(&self) -> bool {
1007 self.proc_macro_data.is_some()
1008 }
1009
1010 pub(crate) fn name(&self) -> Symbol {
1011 self.header.name
1012 }
1013
1014 pub(crate) fn stable_crate_id(&self) -> StableCrateId {
1015 self.stable_crate_id
1016 }
1017
1018 pub(crate) fn decode_crate_deps<'a>(
1019 &self,
1020 metadata: &'a MetadataBlob,
1021 ) -> impl ExactSizeIterator<Item = CrateDep> {
1022 self.crate_deps.decode(metadata)
1023 }
1024
1025 pub(crate) fn decode_target_modifiers<'a>(
1026 &self,
1027 metadata: &'a MetadataBlob,
1028 ) -> impl ExactSizeIterator<Item = TargetModifier> {
1029 self.target_modifiers.decode(metadata)
1030 }
1031
1032 pub(crate) fn decode_denied_partial_mitigations<'a>(
1033 &self,
1034 metadata: &'a MetadataBlob,
1035 ) -> impl ExactSizeIterator<Item = DeniedPartialMitigation> {
1036 self.denied_partial_mitigations.decode(metadata)
1037 }
1038}
1039
1040impl CrateMetadata {
1041 fn missing(&self, descr: &str, id: DefIndex) -> ! {
1042 ::rustc_span::macros::bug_impl(None,
format_args!("missing `{1}` for {0:?}", self.local_def_id(id), descr),
Location::caller())bug!("missing `{descr}` for {:?}", self.local_def_id(id))
1043 }
1044
1045 fn raw_proc_macro(&self, tcx: TyCtxt<'_>, id: DefIndex) -> (ProcMacroClient, ProcMacroKind) {
1046 let (pos, (_id, kind)) = self
1049 .root
1050 .proc_macro_data
1051 .as_ref()
1052 .unwrap()
1053 .macros
1054 .decode((self, tcx))
1055 .enumerate()
1056 .find(|(_pos, (i, _))| i.local_def_index == id)
1057 .unwrap();
1058 (self.raw_proc_macros.unwrap()[pos], kind.decode((self, tcx)))
1059 }
1060
1061 fn opt_item_name(&self, item_index: DefIndex) -> Option<Symbol> {
1062 let def_key = self.def_key(item_index);
1063 def_key.disambiguated_data.data.get_opt_name().or_else(|| {
1064 if def_key.disambiguated_data.data == DefPathData::Ctor {
1065 let parent_index = def_key.parent.expect("no parent for a constructor");
1066 self.def_key(parent_index).disambiguated_data.data.get_opt_name()
1067 } else {
1068 None
1069 }
1070 })
1071 }
1072
1073 fn item_name(&self, item_index: DefIndex) -> Symbol {
1074 self.opt_item_name(item_index).expect("no encoded ident for item")
1075 }
1076
1077 fn opt_item_ident(&self, tcx: TyCtxt<'_>, item_index: DefIndex) -> Option<Ident> {
1078 let name = self.opt_item_name(item_index)?;
1079 let span = self
1080 .root
1081 .tables
1082 .def_ident_span
1083 .get(self, item_index)
1084 .unwrap_or_else(|| self.missing("def_ident_span", item_index))
1085 .decode((self, tcx));
1086 Some(Ident::new(name, span))
1087 }
1088
1089 fn item_ident(&self, tcx: TyCtxt<'_>, item_index: DefIndex) -> Ident {
1090 self.opt_item_ident(tcx, item_index).expect("no encoded ident for item")
1091 }
1092
1093 #[inline]
1094 pub(super) fn map_encoded_cnum_to_current(&self, cnum: CrateNum) -> CrateNum {
1095 if cnum == LOCAL_CRATE { self.cnum } else { self.cnum_map[cnum] }
1096 }
1097
1098 fn def_kind(&self, item_id: DefIndex) -> DefKind {
1099 self.root
1100 .tables
1101 .def_kind
1102 .get(self, item_id)
1103 .unwrap_or_else(|| self.missing("def_kind", item_id))
1104 }
1105
1106 fn get_span(&self, tcx: TyCtxt<'_>, index: DefIndex) -> Span {
1107 self.root
1108 .tables
1109 .def_span
1110 .get(self, index)
1111 .unwrap_or_else(|| self.missing("def_span", index))
1112 .decode((self, tcx))
1113 }
1114
1115 fn load_proc_macro<'tcx>(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> SyntaxExtension {
1116 let (name, kind, helper_attrs) = match self.raw_proc_macro(tcx, id) {
1117 (client, ProcMacroKind::CustomDerive { trait_name, attributes }) => {
1118 let helper_attrs =
1119 attributes.into_iter().map(|attr| Symbol::intern(&attr)).collect();
1120 (
1121 trait_name,
1122 SyntaxExtensionKind::Derive(Arc::new(DeriveProcMacro { client })),
1123 helper_attrs,
1124 )
1125 }
1126 (client, ProcMacroKind::Attr { name }) => {
1127 (name, SyntaxExtensionKind::Attr(Arc::new(AttrProcMacro { client })), Vec::new())
1128 }
1129 (client, ProcMacroKind::Bang { name }) => {
1130 (name, SyntaxExtensionKind::Bang(Arc::new(BangProcMacro { client })), Vec::new())
1131 }
1132 };
1133
1134 let sess = tcx.sess;
1135 let attrs: Vec<_> = self.get_item_attrs(tcx, id).collect();
1136 SyntaxExtension::new(
1137 sess,
1138 kind,
1139 self.get_span(tcx, id),
1140 helper_attrs,
1141 self.root.edition,
1142 Symbol::intern(&name),
1143 &attrs,
1144 false,
1145 )
1146 }
1147
1148 fn get_variant(
1149 &self,
1150 tcx: TyCtxt<'_>,
1151 kind: DefKind,
1152 index: DefIndex,
1153 parent_did: DefId,
1154 ) -> (VariantIdx, ty::VariantDef) {
1155 let adt_kind = match kind {
1156 DefKind::Variant => ty::AdtKind::Enum,
1157 DefKind::Struct => ty::AdtKind::Struct,
1158 DefKind::Union => ty::AdtKind::Union,
1159 _ => ::rustc_span::macros::bug_impl(None, format_args!("impossible case reached"),
Location::caller())bug!(),
1160 };
1161
1162 let data = self.root.tables.variant_data.get(self, index).unwrap().decode((self, tcx));
1163
1164 let variant_did =
1165 if adt_kind == ty::AdtKind::Enum { Some(self.local_def_id(index)) } else { None };
1166 let ctor = data.ctor.map(|(kind, id)| (kind, self.local_def_id(id.local_def_index)));
1167
1168 (
1169 data.idx,
1170 ty::VariantDef::new(
1171 self.item_name(index),
1172 variant_did,
1173 ctor,
1174 data.discr,
1175 self.get_associated_item_or_field_def_ids(tcx, index)
1176 .map(|did| ty::FieldDef {
1177 did,
1178 name: self.item_name(did.index),
1179 vis: self.get_visibility(tcx, did.index),
1180 mut_restriction: self.get_mut_restriction(tcx, did.index),
1181 safety: self.get_safety(did.index),
1182 value: self.get_default_field(tcx, did.index),
1183 })
1184 .collect(),
1185 parent_did,
1186 None,
1187 data.is_non_exhaustive,
1188 ),
1189 )
1190 }
1191
1192 fn get_adt_def<'tcx>(&self, tcx: TyCtxt<'tcx>, item_id: DefIndex) -> ty::AdtDef<'tcx> {
1193 let kind = self.def_kind(item_id);
1194 let did = self.local_def_id(item_id);
1195
1196 let adt_kind = match kind {
1197 DefKind::Enum => ty::AdtKind::Enum,
1198 DefKind::Struct => ty::AdtKind::Struct,
1199 DefKind::Union => ty::AdtKind::Union,
1200 _ => ::rustc_span::macros::bug_impl(None,
format_args!("get_adt_def called on a non-ADT {0:?}", did),
Location::caller())bug!("get_adt_def called on a non-ADT {:?}", did),
1201 };
1202 let repr = self.root.tables.repr_options.get(self, item_id).unwrap().decode((self, tcx));
1203
1204 let mut variants: Vec<_> = if let ty::AdtKind::Enum = adt_kind {
1205 self.root
1206 .tables
1207 .module_children_non_reexports
1208 .get(self, item_id)
1209 .expect("variants are not encoded for an enum")
1210 .decode((self, tcx))
1211 .filter_map(|id| {
1212 let index = id.local_def_index;
1213 let kind = self.def_kind(index);
1214 match kind {
1215 DefKind::Ctor(..) => None,
1216 _ => Some(self.get_variant(tcx, kind, index, did)),
1217 }
1218 })
1219 .collect()
1220 } else {
1221 std::iter::once(self.get_variant(tcx, kind, item_id, did)).collect()
1222 };
1223
1224 variants.sort_by_key(|(idx, _)| *idx);
1225
1226 tcx.mk_adt_def(
1227 did,
1228 adt_kind,
1229 variants.into_iter().map(|(_, variant)| variant).collect(),
1230 repr,
1231 )
1232 }
1233
1234 fn get_visibility(&self, tcx: TyCtxt<'_>, id: DefIndex) -> Visibility<ModId> {
1235 self.root
1236 .tables
1237 .visibility
1238 .get(self, id)
1239 .unwrap_or_else(|| self.missing("visibility", id))
1240 .decode((self, tcx))
1241 .map_id(|id| ModId::new_unchecked(self.local_def_id(id.local_def_index)))
1242 }
1243
1244 fn get_mut_restriction(&self, tcx: TyCtxt<'_>, id: DefIndex) -> RestrictionKind {
1245 self.root
1246 .tables
1247 .mut_restriction
1248 .get(self, id)
1249 .unwrap_or_else(|| self.missing("mut_restriction", id))
1250 .decode((self, tcx))
1251 }
1252
1253 fn get_safety(&self, id: DefIndex) -> Safety {
1254 self.root.tables.safety.get(self, id)
1255 }
1256
1257 fn get_default_field(&self, tcx: TyCtxt<'_>, id: DefIndex) -> Option<DefId> {
1258 self.root.tables.default_fields.get(self, id).map(|d| d.decode((self, tcx)))
1259 }
1260
1261 fn get_expn_that_defined(&self, tcx: TyCtxt<'_>, id: DefIndex) -> ExpnId {
1262 self.root
1263 .tables
1264 .expn_that_defined
1265 .get(self, id)
1266 .unwrap_or_else(|| self.missing("expn_that_defined", id))
1267 .decode((self, tcx))
1268 }
1269
1270 fn get_debugger_visualizers(&self, tcx: TyCtxt<'_>) -> Vec<DebuggerVisualizerFile> {
1271 self.root.debugger_visualizers.decode((self, tcx)).collect::<Vec<_>>()
1272 }
1273
1274 fn get_lib_features(&self, tcx: TyCtxt<'_>) -> LibFeatures {
1276 LibFeatures {
1277 stability: self
1278 .root
1279 .lib_features
1280 .decode((self, tcx))
1281 .map(|(sym, stab)| (sym, (stab, DUMMY_SP)))
1282 .collect(),
1283 }
1284 }
1285
1286 fn get_stability_implications<'tcx>(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Symbol)] {
1290 tcx.arena.alloc_from_iter(self.root.stability_implications.decode((self, tcx)))
1291 }
1292
1293 fn get_lang_items<'tcx>(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, LangItem)] {
1295 tcx.arena.alloc_from_iter(
1296 self.root
1297 .lang_items
1298 .decode((self, tcx))
1299 .map(move |(id, index)| (self.local_def_id(id.local_def_index), index)),
1300 )
1301 }
1302
1303 fn get_stripped_cfg_items<'tcx>(
1304 &self,
1305 tcx: TyCtxt<'tcx>,
1306 cnum: CrateNum,
1307 ) -> &'tcx [StrippedCfgItem] {
1308 let item_names =
1309 self.root.stripped_cfg_items.decode((self, tcx)).map(|item| {
1310 item.map_scope_id(|id| DefId { krate: cnum, index: id.local_def_index })
1311 });
1312
1313 tcx.arena.alloc_from_iter(item_names)
1314 }
1315
1316 fn get_diagnostic_items(&self, tcx: TyCtxt<'_>) -> DiagnosticItems {
1318 let mut id_to_name = DefIdMap::default();
1319 let name_to_id = self
1320 .root
1321 .diagnostic_items
1322 .decode((self, tcx))
1323 .map(|(name, id)| {
1324 let id = self.local_def_id(id.local_def_index);
1325 id_to_name.insert(id, name);
1326 (name, id)
1327 })
1328 .collect();
1329 DiagnosticItems { id_to_name, name_to_id }
1330 }
1331
1332 fn get_canonical_symbols(&self, tcx: TyCtxt<'_>) -> CanonicalSymbols {
1334 let mut canonical_symbols = CanonicalSymbols::new();
1335
1336 for (name, id) in self.root.canonical_symbols.decode((self, tcx)) {
1337 let id = self.local_def_id(id.local_def_index);
1338 let _ = canonical_symbols.set(name, id);
1339 }
1340
1341 canonical_symbols
1342 }
1343
1344 fn get_fake_doc_items(&self, tcx: TyCtxt<'_>) -> Vec<DefId> {
1346 let mut fake_doc_items = Vec::new();
1347
1348 for id in self.root.fake_doc_items.decode((self, tcx)) {
1349 let id = self.local_def_id(id.local_def_index);
1350 fake_doc_items.push(id);
1351 }
1352
1353 fake_doc_items
1354 }
1355
1356 fn get_mod_child(&self, tcx: TyCtxt<'_>, id: DefIndex) -> ModChild {
1357 let ident = self.item_ident(tcx, id);
1358 let res = Res::Def(self.def_kind(id), self.local_def_id(id));
1359 let vis = self.get_visibility(tcx, id);
1360
1361 ModChild { ident, res, vis, reexport_chain: Default::default() }
1362 }
1363
1364 fn get_module_children(&self, tcx: TyCtxt<'_>, id: DefIndex) -> impl Iterator<Item = ModChild> {
1373 gen move {
1374 if let Some(data) = &self.root.proc_macro_data {
1375 if id == CRATE_DEF_INDEX {
1378 for (child_index, _) in data.macros.decode((self, tcx)) {
1379 yield self.get_mod_child(tcx, child_index.local_def_index);
1380 }
1381 }
1382 } else {
1383 let non_reexports = self.root.tables.module_children_non_reexports.get(self, id);
1385 let non_reexports =
1386 non_reexports.expect("provided `DefIndex` must refer to a module-like item");
1387 for child_index in non_reexports.decode((self, tcx)) {
1388 yield self.get_mod_child(tcx, child_index.local_def_index);
1389 }
1390
1391 let reexports = self.root.tables.module_children_reexports.get(self, id);
1392 if !reexports.is_default() {
1393 for reexport in reexports.decode((self, tcx)) {
1394 yield reexport;
1395 }
1396 }
1397 }
1398 }
1399 }
1400
1401 fn get_ambig_module_children(
1402 &self,
1403 tcx: TyCtxt<'_>,
1404 id: DefIndex,
1405 ) -> impl Iterator<Item = AmbigModChild> {
1406 gen move {
1407 let children = self.root.tables.ambig_module_children.get(self, id);
1408 if !children.is_default() {
1409 for child in children.decode((self, tcx)) {
1410 yield child;
1411 }
1412 }
1413 }
1414 }
1415
1416 fn is_item_mir_available(&self, id: DefIndex) -> bool {
1417 self.root.tables.optimized_mir.get(self, id).is_some()
1418 }
1419
1420 fn get_fn_has_self_parameter(&self, tcx: TyCtxt<'_>, id: DefIndex) -> bool {
1421 self.root
1422 .tables
1423 .fn_arg_idents
1424 .get(self, id)
1425 .expect("argument names not encoded for a function")
1426 .decode((self, tcx))
1427 .nth(0)
1428 .is_some_and(|ident| #[allow(non_exhaustive_omitted_patterns)] match ident {
Some(Ident { name: kw::SelfLower, .. }) => true,
_ => false,
}matches!(ident, Some(Ident { name: kw::SelfLower, .. })))
1429 }
1430
1431 fn get_associated_item_or_field_def_ids(
1432 &self,
1433 tcx: TyCtxt<'_>,
1434 id: DefIndex,
1435 ) -> impl Iterator<Item = DefId> {
1436 self.root
1437 .tables
1438 .associated_item_or_field_def_ids
1439 .get(self, id)
1440 .unwrap_or_else(|| self.missing("associated_item_or_field_def_ids", id))
1441 .decode((self, tcx))
1442 .map(move |id| self.local_def_id(id.local_def_index))
1443 }
1444
1445 fn get_associated_item(&self, tcx: TyCtxt<'_>, id: DefIndex) -> ty::AssocItem {
1446 let kind = match self.def_kind(id) {
1447 DefKind::AssocConst => {
1448 let data = if let Some(item_name) = self.root.tables.opt_item_name.get(self, id) {
1449 ty::AssocConstData::Named(item_name.decode((self, tcx)))
1450 } else {
1451 ty::AssocConstData::Anonymous
1452 };
1453 ty::AssocKind::Const { data }
1454 }
1455 DefKind::AssocFn => ty::AssocKind::Fn {
1456 name: self.item_name(id),
1457 has_self: self.get_fn_has_self_parameter(tcx, id),
1458 },
1459 DefKind::AssocTy => {
1460 let data = if let Some(rpitit_info) = self.root.tables.opt_rpitit_info.get(self, id)
1461 {
1462 ty::AssocTypeData::Rpitit(rpitit_info.decode((self, tcx)))
1463 } else {
1464 ty::AssocTypeData::Normal(self.item_name(id))
1465 };
1466 ty::AssocKind::Type { data }
1467 }
1468 _ => ::rustc_span::macros::bug_impl(None,
format_args!("cannot get associated-item of `{0:?}`", self.def_key(id)),
Location::caller())bug!("cannot get associated-item of `{:?}`", self.def_key(id)),
1469 };
1470 let container = self.root.tables.assoc_container.get(self, id).unwrap().decode((self, tcx));
1471
1472 ty::AssocItem { kind, def_id: self.local_def_id(id), container }
1473 }
1474
1475 fn get_ctor(&self, tcx: TyCtxt<'_>, node_id: DefIndex) -> Option<(CtorKind, DefId)> {
1476 match self.def_kind(node_id) {
1477 DefKind::Struct | DefKind::Variant => {
1478 let vdata =
1479 self.root.tables.variant_data.get(self, node_id).unwrap().decode((self, tcx));
1480 vdata.ctor.map(|(kind, id)| (kind, self.local_def_id(id.local_def_index)))
1481 }
1482 _ => None,
1483 }
1484 }
1485
1486 fn get_item_attrs(
1487 &self,
1488 tcx: TyCtxt<'_>,
1489 id: DefIndex,
1490 ) -> impl Iterator<Item = rustc_attr_ir::Attribute> {
1491 self.root
1492 .tables
1493 .attributes
1494 .get(self, id)
1495 .unwrap_or_else(|| {
1496 let def_key = self.def_key(id);
1497 match def_key.disambiguated_data.data {
1498 DefPathData::Ctor => {
1499 let parent_id = def_key.parent.expect("no parent for a constructor");
1503 self.root
1504 .tables
1505 .attributes
1506 .get(self, parent_id)
1507 .expect("no encoded attributes for a structure or variant")
1508 }
1509 DefPathData::SyntheticCoroutineBody => {
1510 LazyArray::default()
1512 }
1513 _ => {
::core::panicking::panic_fmt(format_args!("Definition key {1:?} of type `{0:?}` did not have any attributes stored",
def_key.disambiguated_data.data, def_key));
}panic!("Definition key {def_key:?} of type `{:?}` did not have any attributes stored", def_key.disambiguated_data.data)
1514 }
1515 })
1516 .decode((self, tcx))
1517 }
1518
1519 fn get_inherent_implementations_for_type<'tcx>(
1520 &self,
1521 tcx: TyCtxt<'tcx>,
1522 id: DefIndex,
1523 ) -> &'tcx [DefId] {
1524 tcx.arena.alloc_from_iter(
1525 self.root
1526 .tables
1527 .inherent_impls
1528 .get(self, id)
1529 .decode((self, tcx))
1530 .map(|id| self.local_def_id(id.local_def_index)),
1531 )
1532 }
1533
1534 fn get_traits(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = DefId> {
1536 self.root.traits.decode((self, tcx)).map(move |id| self.local_def_id(id.local_def_index))
1537 }
1538
1539 fn get_trait_impls(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = DefId> {
1541 self.trait_impls.values().flat_map(move |impls| {
1542 impls.decode((self, tcx)).map(move |(id, _)| self.local_def_id(id.local_def_index))
1543 })
1544 }
1545
1546 fn get_incoherent_impls<'tcx>(&self, tcx: TyCtxt<'tcx>, simp: SimplifiedType) -> &'tcx [DefId] {
1547 if let Some(impls) = self.incoherent_impls.get(&simp) {
1548 tcx.arena.alloc_from_iter(
1549 impls.decode((self, tcx)).map(|id| self.local_def_id(id.local_def_index)),
1550 )
1551 } else {
1552 &[]
1553 }
1554 }
1555
1556 fn get_implementations_of_trait<'tcx>(
1557 &self,
1558 tcx: TyCtxt<'tcx>,
1559 trait_def_id: DefId,
1560 ) -> &'tcx [(DefId, Option<SimplifiedType>)] {
1561 if self.trait_impls.is_empty() {
1562 return &[];
1563 }
1564
1565 let key = match self.reverse_translate_def_id(trait_def_id) {
1568 Some(def_id) => def_id,
1569 None => return &[],
1570 };
1571
1572 if let Some(impls) = self.trait_impls.get(&key) {
1573 tcx.arena.alloc_from_iter(impls.decode((self, tcx)).map(|(id, simplified_self_ty)| {
1574 (self.local_def_id(id.local_def_index), simplified_self_ty)
1575 }))
1576 } else {
1577 &[]
1578 }
1579 }
1580
1581 fn get_native_libraries(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = NativeLib> {
1582 self.root.native_libraries.decode((self, tcx))
1583 }
1584
1585 fn get_proc_macro_quoted_span(&self, tcx: TyCtxt<'_>, index: usize) -> Span {
1586 self.root
1587 .proc_macro_data
1588 .as_ref()
1589 .expect("missing proc macro data")
1590 .proc_macro_quoted_spans
1591 .get(self, index)
1592 .unwrap_or_else(|| {
::core::panicking::panic_fmt(format_args!("missing proc macro quoted span: {0:?}",
index));
}panic!("missing proc macro quoted span: {index:?}"))
1593 .decode((self, tcx))
1594 }
1595
1596 fn get_foreign_modules(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = ForeignModule> {
1597 self.root.foreign_modules.decode((self, tcx))
1598 }
1599
1600 fn get_dylib_dependency_formats<'tcx>(
1601 &self,
1602 tcx: TyCtxt<'tcx>,
1603 ) -> &'tcx [(CrateNum, LinkagePreference)] {
1604 tcx.arena.alloc_from_iter(
1605 self.root.dylib_dependency_formats.decode((self, tcx)).enumerate().flat_map(
1606 |(i, link)| {
1607 let cnum = CrateNum::new(i + 1); link.map(|link| (self.cnum_map[cnum], link))
1609 },
1610 ),
1611 )
1612 }
1613
1614 fn get_externally_implementable_items(
1615 &self,
1616 tcx: TyCtxt<'_>,
1617 ) -> impl Iterator<Item = EiiMapEncodedKeyValue> {
1618 self.root.externally_implementable_items.decode((self, tcx))
1619 }
1620
1621 fn get_missing_lang_items<'tcx>(&self, tcx: TyCtxt<'tcx>) -> &'tcx [LangItem] {
1622 tcx.arena.alloc_from_iter(self.root.lang_items_missing.decode((self, tcx)))
1623 }
1624
1625 fn get_exportable_items(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = DefId> {
1626 self.root
1627 .exportable_items
1628 .decode((self, tcx))
1629 .map(move |id| self.local_def_id(id.local_def_index))
1630 }
1631
1632 fn get_stable_order_of_exportable_impls(
1633 &self,
1634 tcx: TyCtxt<'_>,
1635 ) -> impl Iterator<Item = (DefId, usize)> {
1636 self.root
1637 .stable_order_of_exportable_impls
1638 .decode((self, tcx))
1639 .map(move |v| (self.local_def_id(v.0.local_def_index), v.1))
1640 }
1641
1642 fn exported_non_generic_symbols<'tcx>(
1643 &self,
1644 tcx: TyCtxt<'tcx>,
1645 ) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
1646 tcx.arena.alloc_from_iter(self.root.exported_non_generic_symbols.decode((self, tcx)))
1647 }
1648
1649 fn exported_generic_symbols<'tcx>(
1650 &self,
1651 tcx: TyCtxt<'tcx>,
1652 ) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
1653 tcx.arena.alloc_from_iter(self.root.exported_generic_symbols.decode((self, tcx)))
1654 }
1655
1656 fn get_macro(&self, tcx: TyCtxt<'_>, id: DefIndex) -> ast::MacroDef {
1657 match self.def_kind(id) {
1658 DefKind::Macro(_) => {
1659 let macro_rules = self.root.tables.is_macro_rules.get(self, id);
1660 let body =
1661 self.root.tables.macro_definition.get(self, id).unwrap().decode((self, tcx));
1662 ast::MacroDef { macro_rules, body: Box::new(body), eii_declaration: None }
1663 }
1664 _ => ::rustc_span::macros::bug_impl(None, format_args!("impossible case reached"),
Location::caller())bug!(),
1665 }
1666 }
1667
1668 #[inline]
1669 fn def_key(&self, index: DefIndex) -> DefKey {
1670 *self.def_key_cache.lock().entry(index).or_insert_with(|| {
1671 self.root.tables.def_keys.get(&self.blob, index).unwrap().decode(&self.blob)
1672 })
1673 }
1674
1675 fn def_path(&self, id: DefIndex) -> DefPath {
1677 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:1677",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(1677u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::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_path(cnum={0:?}, id={1:?})",
self.cnum, id) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("def_path(cnum={:?}, id={:?})", self.cnum, id);
1678 DefPath::make(self.cnum, id, |parent| self.def_key(parent))
1679 }
1680
1681 #[inline]
1682 fn def_path_hash(&self, index: DefIndex) -> DefPathHash {
1683 let fingerprint = Fingerprint::new(
1687 self.root.stable_crate_id.as_u64(),
1688 self.root.tables.def_path_hashes.get(&self.blob, index),
1689 );
1690 DefPathHash::new(self.root.stable_crate_id, fingerprint.split().1)
1691 }
1692
1693 #[inline]
1694 fn def_path_hash_to_def_index(&self, hash: DefPathHash) -> Option<DefIndex> {
1695 self.def_path_hash_map.def_path_hash_to_def_index(&hash)
1696 }
1697
1698 fn expn_hash_to_expn_id(&self, tcx: TyCtxt<'_>, index_guess: u32, hash: ExpnHash) -> ExpnId {
1699 let index_guess = ExpnIndex::from_u32(index_guess);
1700 let old_hash =
1701 self.root.expn_hashes.get(self, index_guess).map(|lazy| lazy.decode((self, tcx)));
1702
1703 let index = if old_hash == Some(hash) {
1704 index_guess
1708 } else {
1709 let map = self.expn_hash_map.get_or_init(|| {
1713 let end_id = self.root.expn_hashes.size() as u32;
1714 let mut map =
1715 UnhashMap::with_capacity_and_hasher(end_id as usize, Default::default());
1716 for i in 0..end_id {
1717 let i = ExpnIndex::from_u32(i);
1718 if let Some(hash) = self.root.expn_hashes.get(self, i) {
1719 map.insert(hash.decode((self, tcx)), i);
1720 }
1721 }
1722 map
1723 });
1724 map[&hash]
1725 };
1726
1727 let data = self.root.expn_data.get(self, index).unwrap().decode((self, tcx));
1728 rustc_span::hygiene::register_expn_id(self.cnum, index, data, hash)
1729 }
1730
1731 fn imported_source_file(&self, tcx: TyCtxt<'_>, source_file_index: u32) -> ImportedSourceFile {
1757 fn filter<'a>(
1758 tcx: TyCtxt<'_>,
1759 real_source_base_dir: &Option<PathBuf>,
1760 path: Option<&'a Path>,
1761 ) -> Option<&'a Path> {
1762 path.filter(|_| {
1763 real_source_base_dir.is_some()
1765 && tcx.sess.opts.unstable_opts.translate_remapped_path_to_local_path
1767 })
1768 .filter(|virtual_dir| {
1769 !tcx.sess.opts.remap_path_prefix.iter().any(|(_from, to)| to == virtual_dir)
1773 })
1774 }
1775
1776 let try_to_translate_virtual_to_real =
1777 |virtual_source_base_dir: Option<&str>,
1778 real_source_base_dir: &Option<PathBuf>,
1779 name: &mut rustc_span::FileName| {
1780 let virtual_source_base_dir = [
1781 filter(tcx, real_source_base_dir, virtual_source_base_dir.map(Path::new)),
1782 filter(
1783 tcx,
1784 real_source_base_dir,
1785 tcx.sess.opts.unstable_opts.simulate_remapped_rust_src_base.as_deref(),
1786 ),
1787 ];
1788
1789 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:1789",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(1789u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::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!("try_to_translate_virtual_to_real(name={0:?}): virtual_source_base_dir={1:?}, real_source_base_dir={2:?}",
name, virtual_source_base_dir, real_source_base_dir) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
1790 "try_to_translate_virtual_to_real(name={:?}): \
1791 virtual_source_base_dir={:?}, real_source_base_dir={:?}",
1792 name, virtual_source_base_dir, real_source_base_dir,
1793 );
1794
1795 for virtual_dir in virtual_source_base_dir.iter().flatten() {
1796 if let Some(real_dir) = &real_source_base_dir
1797 && let rustc_span::FileName::Real(old_name) = name
1798 && let virtual_path = old_name.path(RemapPathScopeComponents::MACRO)
1799 && let Ok(rest) = virtual_path.strip_prefix(virtual_dir)
1800 {
1801 let new_path = real_dir.join(rest);
1802
1803 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:1803",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(1803u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::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!("try_to_translate_virtual_to_real: `{0}` -> `{1}`",
virtual_path.display(), new_path.display()) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
1804 "try_to_translate_virtual_to_real: `{}` -> `{}`",
1805 virtual_path.display(),
1806 new_path.display(),
1807 );
1808
1809 *name = rustc_span::FileName::Real(
1815 tcx.sess
1816 .source_map()
1817 .path_mapping()
1818 .to_real_filename(&rustc_span::RealFileName::empty(), new_path),
1819 );
1820 }
1821 }
1822 };
1823
1824 let try_to_translate_real_to_virtual =
1825 |virtual_source_base_dir: Option<&str>,
1826 real_source_base_dir: &Option<PathBuf>,
1827 subdir: &str,
1828 name: &mut rustc_span::FileName| {
1829 if let Some(virtual_dir) =
1830 &tcx.sess.opts.unstable_opts.simulate_remapped_rust_src_base
1831 && let Some(real_dir) = real_source_base_dir
1832 && let rustc_span::FileName::Real(old_name) = name
1833 {
1834 let (_working_dir, embeddable_path) =
1835 old_name.embeddable_name(RemapPathScopeComponents::MACRO);
1836 let relative_path = embeddable_path.strip_prefix(real_dir).ok().or_else(|| {
1837 virtual_source_base_dir
1838 .and_then(|virtual_dir| embeddable_path.strip_prefix(virtual_dir).ok())
1839 });
1840 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:1840",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(1840u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("relative_path")
}> =
::tracing::__macro_support::FieldName::new("relative_path");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("virtual_dir")
}> =
::tracing::__macro_support::FieldName::new("virtual_dir");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("subdir")
}> =
::tracing::__macro_support::FieldName::new("subdir");
NAME.as_str()
}], ::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!("simulate_remapped_rust_src_base")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&relative_path)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&virtual_dir)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&subdir)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
1841 ?relative_path,
1842 ?virtual_dir,
1843 ?subdir,
1844 "simulate_remapped_rust_src_base"
1845 );
1846 if let Some(rest) = relative_path.and_then(|p| p.strip_prefix(subdir).ok()) {
1847 *name =
1848 rustc_span::FileName::Real(rustc_span::RealFileName::from_virtual_path(
1849 &virtual_dir.join(subdir).join(rest),
1850 ))
1851 }
1852 }
1853 };
1854
1855 let mut import_info = self.source_map_import_info.lock();
1856 for _ in import_info.len()..=(source_file_index as usize) {
1857 import_info.push(None);
1858 }
1859 import_info[source_file_index as usize]
1860 .get_or_insert_with(|| {
1861 let source_file_to_import = self
1862 .root
1863 .source_map
1864 .get(self, source_file_index)
1865 .expect("missing source file")
1866 .decode((self, tcx));
1867
1868 let original_end_pos = source_file_to_import.end_position();
1871 let rustc_span::SourceFile {
1872 mut name,
1873 src_hash,
1874 checksum_hash,
1875 start_pos: original_start_pos,
1876 normalized_source_len,
1877 unnormalized_source_len,
1878 lines,
1879 multibyte_chars,
1880 normalized_pos,
1881 stable_id,
1882 ..
1883 } = source_file_to_import;
1884
1885 try_to_translate_real_to_virtual(
1893 ::core::option::Option::Some("/rustc/6181cc4f077f1a16ce605e297173b01c6ddff553")option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR"),
1894 &tcx.sess.opts.real_rust_source_base_dir,
1895 "library",
1896 &mut name,
1897 );
1898
1899 try_to_translate_real_to_virtual(
1904 ::core::option::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553")option_env!("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR"),
1905 &tcx.sess.opts.real_rustc_dev_source_base_dir,
1906 "compiler",
1907 &mut name,
1908 );
1909
1910 try_to_translate_virtual_to_real(
1916 ::core::option::Option::Some("/rustc/6181cc4f077f1a16ce605e297173b01c6ddff553")option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR"),
1917 &tcx.sess.opts.real_rust_source_base_dir,
1918 &mut name,
1919 );
1920
1921 try_to_translate_virtual_to_real(
1927 ::core::option::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553")option_env!("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR"),
1928 &tcx.sess.opts.real_rustc_dev_source_base_dir,
1929 &mut name,
1930 );
1931
1932 let local_version = tcx.sess.source_map().new_imported_source_file(
1933 name,
1934 src_hash,
1935 checksum_hash,
1936 stable_id,
1937 normalized_source_len.to_u32(),
1938 unnormalized_source_len,
1939 self.cnum,
1940 lines,
1941 multibyte_chars,
1942 normalized_pos,
1943 source_file_index,
1944 );
1945 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs:1945",
"rustc_metadata::rmeta::decoder", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6181cc4f077f1a16ce605e297173b01c6ddff553/compiler/rustc_metadata/src/rmeta/decoder.rs"),
::tracing_core::__macro_support::Option::Some(1945u32),
::tracing_core::__macro_support::Option::Some("rustc_metadata::rmeta::decoder"),
::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!("CrateMetaData::imported_source_files alloc source_file {0:?} original (start_pos {1:?} source_len {2:?}) translated (start_pos {3:?} source_len {4:?})",
local_version.name, original_start_pos,
normalized_source_len, local_version.start_pos,
local_version.normalized_source_len) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
1946 "CrateMetaData::imported_source_files alloc \
1947 source_file {:?} original (start_pos {:?} source_len {:?}) \
1948 translated (start_pos {:?} source_len {:?})",
1949 local_version.name,
1950 original_start_pos,
1951 normalized_source_len,
1952 local_version.start_pos,
1953 local_version.normalized_source_len
1954 );
1955
1956 ImportedSourceFile {
1957 original_start_pos,
1958 original_end_pos,
1959 translated_source_file: local_version,
1960 }
1961 })
1962 .clone()
1963 }
1964
1965 fn get_attr_flags(&self, index: DefIndex) -> AttrFlags {
1966 self.root.tables.attr_flags.get(self, index)
1967 }
1968
1969 fn get_intrinsic(&self, tcx: TyCtxt<'_>, index: DefIndex) -> Option<ty::IntrinsicDef> {
1970 self.root.tables.intrinsic.get(self, index).map(|d| d.decode((self, tcx)))
1971 }
1972
1973 fn get_doc_link_resolutions(&self, tcx: TyCtxt<'_>, index: DefIndex) -> DocLinkResMap {
1974 self.root
1975 .tables
1976 .doc_link_resolutions
1977 .get(self, index)
1978 .expect("no resolutions for a doc link")
1979 .decode((self, tcx))
1980 }
1981
1982 fn get_doc_link_traits_in_scope(
1983 &self,
1984 tcx: TyCtxt<'_>,
1985 index: DefIndex,
1986 ) -> impl Iterator<Item = DefId> {
1987 self.root
1988 .tables
1989 .doc_link_traits_in_scope
1990 .get(self, index)
1991 .expect("no traits in scope for a doc link")
1992 .decode((self, tcx))
1993 }
1994}
1995
1996impl CrateMetadata {
1997 pub(crate) fn new(
1998 tcx: TyCtxt<'_>,
1999 blob: MetadataBlob,
2000 root: CrateRoot,
2001 unhashed: CrateRootUnhashed,
2002 raw_proc_macros: Option<&'static [ProcMacroClient]>,
2003 cnum: CrateNum,
2004 cnum_map: CrateNumMap,
2005 dep_kind: CrateDepKind,
2006 source: CrateSource,
2007 private_dep: bool,
2008 host_hash: Option<Svh>,
2009 ) -> CrateMetadata {
2010 let trait_impls = root
2011 .impls
2012 .decode(&blob)
2013 .map(|trait_impls| (trait_impls.trait_id, trait_impls.impls))
2014 .collect();
2015 let alloc_decoding_state =
2016 AllocDecodingState::new(root.interpret_alloc_index.decode(&blob).collect());
2017
2018 let def_path_hash_map = root.def_path_hash_map.decode(&blob);
2021
2022 let mut cdata = CrateMetadata {
2023 blob,
2024 root,
2025 unhashed,
2026 trait_impls,
2027 incoherent_impls: Default::default(),
2028 raw_proc_macros,
2029 source_map_import_info: Lock::new(Vec::new()),
2030 def_path_hash_map,
2031 expn_hash_map: Default::default(),
2032 alloc_decoding_state,
2033 cnum,
2034 cnum_map,
2035 dep_kind,
2036 source: Arc::new(source),
2037 private_dep,
2038 host_hash,
2039 used: false,
2040 extern_crate: None,
2041 hygiene_context: Default::default(),
2042 def_key_cache: Default::default(),
2043 };
2044
2045 cdata.incoherent_impls = cdata
2046 .root
2047 .incoherent_impls
2048 .decode((&cdata, tcx))
2049 .map(|incoherent_impls| {
2050 (incoherent_impls.self_ty.decode((&cdata, tcx)), incoherent_impls.impls)
2051 })
2052 .collect();
2053
2054 cdata
2055 }
2056
2057 pub(crate) fn dependencies(&self) -> impl Iterator<Item = CrateNum> {
2058 self.cnum_map.iter().copied()
2059 }
2060
2061 pub(crate) fn target_modifiers(&self) -> TargetModifiers {
2062 self.root.decode_target_modifiers(&self.blob).collect()
2063 }
2064
2065 pub(crate) fn enabled_denied_partial_mitigations(&self) -> DeniedPartialMitigations {
2066 self.root.decode_denied_partial_mitigations(&self.blob).collect()
2067 }
2068
2069 pub(crate) fn update_extern_crate_diagnostics(
2071 &mut self,
2072 new_extern_crate: ExternCrate,
2073 ) -> bool {
2074 let update =
2075 self.extern_crate.as_ref().is_none_or(|old| old.rank() < new_extern_crate.rank());
2076 if update {
2077 self.extern_crate = Some(new_extern_crate);
2078 }
2079 update
2080 }
2081
2082 pub(crate) fn source(&self) -> &CrateSource {
2083 &*self.source
2084 }
2085
2086 pub(crate) fn dep_kind(&self) -> CrateDepKind {
2087 self.dep_kind
2088 }
2089
2090 pub(crate) fn set_dep_kind(&mut self, dep_kind: CrateDepKind) {
2091 self.dep_kind = dep_kind;
2092 }
2093
2094 pub(crate) fn update_and_private_dep(&mut self, private_dep: bool) {
2095 self.private_dep &= private_dep;
2096 }
2097
2098 pub(crate) fn used(&self) -> bool {
2099 self.used
2100 }
2101
2102 pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {
2103 self.root.required_panic_strategy
2104 }
2105
2106 pub(crate) fn needs_panic_runtime(&self) -> bool {
2107 self.root.needs_panic_runtime
2108 }
2109
2110 pub(crate) fn is_private_dep(&self) -> bool {
2111 self.private_dep
2112 }
2113
2114 pub(crate) fn is_panic_runtime(&self) -> bool {
2115 self.root.panic_runtime
2116 }
2117
2118 pub(crate) fn is_profiler_runtime(&self) -> bool {
2119 self.root.profiler_runtime
2120 }
2121
2122 pub(crate) fn is_compiler_builtins(&self) -> bool {
2123 self.root.compiler_builtins
2124 }
2125
2126 pub(crate) fn needs_allocator(&self) -> bool {
2127 self.root.needs_allocator
2128 }
2129
2130 pub(crate) fn has_global_allocator(&self) -> bool {
2131 self.root.has_global_allocator
2132 }
2133
2134 pub(crate) fn has_alloc_error_handler(&self) -> bool {
2135 self.root.has_alloc_error_handler
2136 }
2137
2138 pub(crate) fn has_default_lib_allocator(&self) -> bool {
2139 self.root.has_default_lib_allocator
2140 }
2141
2142 pub(crate) fn is_proc_macro_crate(&self) -> bool {
2143 self.root.is_proc_macro_crate()
2144 }
2145
2146 pub(crate) fn proc_macros_for_crate(
2147 &self,
2148 tcx: TyCtxt<'_>,
2149 krate: CrateNum,
2150 ) -> impl Iterator<Item = DefId> {
2151 gen move {
2152 if let Some(data) = &self.root.proc_macro_data {
2153 for def_id in data
2154 .macros
2155 .decode((self, tcx))
2156 .map(move |(id, _)| DefId { krate, index: id.local_def_index })
2157 {
2158 yield def_id;
2159 }
2160 }
2161 }
2162 }
2163
2164 pub(crate) fn name(&self) -> Symbol {
2165 self.root.header.name
2166 }
2167
2168 pub(crate) fn hash(&self) -> Svh {
2169 self.blob.get_crate_hash()
2170 }
2171
2172 pub(crate) fn has_async_drops(&self) -> bool {
2173 self.root.tables.adt_async_destructor.len > 0
2174 }
2175
2176 fn num_def_ids(&self) -> usize {
2177 self.root.tables.def_keys.size()
2178 }
2179
2180 fn local_def_id(&self, index: DefIndex) -> DefId {
2181 DefId { krate: self.cnum, index }
2182 }
2183
2184 fn reverse_translate_def_id(&self, did: DefId) -> Option<RemappedRawDefId> {
2187 for (local, &global) in self.cnum_map.iter_enumerated() {
2188 if global == did.krate {
2189 return Some(RemappedRawDefId::new_unchecked(local.as_u32(), did.index.as_u32()));
2190 }
2191 }
2192
2193 None
2194 }
2195}