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;
41 use syntax::symbol::Symbol;
43 use rustc_back::target::Target;
45 use hir::intravisit::Visitor;
46 use rustc_back::PanicStrategy;
48 pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown};
50 // lonely orphan structs and enums looking for a better home
52 #[derive(Clone, Debug)]
54 pub crate_name: Symbol,
58 // Where a crate came from on the local filesystem. One of these three options
60 #[derive(PartialEq, Clone, Debug)]
61 pub struct CrateSource {
62 pub dylib: Option<(PathBuf, PathKind)>,
63 pub rlib: Option<(PathBuf, PathKind)>,
64 pub rmeta: Option<(PathBuf, PathKind)>,
67 #[derive(RustcEncodable, RustcDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
69 /// A dependency that is only used for its macros, none of which are visible from other crates.
70 /// These are included in the metadata only as placeholders and are ignored when decoding.
72 /// A dependency that is only used for its macros.
74 /// A dependency that is always injected into the dependency list and so
75 /// doesn't need to be linked to an rlib, e.g. the injected allocator.
77 /// A dependency that is required by an rlib version of this crate.
78 /// Ordinary `extern crate`s result in `Explicit` dependencies.
83 pub fn macros_only(self) -> bool {
85 DepKind::UnexportedMacrosOnly | DepKind::MacrosOnly => true,
86 DepKind::Implicit | DepKind::Explicit => false,
91 #[derive(PartialEq, Clone, Debug)]
99 pub fn is_some(&self) -> bool {
100 if let LibSource::Some(_) = *self {
107 pub fn option(&self) -> Option<PathBuf> {
109 LibSource::Some(ref p) => Some(p.clone()),
110 LibSource::MetadataOnly | LibSource::None => None,
115 #[derive(Copy, Debug, PartialEq, Clone, RustcEncodable, RustcDecodable)]
116 pub enum LinkagePreference {
121 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
122 pub enum NativeLibraryKind {
123 NativeStatic, // native static library (.a archive)
124 NativeFramework, // OSX-specific
125 NativeUnknown, // default way to specify a dynamic library
128 #[derive(Clone, Hash, RustcEncodable, RustcDecodable)]
129 pub struct NativeLibrary {
130 pub kind: NativeLibraryKind,
132 pub cfg: Option<ast::MetaItem>,
133 pub foreign_items: Vec<DefIndex>,
136 /// The data we save and restore about an inlined item or method. This is not
137 /// part of the AST that we parse from a file, but it becomes part of the tree
139 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
140 pub struct InlinedItem {
143 pub const_fn_args: Vec<Option<DefId>>,
146 /// A borrowed version of `hir::InlinedItem`. This is what's encoded when saving
147 /// a crate; it then gets read as an InlinedItem.
148 #[derive(Clone, PartialEq, Eq, RustcEncodable, Hash, Debug)]
149 pub struct InlinedItemRef<'a> {
151 pub body: &'a hir::Body,
152 pub const_fn_args: Vec<Option<DefId>>,
155 fn get_fn_args(decl: &hir::FnDecl) -> Vec<Option<DefId>> {
156 decl.inputs.iter().map(|arg| match arg.pat.node {
157 hir::PatKind::Binding(_, def_id, _, _) => Some(def_id),
162 impl<'a, 'tcx> InlinedItemRef<'tcx> {
163 pub fn from_item(def_id: DefId,
165 tcx: TyCtxt<'a, 'tcx, 'tcx>)
166 -> InlinedItemRef<'tcx> {
167 let (body_id, args) = match item.node {
168 hir::ItemFn(ref decl, _, _, _, _, body_id) =>
169 (body_id, get_fn_args(decl)),
170 hir::ItemConst(_, body_id) => (body_id, vec![]),
171 _ => bug!("InlinedItemRef::from_item wrong kind")
175 body: tcx.map.body(body_id),
180 pub fn from_trait_item(def_id: DefId,
181 item: &hir::TraitItem,
182 tcx: TyCtxt<'a, 'tcx, 'tcx>)
183 -> InlinedItemRef<'tcx> {
184 let (body_id, args) = match item.node {
185 hir::TraitItemKind::Const(_, Some(body_id)) =>
187 hir::TraitItemKind::Const(_, None) => {
188 bug!("InlinedItemRef::from_trait_item called for const without body")
190 _ => bug!("InlinedItemRef::from_trait_item wrong kind")
194 body: tcx.map.body(body_id),
199 pub fn from_impl_item(def_id: DefId,
200 item: &hir::ImplItem,
201 tcx: TyCtxt<'a, 'tcx, 'tcx>)
202 -> InlinedItemRef<'tcx> {
203 let (body_id, args) = match item.node {
204 hir::ImplItemKind::Method(ref sig, body_id) =>
205 (body_id, get_fn_args(&sig.decl)),
206 hir::ImplItemKind::Const(_, body_id) =>
208 _ => bug!("InlinedItemRef::from_impl_item wrong kind")
212 body: tcx.map.body(body_id),
217 pub fn visit<V>(&self, visitor: &mut V)
218 where V: Visitor<'tcx>
220 visitor.visit_body(self.body);
225 pub fn visit<'ast,V>(&'ast self, visitor: &mut V)
226 where V: Visitor<'ast>
228 visitor.visit_body(&self.body);
232 pub enum LoadedMacro {
233 MacroRules(ast::MacroDef),
234 ProcMacro(Rc<SyntaxExtension>),
237 #[derive(Copy, Clone, Debug)]
238 pub struct ExternCrate {
239 /// def_id of an `extern crate` in the current crate that caused
240 /// this crate to be loaded; note that there could be multiple
244 /// span of the extern crate that caused this to be loaded
247 /// If true, then this crate is the crate named by the extern
248 /// crate referenced above. If false, then this crate is a dep
252 /// Number of links to reach the extern crate `def_id`
253 /// declaration; used to select the extern crate with the shortest
258 /// A store of Rust crates, through with their metadata
260 pub trait CrateStore<'tcx> {
262 fn describe_def(&self, def: DefId) -> Option<Def>;
263 fn def_span(&self, sess: &Session, def: DefId) -> Span;
264 fn stability(&self, def: DefId) -> Option<attr::Stability>;
265 fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>;
266 fn visibility(&self, def: DefId) -> ty::Visibility;
267 fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind;
268 fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
269 -> ty::ClosureTy<'tcx>;
270 fn item_variances(&self, def: DefId) -> Vec<ty::Variance>;
271 fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
273 fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>>;
274 fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
275 -> ty::GenericPredicates<'tcx>;
276 fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
277 -> ty::GenericPredicates<'tcx>;
278 fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
279 -> ty::Generics<'tcx>;
280 fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
281 fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef;
282 fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef;
283 fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
284 fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>;
287 fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId>;
290 fn associated_item_def_ids(&self, def_id: DefId) -> Vec<DefId>;
291 fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
292 -> Option<ty::TraitRef<'tcx>>;
293 fn impl_polarity(&self, def: DefId) -> hir::ImplPolarity;
294 fn custom_coerce_unsized_kind(&self, def: DefId)
295 -> Option<ty::adjustment::CustomCoerceUnsized>;
296 fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;
298 // trait/impl-item info
299 fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;
300 fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem>;
303 fn is_const_fn(&self, did: DefId) -> bool;
304 fn is_defaulted_trait(&self, did: DefId) -> bool;
305 fn is_default_impl(&self, impl_did: DefId) -> bool;
306 fn is_foreign_item(&self, did: DefId) -> bool;
307 fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
308 fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
311 fn dylib_dependency_formats(&self, cnum: CrateNum)
312 -> Vec<(CrateNum, LinkagePreference)>;
313 fn dep_kind(&self, cnum: CrateNum) -> DepKind;
314 fn export_macros(&self, cnum: CrateNum);
315 fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
316 fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>;
317 fn is_staged_api(&self, cnum: CrateNum) -> bool;
318 fn is_allocator(&self, cnum: CrateNum) -> bool;
319 fn is_panic_runtime(&self, cnum: CrateNum) -> bool;
320 fn is_compiler_builtins(&self, cnum: CrateNum) -> bool;
321 fn panic_strategy(&self, cnum: CrateNum) -> PanicStrategy;
322 fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate>;
323 /// The name of the crate as it is referred to in source code of the current
325 fn crate_name(&self, cnum: CrateNum) -> Symbol;
326 /// The name of the crate as it is stored in the crate's metadata.
327 fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
328 fn crate_hash(&self, cnum: CrateNum) -> Svh;
329 fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
330 fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
331 fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
332 fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>;
333 fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId>;
334 fn is_no_builtins(&self, cnum: CrateNum) -> bool;
337 fn retrace_path(&self,
339 path_data: &[DisambiguatedDefPathData])
341 fn def_key(&self, def: DefId) -> DefKey;
342 fn def_path(&self, def: DefId) -> hir_map::DefPath;
343 fn struct_field_names(&self, def: DefId) -> Vec<ast::Name>;
344 fn item_children(&self, did: DefId) -> Vec<def::Export>;
345 fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro;
348 fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
349 -> Option<(&'tcx InlinedItem, ast::NodeId)>;
350 fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId>;
351 fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId>;
353 fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> Mir<'tcx>;
354 fn is_item_mir_available(&self, def: DefId) -> bool;
356 /// Take a look if we need to inline or monomorphize this. If so, we
357 /// will emit code for this item in the local crate, and thus
358 /// create a translation item for it.
359 fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool;
361 // This is basically a 1-based range of ints, which is a little
362 // silly - I may fix that.
363 fn crates(&self) -> Vec<CrateNum>;
364 fn used_libraries(&self) -> Vec<NativeLibrary>;
365 fn used_link_args(&self) -> Vec<String>;
368 fn metadata_filename(&self) -> &str;
369 fn metadata_section_name(&self, target: &Target) -> &str;
370 fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)>;
371 fn used_crate_source(&self, cnum: CrateNum) -> CrateSource;
372 fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum>;
373 fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
374 reexports: &def::ExportMap,
375 link_meta: &LinkMeta,
376 reachable: &NodeSet) -> Vec<u8>;
377 fn metadata_encoding_version(&self) -> &[u8];
380 // FIXME: find a better place for this?
381 pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
382 let mut err_count = 0;
384 let mut say = |s: &str| {
386 (_, None) => bug!("{}", s),
387 (Some(sp), Some(sess)) => sess.span_err(sp, s),
388 (None, Some(sess)) => sess.err(s),
393 say("crate name must not be empty");
396 if c.is_alphanumeric() { continue }
397 if c == '_' { continue }
398 say(&format!("invalid character `{}` in crate name: `{}`", c, s));
403 sess.unwrap().abort_if_errors();
407 /// A dummy crate store that does not support any non-local crates,
408 /// for test purposes.
409 pub struct DummyCrateStore;
410 #[allow(unused_variables)]
411 impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
413 fn describe_def(&self, def: DefId) -> Option<Def> { bug!("describe_def") }
414 fn def_span(&self, sess: &Session, def: DefId) -> Span { bug!("def_span") }
415 fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
416 fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
417 fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
418 fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind { bug!("closure_kind") }
419 fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
420 -> ty::ClosureTy<'tcx> { bug!("closure_ty") }
421 fn item_variances(&self, def: DefId) -> Vec<ty::Variance> { bug!("item_variances") }
422 fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
423 -> Ty<'tcx> { bug!("item_type") }
424 fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
425 bug!("visible_parent_map")
427 fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
428 -> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
429 fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
430 -> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
431 fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
432 -> ty::Generics<'tcx> { bug!("item_generics") }
433 fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
434 fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef
435 { bug!("trait_def") }
436 fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef
438 fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
439 fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }
442 fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId> { vec![] }
445 fn associated_item_def_ids(&self, def_id: DefId) -> Vec<DefId>
446 { bug!("associated_items") }
447 fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
448 -> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
449 fn impl_polarity(&self, def: DefId) -> hir::ImplPolarity { bug!("impl_polarity") }
450 fn custom_coerce_unsized_kind(&self, def: DefId)
451 -> Option<ty::adjustment::CustomCoerceUnsized>
452 { bug!("custom_coerce_unsized_kind") }
453 fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
455 // trait/impl-item info
456 fn trait_of_item(&self, def_id: DefId) -> Option<DefId> { bug!("trait_of_item") }
457 fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem> { bug!("associated_item") }
460 fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
461 fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
462 fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
463 fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") }
464 fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
465 fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
468 fn dylib_dependency_formats(&self, cnum: CrateNum)
469 -> Vec<(CrateNum, LinkagePreference)>
470 { bug!("dylib_dependency_formats") }
471 fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>
472 { bug!("lang_items") }
473 fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
474 { bug!("missing_lang_items") }
475 fn is_staged_api(&self, cnum: CrateNum) -> bool { bug!("is_staged_api") }
476 fn dep_kind(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
477 fn export_macros(&self, cnum: CrateNum) { bug!("export_macros") }
478 fn is_allocator(&self, cnum: CrateNum) -> bool { bug!("is_allocator") }
479 fn is_panic_runtime(&self, cnum: CrateNum) -> bool { bug!("is_panic_runtime") }
480 fn is_compiler_builtins(&self, cnum: CrateNum) -> bool { bug!("is_compiler_builtins") }
481 fn panic_strategy(&self, cnum: CrateNum) -> PanicStrategy {
482 bug!("panic_strategy")
484 fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
485 fn crate_name(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
486 fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
487 bug!("original_crate_name")
489 fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
490 fn crate_disambiguator(&self, cnum: CrateNum)
491 -> Symbol { bug!("crate_disambiguator") }
492 fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
493 { bug!("plugin_registrar_fn") }
494 fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
495 { bug!("derive_registrar_fn") }
496 fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
497 { bug!("native_libraries") }
498 fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId> { bug!("exported_symbols") }
499 fn is_no_builtins(&self, cnum: CrateNum) -> bool { bug!("is_no_builtins") }
502 fn retrace_path(&self,
504 path_data: &[DisambiguatedDefPathData])
509 fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
510 fn def_path(&self, def: DefId) -> hir_map::DefPath {
511 bug!("relative_def_path")
513 fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
514 fn item_children(&self, did: DefId) -> Vec<def::Export> { bug!("item_children") }
515 fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro { bug!("load_macro") }
518 fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
519 -> Option<(&'tcx InlinedItem, ast::NodeId)> {
520 bug!("maybe_get_item_ast")
522 fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId> {
523 bug!("local_node_for_inlined_defid")
525 fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId> {
526 bug!("defid_for_inlined_node")
529 fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
530 -> Mir<'tcx> { bug!("get_item_mir") }
531 fn is_item_mir_available(&self, def: DefId) -> bool {
532 bug!("is_item_mir_available")
534 fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool {
535 bug!("can_have_local_instance")
538 // This is basically a 1-based range of ints, which is a little
539 // silly - I may fix that.
540 fn crates(&self) -> Vec<CrateNum> { vec![] }
541 fn used_libraries(&self) -> Vec<NativeLibrary> { vec![] }
542 fn used_link_args(&self) -> Vec<String> { vec![] }
545 fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
546 fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
547 fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)>
549 fn used_crate_source(&self, cnum: CrateNum) -> CrateSource { bug!("used_crate_source") }
550 fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum> { None }
551 fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
552 reexports: &def::ExportMap,
553 link_meta: &LinkMeta,
554 reachable: &NodeSet) -> Vec<u8> { vec![] }
555 fn metadata_encoding_version(&self) -> &[u8] { bug!("metadata_encoding_version") }
558 pub trait CrateLoader {
559 fn process_item(&mut self, item: &ast::Item, defs: &Definitions);
560 fn postprocess(&mut self, krate: &ast::Crate);