]> git.proxmox.com Git - rustc.git/blame - src/librustc_metadata/common.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / librustc_metadata / common.rs
CommitLineData
c34b1796 1// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
1a4d82fc
JJ
10
11#![allow(non_camel_case_types, non_upper_case_globals)]
12
13pub use self::astencode_tag::*;
14
c34b1796
AL
15// RBML enum definitions and utils shared by the encoder and decoder
16//
17// 0x00..0x1f: reserved for RBML generic type tags
18// 0x20..0xef: free for use, preferred for frequent tags
19// 0xf0..0xff: internally used by RBML to encode 0x100..0xfff in two bytes
20// 0x100..0xfff: free for use, preferred for infrequent tags
223e47cc 21
c34b1796 22pub const tag_items: usize = 0x100; // top-level only
223e47cc 23
c34b1796 24pub const tag_paths_data_name: usize = 0x20;
223e47cc 25
c34b1796 26pub const tag_def_id: usize = 0x21;
223e47cc 27
c34b1796 28pub const tag_items_data: usize = 0x22;
223e47cc 29
c34b1796 30pub const tag_items_data_item: usize = 0x23;
223e47cc 31
c34b1796 32pub const tag_items_data_item_family: usize = 0x24;
223e47cc 33
c34b1796 34pub const tag_items_data_item_type: usize = 0x25;
223e47cc 35
c34b1796 36pub const tag_items_data_item_symbol: usize = 0x26;
223e47cc 37
c34b1796 38pub const tag_items_data_item_variant: usize = 0x27;
223e47cc 39
c34b1796 40pub const tag_items_data_parent_item: usize = 0x28;
223e47cc 41
c34b1796 42pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;
223e47cc 43
b039eaaf
SL
44pub const tag_items_closure_kind: usize = 0x2a;
45pub const tag_items_closure_ty: usize = 0x2b;
46pub const tag_def_key: usize = 0x2c;
223e47cc 47
b039eaaf
SL
48// GAP 0x2d 0x2e
49
50pub const tag_index: usize = 0x110; // top-level only
51pub const tag_xref_index: usize = 0x111; // top-level only
52pub const tag_xref_data: usize = 0x112; // top-level only
223e47cc 53
c34b1796 54pub const tag_meta_item_name_value: usize = 0x2f;
223e47cc 55
c34b1796 56pub const tag_meta_item_name: usize = 0x30;
223e47cc 57
c34b1796 58pub const tag_meta_item_value: usize = 0x31;
223e47cc 59
c34b1796 60pub const tag_attributes: usize = 0x101; // top-level only
223e47cc 61
c34b1796 62pub const tag_attribute: usize = 0x32;
223e47cc 63
c34b1796 64pub const tag_meta_item_word: usize = 0x33;
223e47cc 65
c34b1796 66pub const tag_meta_item_list: usize = 0x34;
223e47cc
LB
67
68// The list of crates that this crate depends on
c34b1796 69pub const tag_crate_deps: usize = 0x102; // top-level only
223e47cc
LB
70
71// A single crate dependency
c34b1796 72pub const tag_crate_dep: usize = 0x35;
223e47cc 73
c34b1796
AL
74pub const tag_crate_hash: usize = 0x103; // top-level only
75pub const tag_crate_crate_name: usize = 0x104; // top-level only
54a0048b 76pub const tag_crate_disambiguator: usize = 0x113; // top-level only
223e47cc 77
c34b1796
AL
78pub const tag_crate_dep_crate_name: usize = 0x36;
79pub const tag_crate_dep_hash: usize = 0x37;
e9174d1e 80pub const tag_crate_dep_explicitly_linked: usize = 0x38; // top-level only
223e47cc 81
e9174d1e 82pub const tag_item_trait_item: usize = 0x3a;
223e47cc 83
e9174d1e 84pub const tag_item_trait_ref: usize = 0x3b;
223e47cc
LB
85
86// discriminator value for variants
c34b1796 87pub const tag_disr_val: usize = 0x3c;
1a4d82fc 88
54a0048b 89// GAP 0x3d, 0x3e, 0x3f, 0x40
c34b1796 90
54a0048b
SL
91pub const tag_item_field: usize = 0x41;
92// GAP 0x42
c34b1796 93pub const tag_item_variances: usize = 0x43;
223e47cc 94/*
1a4d82fc
JJ
95 trait items contain tag_item_trait_item elements,
96 impl items contain tag_item_impl_item elements, and classes
223e47cc
LB
97 have both. That's because some code treats classes like traits,
98 and other code treats them like impls. Because classes can contain
1a4d82fc 99 both, tag_item_trait_item and tag_item_impl_item have to be two
223e47cc
LB
100 different tags.
101 */
c34b1796
AL
102pub const tag_item_impl_item: usize = 0x44;
103pub const tag_item_trait_method_explicit_self: usize = 0x45;
223e47cc 104
970d7e83 105
223e47cc
LB
106// Reexports are found within module tags. Each reexport contains def_ids
107// and names.
c34b1796
AL
108pub const tag_items_data_item_reexport: usize = 0x46;
109pub const tag_items_data_item_reexport_def_id: usize = 0x47;
110pub const tag_items_data_item_reexport_name: usize = 0x48;
223e47cc
LB
111
112// used to encode crate_ctxt side tables
9346a6ac
AL
113enum_from_u32! {
114 #[derive(Copy, Clone, PartialEq)]
115 #[repr(usize)]
116 pub enum astencode_tag { // Reserves 0x50 -- 0x6f
117 tag_ast = 0x50,
118
119 tag_tree = 0x51,
120
9cc50fc6
SL
121 tag_mir = 0x52,
122
9346a6ac
AL
123 tag_table = 0x53,
124 // GAP 0x54, 0x55
125 tag_table_def = 0x56,
126 tag_table_node_type = 0x57,
127 tag_table_item_subst = 0x58,
128 tag_table_freevars = 0x59,
b039eaaf 129 // GAP 0x5a, 0x5b, 0x5c, 0x5d, 0x5e
9346a6ac 130 tag_table_method_map = 0x5f,
b039eaaf 131 // GAP 0x60
9346a6ac 132 tag_table_adjustments = 0x61,
b039eaaf 133 // GAP 0x62, 0x63, 0x64, 0x65
9346a6ac 134 tag_table_upvar_capture_map = 0x66,
b039eaaf 135 // GAP 0x67, 0x68
9346a6ac 136 tag_table_const_qualif = 0x69,
62682a34 137 tag_table_cast_kinds = 0x6a,
9346a6ac 138 }
970d7e83 139}
223e47cc 140
c34b1796 141pub const tag_item_trait_item_sort: usize = 0x70;
1a4d82fc 142
c34b1796 143pub const tag_crate_triple: usize = 0x105; // top-level only
1a4d82fc 144
c34b1796 145pub const tag_dylib_dependency_formats: usize = 0x106; // top-level only
223e47cc
LB
146
147// Language items are a top-level directory (for speed). Hierarchy:
148//
149// tag_lang_items
150// - tag_lang_items_item
151// - tag_lang_items_item_id: u32
b039eaaf 152// - tag_lang_items_item_index: u32
223e47cc 153
c34b1796
AL
154pub const tag_lang_items: usize = 0x107; // top-level only
155pub const tag_lang_items_item: usize = 0x73;
156pub const tag_lang_items_item_id: usize = 0x74;
b039eaaf 157pub const tag_lang_items_item_index: usize = 0x75;
c34b1796 158pub const tag_lang_items_missing: usize = 0x76;
1a4d82fc 159
c34b1796
AL
160pub const tag_item_unnamed_field: usize = 0x77;
161pub const tag_items_data_item_visibility: usize = 0x78;
b039eaaf
SL
162pub const tag_items_data_item_inherent_impl: usize = 0x79;
163// GAP 0x7a
c34b1796
AL
164pub const tag_mod_child: usize = 0x7b;
165pub const tag_misc_info: usize = 0x108; // top-level only
166pub const tag_misc_info_crate_items: usize = 0x7c;
1a4d82fc 167
c34b1796 168pub const tag_impls: usize = 0x109; // top-level only
b039eaaf
SL
169pub const tag_impls_trait: usize = 0x7d;
170pub const tag_impls_trait_impl: usize = 0x7e;
1a4d82fc 171
b039eaaf 172// GAP 0x7f, 0x80, 0x81
223e47cc 173
c34b1796
AL
174pub const tag_native_libraries: usize = 0x10a; // top-level only
175pub const tag_native_libraries_lib: usize = 0x82;
176pub const tag_native_libraries_name: usize = 0x83;
177pub const tag_native_libraries_kind: usize = 0x84;
223e47cc 178
c34b1796 179pub const tag_plugin_registrar_fn: usize = 0x10b; // top-level only
223e47cc 180
c34b1796
AL
181pub const tag_method_argument_names: usize = 0x85;
182pub const tag_method_argument_name: usize = 0x86;
970d7e83 183
e9174d1e
SL
184pub const tag_reachable_ids: usize = 0x10c; // top-level only
185pub const tag_reachable_id: usize = 0x87;
970d7e83 186
c34b1796 187pub const tag_items_data_item_stability: usize = 0x88;
1a4d82fc 188
c34b1796 189pub const tag_items_data_item_repr: usize = 0x89;
1a4d82fc 190
c34b1796
AL
191pub const tag_struct_fields: usize = 0x10d; // top-level only
192pub const tag_struct_field: usize = 0x8a;
c34b1796 193
b039eaaf 194pub const tag_items_data_item_struct_ctor: usize = 0x8b;
c34b1796 195pub const tag_attribute_is_sugared_doc: usize = 0x8c;
b039eaaf 196// GAP 0x8d
c34b1796 197pub const tag_items_data_region: usize = 0x8e;
1a4d82fc 198
c34b1796
AL
199pub const tag_region_param_def: usize = 0x8f;
200pub const tag_region_param_def_ident: usize = 0x90;
201pub const tag_region_param_def_def_id: usize = 0x91;
202pub const tag_region_param_def_space: usize = 0x92;
203pub const tag_region_param_def_index: usize = 0x93;
1a4d82fc 204
c34b1796 205pub const tag_type_param_def: usize = 0x94;
1a4d82fc 206
c34b1796
AL
207pub const tag_item_generics: usize = 0x95;
208pub const tag_method_ty_generics: usize = 0x96;
1a4d82fc 209
b039eaaf
SL
210pub const tag_type_predicate: usize = 0x97;
211pub const tag_self_predicate: usize = 0x98;
212pub const tag_fn_predicate: usize = 0x99;
1a4d82fc 213
c34b1796 214pub const tag_unsafety: usize = 0x9a;
1a4d82fc 215
c34b1796
AL
216pub const tag_associated_type_names: usize = 0x9b;
217pub const tag_associated_type_name: usize = 0x9c;
1a4d82fc 218
c34b1796 219pub const tag_polarity: usize = 0x9d;
1a4d82fc 220
c34b1796
AL
221pub const tag_macro_defs: usize = 0x10e; // top-level only
222pub const tag_macro_def: usize = 0x9e;
223pub const tag_macro_def_body: usize = 0x9f;
7453a54e
SL
224pub const tag_macro_def_span_lo: usize = 0xa8;
225pub const tag_macro_def_span_hi: usize = 0xa9;
1a4d82fc 226
c34b1796 227pub const tag_paren_sugar: usize = 0xa0;
1a4d82fc 228
c34b1796
AL
229pub const tag_codemap: usize = 0xa1;
230pub const tag_codemap_filemap: usize = 0xa2;
1a4d82fc 231
c34b1796 232pub const tag_item_super_predicates: usize = 0xa3;
85aaf69f 233
c34b1796 234pub const tag_defaulted_trait: usize = 0xa4;
d9579d0f
AL
235
236pub const tag_impl_coerce_unsized_kind: usize = 0xa5;
62682a34
SL
237
238pub const tag_items_data_item_constness: usize = 0xa6;
b039eaaf 239
9cc50fc6
SL
240pub const tag_items_data_item_deprecation: usize = 0xa7;
241
54a0048b
SL
242pub const tag_items_data_item_defaultness: usize = 0xa8;
243
244pub const tag_items_data_parent_impl: usize = 0xa9;
245
b039eaaf
SL
246pub const tag_rustc_version: usize = 0x10f;
247pub fn rustc_version() -> String {
248 format!(
249 "rustc {}",
250 option_env!("CFG_VERSION").unwrap_or("unknown version")
251 )
252}