1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
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.
11 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
12 // file at the top-level directory of this distribution and at
13 // http://rust-lang.org/COPYRIGHT.
15 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
16 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
17 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
18 // option. This file may not be copied, modified, or distributed
19 // except according to those terms.
21 // the rustc crate store interface. This also includes types that
22 // are *mostly* used as a part of that interface, but these should
23 // probably get a better home if someone can find one.
25 use hir::def::{self, Def};
26 use hir::def_id::{CrateNum, DefId, DefIndex};
27 use hir::map as hir_map;
28 use hir::map::definitions::{Definitions, DefKey, DisambiguatedDefPathData};
30 use middle::lang_items;
31 use ty::{self, Ty, TyCtxt};
34 use session::search_paths::PathKind;
35 use util::nodemap::{NodeSet, DefIdMap};
36 use std::path::PathBuf;
40 use syntax::ext::base::SyntaxExtension;
42 use syntax::symbol::Symbol;
44 use rustc_back::target::Target;
46 use hir::intravisit::Visitor;
47 use rustc_back::PanicStrategy;
49 pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown};
51 // lonely orphan structs and enums looking for a better home
53 #[derive(Clone, Debug)]
55 pub crate_name: Symbol,
59 // Where a crate came from on the local filesystem. One of these three options
61 #[derive(PartialEq, Clone, Debug)]
62 pub struct CrateSource {
63 pub dylib: Option<(PathBuf, PathKind)>,
64 pub rlib: Option<(PathBuf, PathKind)>,
65 pub rmeta: Option<(PathBuf, PathKind)>,
68 #[derive(RustcEncodable, RustcDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
70 /// A dependency that is only used for its macros, none of which are visible from other crates.
71 /// These are included in the metadata only as placeholders and are ignored when decoding.
73 /// A dependency that is only used for its macros.
75 /// A dependency that is always injected into the dependency list and so
76 /// doesn't need to be linked to an rlib, e.g. the injected allocator.
78 /// A dependency that is required by an rlib version of this crate.
79 /// Ordinary `extern crate`s result in `Explicit` dependencies.
84 pub fn macros_only(self) -> bool {
86 DepKind::UnexportedMacrosOnly | DepKind::MacrosOnly => true,
87 DepKind::Implicit | DepKind::Explicit => false,
92 #[derive(PartialEq, Clone, Debug)]
100 pub fn is_some(&self) -> bool {
101 if let LibSource::Some(_) = *self {
108 pub fn option(&self) -> Option<PathBuf> {
110 LibSource::Some(ref p) => Some(p.clone()),
111 LibSource::MetadataOnly | LibSource::None => None,
116 #[derive(Copy, Debug, PartialEq, Clone, RustcEncodable, RustcDecodable)]
117 pub enum LinkagePreference {
122 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
123 pub enum NativeLibraryKind {
124 NativeStatic, // native static library (.a archive)
125 NativeFramework, // OSX-specific
126 NativeUnknown, // default way to specify a dynamic library
129 #[derive(Clone, Hash, RustcEncodable, RustcDecodable)]
130 pub struct NativeLibrary {
131 pub kind: NativeLibraryKind,
133 pub cfg: Option<ast::MetaItem>,
134 pub foreign_items: Vec<DefIndex>,
137 /// The data we save and restore about an inlined item or method. This is not
138 /// part of the AST that we parse from a file, but it becomes part of the tree
140 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
141 pub struct InlinedItem {
143 pub body: P<hir::Expr>,
144 pub const_fn_args: Vec<Option<DefId>>,
147 /// A borrowed version of `hir::InlinedItem`. This is what's encoded when saving
148 /// a crate; it then gets read as an InlinedItem.
149 #[derive(Clone, PartialEq, Eq, RustcEncodable, Hash, Debug)]
150 pub struct InlinedItemRef<'a> {
152 pub body: &'a hir::Expr,
153 pub const_fn_args: Vec<Option<DefId>>,
156 fn get_fn_args(decl: &hir::FnDecl) -> Vec<Option<DefId>> {
157 decl.inputs.iter().map(|arg| match arg.pat.node {
158 hir::PatKind::Binding(_, def_id, _, _) => Some(def_id),
163 impl<'a> InlinedItemRef<'a> {
164 pub fn from_item<'b, 'tcx>(def_id: DefId,
166 tcx: TyCtxt<'b, 'a, 'tcx>)
167 -> InlinedItemRef<'a> {
168 let (body, args) = match item.node {
169 hir::ItemFn(ref decl, _, _, _, _, body_id) =>
170 (tcx.map.expr(body_id), get_fn_args(decl)),
171 hir::ItemConst(_, ref body) => (&**body, Vec::new()),
172 _ => bug!("InlinedItemRef::from_item wrong kind")
181 pub fn from_trait_item(def_id: DefId,
182 item: &'a hir::TraitItem,
184 -> InlinedItemRef<'a> {
185 let (body, args) = match item.node {
186 hir::ConstTraitItem(_, Some(ref body)) =>
187 (&**body, Vec::new()),
188 hir::ConstTraitItem(_, None) => {
189 bug!("InlinedItemRef::from_trait_item called for const without body")
191 _ => bug!("InlinedItemRef::from_trait_item wrong kind")
200 pub fn from_impl_item<'b, 'tcx>(def_id: DefId,
201 item: &'a hir::ImplItem,
202 tcx: TyCtxt<'b, 'a, 'tcx>)
203 -> InlinedItemRef<'a> {
204 let (body, args) = match item.node {
205 hir::ImplItemKind::Method(ref sig, body_id) =>
206 (tcx.map.expr(body_id), get_fn_args(&sig.decl)),
207 hir::ImplItemKind::Const(_, ref body) =>
208 (&**body, Vec::new()),
209 _ => bug!("InlinedItemRef::from_impl_item wrong kind")
218 pub fn visit<V>(&self, visitor: &mut V)
221 visitor.visit_expr(&self.body);
226 pub fn visit<'ast,V>(&'ast self, visitor: &mut V)
227 where V: Visitor<'ast>
229 visitor.visit_expr(&self.body);
233 pub enum LoadedMacro {
234 MacroRules(ast::MacroDef),
235 ProcMacro(Rc<SyntaxExtension>),
238 #[derive(Copy, Clone, Debug)]
239 pub struct ExternCrate {
240 /// def_id of an `extern crate` in the current crate that caused
241 /// this crate to be loaded; note that there could be multiple
245 /// span of the extern crate that caused this to be loaded
248 /// If true, then this crate is the crate named by the extern
249 /// crate referenced above. If false, then this crate is a dep
253 /// Number of links to reach the extern crate `def_id`
254 /// declaration; used to select the extern crate with the shortest
259 /// A store of Rust crates, through with their metadata
261 pub trait CrateStore<'tcx> {
263 fn describe_def(&self, def: DefId) -> Option<Def>;
264 fn def_span(&self, sess: &Session, def: DefId) -> Span;
265 fn stability(&self, def: DefId) -> Option<attr::Stability>;
266 fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>;
267 fn visibility(&self, def: DefId) -> ty::Visibility;
268 fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind;
269 fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
270 -> ty::ClosureTy<'tcx>;
271 fn item_variances(&self, def: DefId) -> Vec<ty::Variance>;
272 fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
274 fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>>;
275 fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
276 -> ty::GenericPredicates<'tcx>;
277 fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
278 -> ty::GenericPredicates<'tcx>;
279 fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
280 -> ty::Generics<'tcx>;
281 fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
282 fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef;
283 fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef;
284 fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
285 fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>;
288 fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId>;
291 fn associated_item_def_ids(&self, def_id: DefId) -> Vec<DefId>;
292 fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
293 -> Option<ty::TraitRef<'tcx>>;
294 fn impl_polarity(&self, def: DefId) -> hir::ImplPolarity;
295 fn custom_coerce_unsized_kind(&self, def: DefId)
296 -> Option<ty::adjustment::CustomCoerceUnsized>;
297 fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;
299 // trait/impl-item info
300 fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;
301 fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem>;
304 fn is_const_fn(&self, did: DefId) -> bool;
305 fn is_defaulted_trait(&self, did: DefId) -> bool;
306 fn is_default_impl(&self, impl_did: DefId) -> bool;
307 fn is_foreign_item(&self, did: DefId) -> bool;
308 fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
309 fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
312 fn dylib_dependency_formats(&self, cnum: CrateNum)
313 -> Vec<(CrateNum, LinkagePreference)>;
314 fn dep_kind(&self, cnum: CrateNum) -> DepKind;
315 fn export_macros(&self, cnum: CrateNum);
316 fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
317 fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>;
318 fn is_staged_api(&self, cnum: CrateNum) -> bool;
319 fn is_allocator(&self, cnum: CrateNum) -> bool;
320 fn is_panic_runtime(&self, cnum: CrateNum) -> bool;
321 fn is_compiler_builtins(&self, cnum: CrateNum) -> bool;
322 fn panic_strategy(&self, cnum: CrateNum) -> PanicStrategy;
323 fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate>;
324 /// The name of the crate as it is referred to in source code of the current
326 fn crate_name(&self, cnum: CrateNum) -> Symbol;
327 /// The name of the crate as it is stored in the crate's metadata.
328 fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
329 fn crate_hash(&self, cnum: CrateNum) -> Svh;
330 fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
331 fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
332 fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
333 fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>;
334 fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId>;
335 fn is_no_builtins(&self, cnum: CrateNum) -> bool;
338 fn retrace_path(&self,
340 path_data: &[DisambiguatedDefPathData])
342 fn def_key(&self, def: DefId) -> DefKey;
343 fn def_path(&self, def: DefId) -> hir_map::DefPath;
344 fn struct_field_names(&self, def: DefId) -> Vec<ast::Name>;
345 fn item_children(&self, did: DefId) -> Vec<def::Export>;
346 fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro;
349 fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
350 -> Option<(&'tcx InlinedItem, ast::NodeId)>;
351 fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId>;
352 fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId>;
354 fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> Mir<'tcx>;
355 fn is_item_mir_available(&self, def: DefId) -> bool;
357 /// Take a look if we need to inline or monomorphize this. If so, we
358 /// will emit code for this item in the local crate, and thus
359 /// create a translation item for it.
360 fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool;
362 // This is basically a 1-based range of ints, which is a little
363 // silly - I may fix that.
364 fn crates(&self) -> Vec<CrateNum>;
365 fn used_libraries(&self) -> Vec<NativeLibrary>;
366 fn used_link_args(&self) -> Vec<String>;
369 fn metadata_filename(&self) -> &str;
370 fn metadata_section_name(&self, target: &Target) -> &str;
371 fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)>;
372 fn used_crate_source(&self, cnum: CrateNum) -> CrateSource;
373 fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum>;
374 fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
375 reexports: &def::ExportMap,
376 link_meta: &LinkMeta,
377 reachable: &NodeSet) -> Vec<u8>;
378 fn metadata_encoding_version(&self) -> &[u8];
381 // FIXME: find a better place for this?
382 pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
383 let mut err_count = 0;
385 let mut say = |s: &str| {
387 (_, None) => bug!("{}", s),
388 (Some(sp), Some(sess)) => sess.span_err(sp, s),
389 (None, Some(sess)) => sess.err(s),
394 say("crate name must not be empty");
397 if c.is_alphanumeric() { continue }
398 if c == '_' { continue }
399 say(&format!("invalid character `{}` in crate name: `{}`", c, s));
404 sess.unwrap().abort_if_errors();
408 /// A dummy crate store that does not support any non-local crates,
409 /// for test purposes.
410 pub struct DummyCrateStore;
411 #[allow(unused_variables)]
412 impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
414 fn describe_def(&self, def: DefId) -> Option<Def> { bug!("describe_def") }
415 fn def_span(&self, sess: &Session, def: DefId) -> Span { bug!("def_span") }
416 fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
417 fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
418 fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
419 fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind { bug!("closure_kind") }
420 fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
421 -> ty::ClosureTy<'tcx> { bug!("closure_ty") }
422 fn item_variances(&self, def: DefId) -> Vec<ty::Variance> { bug!("item_variances") }
423 fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
424 -> Ty<'tcx> { bug!("item_type") }
425 fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
426 bug!("visible_parent_map")
428 fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
429 -> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
430 fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
431 -> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
432 fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
433 -> ty::Generics<'tcx> { bug!("item_generics") }
434 fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
435 fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef
436 { bug!("trait_def") }
437 fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef
439 fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
440 fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }
443 fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId> { vec![] }
446 fn associated_item_def_ids(&self, def_id: DefId) -> Vec<DefId>
447 { bug!("associated_items") }
448 fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
449 -> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
450 fn impl_polarity(&self, def: DefId) -> hir::ImplPolarity { bug!("impl_polarity") }
451 fn custom_coerce_unsized_kind(&self, def: DefId)
452 -> Option<ty::adjustment::CustomCoerceUnsized>
453 { bug!("custom_coerce_unsized_kind") }
454 fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
456 // trait/impl-item info
457 fn trait_of_item(&self, def_id: DefId) -> Option<DefId> { bug!("trait_of_item") }
458 fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem> { bug!("associated_item") }
461 fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
462 fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
463 fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
464 fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") }
465 fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
466 fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
469 fn dylib_dependency_formats(&self, cnum: CrateNum)
470 -> Vec<(CrateNum, LinkagePreference)>
471 { bug!("dylib_dependency_formats") }
472 fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>
473 { bug!("lang_items") }
474 fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
475 { bug!("missing_lang_items") }
476 fn is_staged_api(&self, cnum: CrateNum) -> bool { bug!("is_staged_api") }
477 fn dep_kind(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
478 fn export_macros(&self, cnum: CrateNum) { bug!("export_macros") }
479 fn is_allocator(&self, cnum: CrateNum) -> bool { bug!("is_allocator") }
480 fn is_panic_runtime(&self, cnum: CrateNum) -> bool { bug!("is_panic_runtime") }
481 fn is_compiler_builtins(&self, cnum: CrateNum) -> bool { bug!("is_compiler_builtins") }
482 fn panic_strategy(&self, cnum: CrateNum) -> PanicStrategy {
483 bug!("panic_strategy")
485 fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
486 fn crate_name(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
487 fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
488 bug!("original_crate_name")
490 fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
491 fn crate_disambiguator(&self, cnum: CrateNum)
492 -> Symbol { bug!("crate_disambiguator") }
493 fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
494 { bug!("plugin_registrar_fn") }
495 fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
496 { bug!("derive_registrar_fn") }
497 fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
498 { bug!("native_libraries") }
499 fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId> { bug!("exported_symbols") }
500 fn is_no_builtins(&self, cnum: CrateNum) -> bool { bug!("is_no_builtins") }
503 fn retrace_path(&self,
505 path_data: &[DisambiguatedDefPathData])
510 fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
511 fn def_path(&self, def: DefId) -> hir_map::DefPath {
512 bug!("relative_def_path")
514 fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
515 fn item_children(&self, did: DefId) -> Vec<def::Export> { bug!("item_children") }
516 fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro { bug!("load_macro") }
519 fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
520 -> Option<(&'tcx InlinedItem, ast::NodeId)> {
521 bug!("maybe_get_item_ast")
523 fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId> {
524 bug!("local_node_for_inlined_defid")
526 fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId> {
527 bug!("defid_for_inlined_node")
530 fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
531 -> Mir<'tcx> { bug!("get_item_mir") }
532 fn is_item_mir_available(&self, def: DefId) -> bool {
533 bug!("is_item_mir_available")
535 fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool {
536 bug!("can_have_local_instance")
539 // This is basically a 1-based range of ints, which is a little
540 // silly - I may fix that.
541 fn crates(&self) -> Vec<CrateNum> { vec![] }
542 fn used_libraries(&self) -> Vec<NativeLibrary> { vec![] }
543 fn used_link_args(&self) -> Vec<String> { vec![] }
546 fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
547 fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
548 fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)>
550 fn used_crate_source(&self, cnum: CrateNum) -> CrateSource { bug!("used_crate_source") }
551 fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum> { None }
552 fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
553 reexports: &def::ExportMap,
554 link_meta: &LinkMeta,
555 reachable: &NodeSet) -> Vec<u8> { vec![] }
556 fn metadata_encoding_version(&self) -> &[u8] { bug!("metadata_encoding_version") }
559 pub trait CrateLoader {
560 fn process_item(&mut self, item: &ast::Item, defs: &Definitions);
561 fn postprocess(&mut self, krate: &ast::Crate);