]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_metadata/src/rmeta/mod.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / compiler / rustc_metadata / src / rmeta / mod.rs
CommitLineData
04454e1e 1use crate::creader::CrateMetadataRef;
60c5eb7d 2use decoder::Metadata;
c295e0f8 3use def_path_hash_map::DefPathHashMapRef;
2b03887a 4use rustc_data_structures::fx::FxHashMap;
923072b8 5use table::TableBuilder;
9e0c209e 6
5e7ed085 7use rustc_ast as ast;
74b04a01 8use rustc_attr as attr;
b7449926 9use rustc_data_structures::svh::Svh;
60c5eb7d 10use rustc_data_structures::sync::MetadataRef;
dfeec247 11use rustc_hir as hir;
9ffffee4 12use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap};
04454e1e 13use rustc_hir::def_id::{CrateNum, DefId, DefIndex, DefPathHash, StableCrateId};
3dfed10e 14use rustc_hir::definitions::DefKey;
487cf647 15use rustc_hir::lang_items::LangItem;
9c376795 16use rustc_index::bit_set::BitSet;
2b03887a 17use rustc_index::vec::IndexVec;
5099ac24 18use rustc_middle::metadata::ModChild;
04454e1e
FG
19use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
20use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
9ffffee4 21use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault;
ba9703b0 22use rustc_middle::mir;
a2a8927a
XL
23use rustc_middle::ty::fast_reject::SimplifiedType;
24use rustc_middle::ty::query::Providers;
9c376795 25use rustc_middle::ty::{self, ReprOptions, Ty, UnusedGenericParams};
2b03887a 26use rustc_middle::ty::{DeducedParamAttrs, GeneratorDiagnosticData, ParameterizedOverTcx, TyCtxt};
064997fb 27use rustc_serialize::opaque::FileEncoder;
ba9703b0 28use rustc_session::config::SymbolManglingVersion;
c295e0f8 29use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
dfeec247 30use rustc_span::edition::Edition;
136023e0 31use rustc_span::hygiene::{ExpnIndex, MacroKind};
f035d41b 32use rustc_span::symbol::{Ident, Symbol};
136023e0 33use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
353b0b11 34use rustc_target::abi::VariantIdx;
dfeec247 35use rustc_target::spec::{PanicStrategy, TargetTriple};
9e0c209e
SL
36
37use std::marker::PhantomData;
e74abb32 38use std::num::NonZeroUsize;
9e0c209e 39
a2a8927a 40pub use decoder::provide_extern;
3dfed10e 41use decoder::DecodeContext;
923072b8 42pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
3dfed10e 43use encoder::EncodeContext;
c295e0f8 44pub use encoder::{encode_metadata, EncodedMetadata};
3dfed10e 45use rustc_span::hygiene::SyntaxContextData;
60c5eb7d
XL
46
47mod decoder;
c295e0f8 48mod def_path_hash_map;
60c5eb7d
XL
49mod encoder;
50mod table;
51
923072b8 52pub(crate) fn rustc_version() -> String {
dfeec247 53 format!("rustc {}", option_env!("CFG_VERSION").unwrap_or("unknown version"))
c30ab7b3 54}
9e0c209e
SL
55
56/// Metadata encoding version.
0731742a 57/// N.B., increment this if you change the format of metadata such that
476ff2be 58/// the rustc version can't be found to compare with `rustc_version()`.
353b0b11 59const METADATA_VERSION: u8 = 7;
9e0c209e
SL
60
61/// Metadata header which includes `METADATA_VERSION`.
9e0c209e 62///
353b0b11
FG
63/// This header is followed by the length of the compressed data, then
64/// the position of the `CrateRoot`, which is encoded as a 32-bit big-endian
65/// unsigned integer, and further followed by the rustc version string.
17df50a5 66pub const METADATA_HEADER: &[u8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
9e0c209e 67
9e0c209e
SL
68/// A value of type T referred to by its absolute position
69/// in the metadata, and which can be decoded lazily.
70///
71/// Metadata is effective a tree, encoded in post-order,
72/// and with the root's position written next to the header.
064997fb 73/// That means every single `LazyValue` points to some previous
9e0c209e
SL
74/// location in the metadata and is part of a larger node.
75///
064997fb 76/// The first `LazyValue` in a node is encoded as the backwards
9e0c209e 77/// distance from the position where the containing node
064997fb
FG
78/// starts and where the `LazyValue` points to, while the rest
79/// use the forward distance from the previous `LazyValue`.
9e0c209e
SL
80/// Distances start at 1, as 0-byte nodes are invalid.
81/// Also invalid are nodes being referred in a different
82/// order than they were encoded in.
923072b8
FG
83#[must_use]
84struct LazyValue<T> {
85 position: NonZeroUsize,
86 _marker: PhantomData<fn() -> T>,
87}
88
89impl<T: ParameterizedOverTcx> ParameterizedOverTcx for LazyValue<T> {
90 type Value<'tcx> = LazyValue<T::Value<'tcx>>;
91}
92
93impl<T> LazyValue<T> {
94 fn from_position(position: NonZeroUsize) -> LazyValue<T> {
95 LazyValue { position, _marker: PhantomData }
96 }
97}
98
99/// A list of lazily-decoded values.
9e0c209e 100///
064997fb 101/// Unlike `LazyValue<Vec<T>>`, the length is encoded next to the
9e0c209e
SL
102/// position, not at the position, which means that the length
103/// doesn't need to be known before encoding all the elements.
104///
105/// If the length is 0, no position is encoded, but otherwise,
064997fb 106/// the encoding is that of `LazyArray`, with the distinction that
9e0c209e
SL
107/// the minimal distance the length of the sequence, i.e.
108/// it's assumed there's no 0-byte element in the sequence.
923072b8
FG
109struct LazyArray<T> {
110 position: NonZeroUsize,
111 num_elems: usize,
112 _marker: PhantomData<fn() -> T>,
113}
114
115impl<T: ParameterizedOverTcx> ParameterizedOverTcx for LazyArray<T> {
116 type Value<'tcx> = LazyArray<T::Value<'tcx>>;
117}
118
9ffffee4
FG
119impl<T> Default for LazyArray<T> {
120 fn default() -> LazyArray<T> {
121 LazyArray::from_position_and_num_elems(NonZeroUsize::new(1).unwrap(), 0)
122 }
123}
124
923072b8
FG
125impl<T> LazyArray<T> {
126 fn from_position_and_num_elems(position: NonZeroUsize, num_elems: usize) -> LazyArray<T> {
127 LazyArray { position, num_elems, _marker: PhantomData }
128 }
923072b8
FG
129}
130
131/// A list of lazily-decoded values, with the added capability of random access.
132///
133/// Random-access table (i.e. offering constant-time `get`/`set`), similar to
134/// `LazyArray<T>`, but without requiring encoding or decoding all the values
135/// eagerly and in-order.
136struct LazyTable<I, T> {
60c5eb7d 137 position: NonZeroUsize,
923072b8
FG
138 encoded_size: usize,
139 _marker: PhantomData<fn(I) -> T>,
140}
141
142impl<I: 'static, T: ParameterizedOverTcx> ParameterizedOverTcx for LazyTable<I, T> {
143 type Value<'tcx> = LazyTable<I, T::Value<'tcx>>;
9e0c209e
SL
144}
145
923072b8
FG
146impl<I, T> LazyTable<I, T> {
147 fn from_position_and_encoded_size(
148 position: NonZeroUsize,
149 encoded_size: usize,
150 ) -> LazyTable<I, T> {
151 LazyTable { position, encoded_size, _marker: PhantomData }
9e0c209e 152 }
e1599b0c 153}
9e0c209e 154
923072b8
FG
155impl<T> Copy for LazyValue<T> {}
156impl<T> Clone for LazyValue<T> {
157 fn clone(&self) -> Self {
158 *self
9e0c209e
SL
159 }
160}
161
923072b8
FG
162impl<T> Copy for LazyArray<T> {}
163impl<T> Clone for LazyArray<T> {
164 fn clone(&self) -> Self {
165 *self
e1599b0c
XL
166 }
167}
168
923072b8
FG
169impl<I, T> Copy for LazyTable<I, T> {}
170impl<I, T> Clone for LazyTable<I, T> {
c30ab7b3
SL
171 fn clone(&self) -> Self {
172 *self
173 }
9e0c209e
SL
174}
175
064997fb 176/// Encoding / decoding state for `Lazy`s (`LazyValue`, `LazyArray`, and `LazyTable`).
9e0c209e 177#[derive(Copy, Clone, PartialEq, Eq, Debug)]
60c5eb7d 178enum LazyState {
9e0c209e
SL
179 /// Outside of a metadata node.
180 NoNode,
181
064997fb 182 /// Inside a metadata node, and before any `Lazy`s.
9e0c209e 183 /// The position is that of the node itself.
e74abb32 184 NodeStart(NonZeroUsize),
9e0c209e 185
064997fb 186 /// Inside a metadata node, with a previous `Lazy`s.
5099ac24 187 /// The position is where that previous `Lazy` would start.
e74abb32
XL
188 Previous(NonZeroUsize),
189}
190
9ffffee4
FG
191type SyntaxContextTable = LazyTable<u32, Option<LazyValue<SyntaxContextData>>>;
192type ExpnDataTable = LazyTable<ExpnIndex, Option<LazyValue<ExpnData>>>;
193type ExpnHashTable = LazyTable<ExpnIndex, Option<LazyValue<ExpnHash>>>;
3dfed10e 194
1b1a35ee 195#[derive(MetadataEncodable, MetadataDecodable)]
923072b8 196pub(crate) struct ProcMacroData {
1b1a35ee
XL
197 proc_macro_decls_static: DefIndex,
198 stability: Option<attr::Stability>,
923072b8 199 macros: LazyArray<DefIndex>,
1b1a35ee
XL
200}
201
202/// Serialized metadata for a crate.
203/// When compiling a proc-macro crate, we encode many of
923072b8 204/// the `LazyArray<T>` fields as `Lazy::empty()`. This serves two purposes:
1b1a35ee
XL
205///
206/// 1. We avoid performing unnecessary work. Proc-macro crates can only
207/// export proc-macros functions, which are compiled into a shared library.
208/// As a result, a large amount of the information we normally store
209/// (e.g. optimized MIR) is unneeded by downstream crates.
210/// 2. We avoid serializing invalid `CrateNum`s. When we deserialize
211/// a proc-macro crate, we don't load any of its dependencies (since we
212/// just need to invoke a native function from the shared library).
213/// This means that any foreign `CrateNum`s that we serialize cannot be
214/// deserialized, since we will not know how to map them into the current
215/// compilation session. If we were to serialize a proc-macro crate like
216/// a normal crate, much of what we serialized would be unusable in addition
217/// to being unused.
3dfed10e 218#[derive(MetadataEncodable, MetadataDecodable)]
923072b8 219pub(crate) struct CrateRoot {
60c5eb7d
XL
220 name: Symbol,
221 triple: TargetTriple,
222 extra_filename: String,
223 hash: Svh,
6a06907d 224 stable_crate_id: StableCrateId,
064997fb 225 required_panic_strategy: Option<PanicStrategy>,
c295e0f8 226 panic_in_drop_strategy: PanicStrategy,
60c5eb7d
XL
227 edition: Edition,
228 has_global_allocator: bool,
487cf647 229 has_alloc_error_handler: bool,
60c5eb7d
XL
230 has_panic_handler: bool,
231 has_default_lib_allocator: bool,
60c5eb7d 232
923072b8
FG
233 crate_deps: LazyArray<CrateDep>,
234 dylib_dependency_formats: LazyArray<Option<LinkagePreference>>,
235 lib_features: LazyArray<(Symbol, Option<Symbol>)>,
064997fb 236 stability_implications: LazyArray<(Symbol, Symbol)>,
487cf647
FG
237 lang_items: LazyArray<(DefIndex, LangItem)>,
238 lang_items_missing: LazyArray<LangItem>,
923072b8
FG
239 diagnostic_items: LazyArray<(Symbol, DefIndex)>,
240 native_libraries: LazyArray<NativeLib>,
241 foreign_modules: LazyArray<ForeignModule>,
242 traits: LazyArray<DefIndex>,
243 impls: LazyArray<TraitImpls>,
244 incoherent_impls: LazyArray<IncoherentImpls>,
245 interpret_alloc_index: LazyArray<u32>,
1b1a35ee 246 proc_macro_data: Option<ProcMacroData>,
60c5eb7d 247
923072b8
FG
248 tables: LazyTables,
249 debugger_visualizers: LazyArray<rustc_span::DebuggerVisualizerFile>,
60c5eb7d 250
923072b8 251 exported_symbols: LazyArray<(ExportedSymbol<'static>, SymbolExportInfo)>,
3dfed10e
XL
252
253 syntax_contexts: SyntaxContextTable,
254 expn_data: ExpnDataTable,
136023e0 255 expn_hashes: ExpnHashTable,
3dfed10e 256
923072b8 257 def_path_hash_map: LazyValue<DefPathHashMapRef<'static>>,
c295e0f8 258
9ffffee4 259 source_map: LazyTable<u32, Option<LazyValue<rustc_span::SourceFile>>>,
ba9703b0 260
60c5eb7d
XL
261 compiler_builtins: bool,
262 needs_allocator: bool,
263 needs_panic_runtime: bool,
264 no_builtins: bool,
265 panic_runtime: bool,
266 profiler_runtime: bool,
60c5eb7d 267 symbol_mangling_version: SymbolManglingVersion,
9e0c209e
SL
268}
269
04454e1e
FG
270/// On-disk representation of `DefId`.
271/// This creates a type-safe way to enforce that we remap the CrateNum between the on-disk
272/// representation and the compilation session.
273#[derive(Copy, Clone)]
923072b8 274pub(crate) struct RawDefId {
04454e1e
FG
275 krate: u32,
276 index: u32,
277}
278
279impl Into<RawDefId> for DefId {
280 fn into(self) -> RawDefId {
281 RawDefId { krate: self.krate.as_u32(), index: self.index.as_u32() }
282 }
283}
284
285impl RawDefId {
923072b8
FG
286 /// This exists so that `provide_one!` is happy
287 fn decode(self, meta: (CrateMetadataRef<'_>, TyCtxt<'_>)) -> DefId {
288 self.decode_from_cdata(meta.0)
289 }
290
291 fn decode_from_cdata(self, cdata: CrateMetadataRef<'_>) -> DefId {
04454e1e
FG
292 let krate = CrateNum::from_u32(self.krate);
293 let krate = cdata.map_encoded_cnum_to_current(krate);
294 DefId { krate, index: DefIndex::from_u32(self.index) }
295 }
296}
297
3dfed10e 298#[derive(Encodable, Decodable)]
923072b8 299pub(crate) struct CrateDep {
f9f354fc 300 pub name: Symbol,
b7449926 301 pub hash: Svh,
e74abb32 302 pub host_hash: Option<Svh>,
3dfed10e 303 pub kind: CrateDepKind,
83c7162d 304 pub extra_filename: String,
9e0c209e
SL
305}
306
3dfed10e 307#[derive(MetadataEncodable, MetadataDecodable)]
923072b8 308pub(crate) struct TraitImpls {
60c5eb7d 309 trait_id: (u32, DefIndex),
923072b8 310 impls: LazyArray<(DefIndex, Option<SimplifiedType>)>,
9e0c209e
SL
311}
312
5e7ed085 313#[derive(MetadataEncodable, MetadataDecodable)]
923072b8 314pub(crate) struct IncoherentImpls {
5e7ed085 315 self_ty: SimplifiedType,
923072b8 316 impls: LazyArray<DefIndex>,
5e7ed085
FG
317}
318
ba9703b0
XL
319/// Define `LazyTables` and `TableBuilders` at the same time.
320macro_rules! define_tables {
9ffffee4
FG
321 (
322 - defaulted: $($name1:ident: Table<$IDX1:ty, $T1:ty>,)+
323 - optional: $($name2:ident: Table<$IDX2:ty, $T2:ty>,)+
324 ) => {
3dfed10e 325 #[derive(MetadataEncodable, MetadataDecodable)]
923072b8 326 pub(crate) struct LazyTables {
9ffffee4
FG
327 $($name1: LazyTable<$IDX1, $T1>,)+
328 $($name2: LazyTable<$IDX2, Option<$T2>>,)+
60c5eb7d
XL
329 }
330
331 #[derive(Default)]
923072b8 332 struct TableBuilders {
9ffffee4
FG
333 $($name1: TableBuilder<$IDX1, $T1>,)+
334 $($name2: TableBuilder<$IDX2, Option<$T2>>,)+
60c5eb7d
XL
335 }
336
923072b8 337 impl TableBuilders {
064997fb 338 fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
ba9703b0 339 LazyTables {
9ffffee4
FG
340 $($name1: self.$name1.encode(buf),)+
341 $($name2: self.$name2.encode(buf),)+
60c5eb7d
XL
342 }
343 }
344 }
345 }
346}
347
ba9703b0 348define_tables! {
9ffffee4
FG
349- defaulted:
350 is_intrinsic: Table<DefIndex, bool>,
351 is_macro_rules: Table<DefIndex, bool>,
352 is_type_alias_impl_trait: Table<DefIndex, bool>,
353 attr_flags: Table<DefIndex, AttrFlags>,
354 def_path_hashes: Table<DefIndex, DefPathHash>,
355 explicit_item_bounds: Table<DefIndex, LazyArray<(ty::Predicate<'static>, Span)>>,
356 inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
357 inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
353b0b11
FG
358 associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,
359 opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
360 unused_generic_params: Table<DefIndex, UnusedGenericParams>,
361 module_children_reexports: Table<DefIndex, LazyArray<ModChild>>,
9ffffee4
FG
362
363- optional:
923072b8
FG
364 attributes: Table<DefIndex, LazyArray<ast::Attribute>>,
365 children: Table<DefIndex, LazyArray<DefIndex>>,
04454e1e 366 opt_def_kind: Table<DefIndex, DefKind>,
f2b60f7d 367 visibility: Table<DefIndex, LazyValue<ty::Visibility<DefIndex>>>,
923072b8
FG
368 def_span: Table<DefIndex, LazyValue<Span>>,
369 def_ident_span: Table<DefIndex, LazyValue<Span>>,
370 lookup_stability: Table<DefIndex, LazyValue<attr::Stability>>,
371 lookup_const_stability: Table<DefIndex, LazyValue<attr::ConstStability>>,
f2b60f7d 372 lookup_default_body_stability: Table<DefIndex, LazyValue<attr::DefaultBodyStability>>,
923072b8 373 lookup_deprecation_entry: Table<DefIndex, LazyValue<attr::Deprecation>>,
923072b8
FG
374 explicit_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>,
375 generics_of: Table<DefIndex, LazyValue<ty::Generics>>,
923072b8 376 super_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>,
353b0b11
FG
377 // As an optimization, we only store this for trait aliases,
378 // since it's identical to super_predicates_of for traits.
379 implied_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>,
9ffffee4 380 type_of: Table<DefIndex, LazyValue<ty::EarlyBinder<Ty<'static>>>>,
923072b8 381 variances_of: Table<DefIndex, LazyArray<ty::Variance>>,
9ffffee4 382 fn_sig: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::PolyFnSig<'static>>>>,
923072b8 383 codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>,
9c376795
FG
384 impl_trait_ref: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::TraitRef<'static>>>>,
385 const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>,
f2b60f7d 386 object_lifetime_default: Table<DefIndex, LazyValue<ObjectLifetimeDefault>>,
923072b8
FG
387 optimized_mir: Table<DefIndex, LazyValue<mir::Body<'static>>>,
388 mir_for_ctfe: Table<DefIndex, LazyValue<mir::Body<'static>>>,
9ffffee4 389 mir_generator_witnesses: Table<DefIndex, LazyValue<mir::GeneratorLayout<'static>>>,
923072b8 390 promoted_mir: Table<DefIndex, LazyValue<IndexVec<mir::Promoted, mir::Body<'static>>>>,
487cf647 391 thir_abstract_const: Table<DefIndex, LazyValue<ty::Const<'static>>>,
04454e1e
FG
392 impl_parent: Table<DefIndex, RawDefId>,
393 impl_polarity: Table<DefIndex, ty::ImplPolarity>,
923072b8 394 constness: Table<DefIndex, hir::Constness>,
04454e1e 395 impl_defaultness: Table<DefIndex, hir::Defaultness>,
5e7ed085 396 // FIXME(eddyb) perhaps compute this on the fly if cheap enough?
923072b8
FG
397 coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
398 mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
399 rendered_const: Table<DefIndex, LazyValue<String>>,
04454e1e 400 asyncness: Table<DefIndex, hir::IsAsync>,
923072b8
FG
401 fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
402 generator_kind: Table<DefIndex, LazyValue<hir::GeneratorKind>>,
403 trait_def: Table<DefIndex, LazyValue<ty::TraitDef>>,
04454e1e 404 trait_item_def_id: Table<DefIndex, RawDefId>,
923072b8 405 expn_that_defined: Table<DefIndex, LazyValue<ExpnId>>,
2b03887a 406 params_in_repr: Table<DefIndex, LazyValue<BitSet<u32>>>,
923072b8 407 repr_options: Table<DefIndex, LazyValue<ReprOptions>>,
3dfed10e
XL
408 // `def_keys` and `def_path_hashes` represent a lazy version of a
409 // `DefPathTable`. This allows us to avoid deserializing an entire
410 // `DefPathTable` up front, since we may only ever use a few
411 // definitions from any given crate.
923072b8 412 def_keys: Table<DefIndex, LazyValue<DefKey>>,
923072b8
FG
413 proc_macro_quoted_spans: Table<usize, LazyValue<Span>>,
414 generator_diagnostic_data: Table<DefIndex, LazyValue<GeneratorDiagnosticData<'static>>>,
f2b60f7d
FG
415 variant_data: Table<DefIndex, LazyValue<VariantData>>,
416 assoc_container: Table<DefIndex, ty::AssocItemContainer>,
487cf647 417 macro_definition: Table<DefIndex, LazyValue<ast::DelimArgs>>,
f2b60f7d 418 proc_macro: Table<DefIndex, MacroKind>,
2b03887a 419 deduced_param_attrs: Table<DefIndex, LazyArray<DeducedParamAttrs>>,
2b03887a 420 trait_impl_trait_tys: Table<DefIndex, LazyValue<FxHashMap<DefId, Ty<'static>>>>,
9ffffee4
FG
421 doc_link_resolutions: Table<DefIndex, LazyValue<DocLinkResMap>>,
422 doc_link_traits_in_scope: Table<DefIndex, LazyArray<DefId>>,
32a655c1
SL
423}
424
3dfed10e 425#[derive(TyEncodable, TyDecodable)]
60c5eb7d 426struct VariantData {
353b0b11 427 idx: VariantIdx,
60c5eb7d 428 discr: ty::VariantDiscr,
532ac7d7 429 /// If this is unit or tuple-variant/struct, then this is the index of the ctor id.
487cf647 430 ctor: Option<(CtorKind, DefIndex)>,
3dfed10e 431 is_non_exhaustive: bool,
9e0c209e
SL
432}
433
9ffffee4
FG
434bitflags::bitflags! {
435 #[derive(Default)]
436 pub struct AttrFlags: u8 {
437 const IS_DOC_HIDDEN = 1 << 0;
438 }
439}
440
2c00a5a8 441// Tags used for encoding Spans:
ba9703b0
XL
442const TAG_VALID_SPAN_LOCAL: u8 = 0;
443const TAG_VALID_SPAN_FOREIGN: u8 = 1;
cdc7bbd5 444const TAG_PARTIAL_SPAN: u8 = 2;
a2a8927a 445
f2b60f7d
FG
446// Tags for encoding Symbol's
447const SYMBOL_STR: u8 = 0;
448const SYMBOL_OFFSET: u8 = 1;
449const SYMBOL_PREINTERNED: u8 = 2;
450
a2a8927a
XL
451pub fn provide(providers: &mut Providers) {
452 encoder::provide(providers);
453 decoder::provide(providers);
454}
923072b8
FG
455
456trivially_parameterized_over_tcx! {
457 VariantData,
923072b8
FG
458 RawDefId,
459 TraitImpls,
460 IncoherentImpls,
461 CrateRoot,
462 CrateDep,
9ffffee4 463 AttrFlags,
923072b8 464}