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<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
302 -> Option<ty::AssociatedItem>;
305 fn is_const_fn(&self, did: DefId) -> bool;
306 fn is_defaulted_trait(&self, did: DefId) -> bool;
307 fn is_default_impl(&self, impl_did: DefId) -> bool;
308 fn is_foreign_item(&self, did: DefId) -> bool;
309 fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
310 fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
313 fn dylib_dependency_formats(&self, cnum: CrateNum)
314 -> Vec<(CrateNum, LinkagePreference)>;
315 fn dep_kind(&self, cnum: CrateNum) -> DepKind;
316 fn export_macros(&self, cnum: CrateNum);
317 fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
318 fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>;
319 fn is_staged_api(&self, cnum: CrateNum) -> bool;
320 fn is_allocator(&self, cnum: CrateNum) -> bool;
321 fn is_panic_runtime(&self, cnum: CrateNum) -> bool;
322 fn is_compiler_builtins(&self, cnum: CrateNum) -> bool;
323 fn panic_strategy(&self, cnum: CrateNum) -> PanicStrategy;
324 fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate>;
325 /// The name of the crate as it is referred to in source code of the current
327 fn crate_name(&self, cnum: CrateNum) -> Symbol;
328 /// The name of the crate as it is stored in the crate's metadata.
329 fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
330 fn crate_hash(&self, cnum: CrateNum) -> Svh;
331 fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
332 fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
333 fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
334 fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>;
335 fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId>;
336 fn is_no_builtins(&self, cnum: CrateNum) -> bool;
339 fn retrace_path(&self,
341 path_data: &[DisambiguatedDefPathData])
343 fn def_key(&self, def: DefId) -> DefKey;
344 fn def_path(&self, def: DefId) -> hir_map::DefPath;
345 fn struct_field_names(&self, def: DefId) -> Vec<ast::Name>;
346 fn item_children(&self, did: DefId) -> Vec<def::Export>;
347 fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro;
350 fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
351 -> Option<(&'tcx InlinedItem, ast::NodeId)>;
352 fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId>;
353 fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId>;
355 fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> Mir<'tcx>;
356 fn is_item_mir_available(&self, def: DefId) -> bool;
358 /// Take a look if we need to inline or monomorphize this. If so, we
359 /// will emit code for this item in the local crate, and thus
360 /// create a translation item for it.
361 fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool;
363 // This is basically a 1-based range of ints, which is a little
364 // silly - I may fix that.
365 fn crates(&self) -> Vec<CrateNum>;
366 fn used_libraries(&self) -> Vec<NativeLibrary>;
367 fn used_link_args(&self) -> Vec<String>;
370 fn metadata_filename(&self) -> &str;
371 fn metadata_section_name(&self, target: &Target) -> &str;
372 fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)>;
373 fn used_crate_source(&self, cnum: CrateNum) -> CrateSource;
374 fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum>;
375 fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
376 reexports: &def::ExportMap,
377 link_meta: &LinkMeta,
378 reachable: &NodeSet) -> Vec<u8>;
379 fn metadata_encoding_version(&self) -> &[u8];
382 // FIXME: find a better place for this?
383 pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
384 let mut err_count = 0;
386 let mut say = |s: &str| {
388 (_, None) => bug!("{}", s),
389 (Some(sp), Some(sess)) => sess.span_err(sp, s),
390 (None, Some(sess)) => sess.err(s),
395 say("crate name must not be empty");
398 if c.is_alphanumeric() { continue }
399 if c == '_' { continue }
400 say(&format!("invalid character `{}` in crate name: `{}`", c, s));
405 sess.unwrap().abort_if_errors();
409 /// A dummy crate store that does not support any non-local crates,
410 /// for test purposes.
411 pub struct DummyCrateStore;
412 #[allow(unused_variables)]
413 impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
415 fn describe_def(&self, def: DefId) -> Option<Def> { bug!("describe_def") }
416 fn def_span(&self, sess: &Session, def: DefId) -> Span { bug!("def_span") }
417 fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
418 fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
419 fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
420 fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind { bug!("closure_kind") }
421 fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
422 -> ty::ClosureTy<'tcx> { bug!("closure_ty") }
423 fn item_variances(&self, def: DefId) -> Vec<ty::Variance> { bug!("item_variances") }
424 fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
425 -> Ty<'tcx> { bug!("item_type") }
426 fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
427 bug!("visible_parent_map")
429 fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
430 -> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
431 fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
432 -> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
433 fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
434 -> ty::Generics<'tcx> { bug!("item_generics") }
435 fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
436 fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef
437 { bug!("trait_def") }
438 fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef
440 fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
441 fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }
444 fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId> { vec![] }
447 fn associated_item_def_ids(&self, def_id: DefId) -> Vec<DefId>
448 { bug!("associated_items") }
449 fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
450 -> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
451 fn impl_polarity(&self, def: DefId) -> hir::ImplPolarity { bug!("impl_polarity") }
452 fn custom_coerce_unsized_kind(&self, def: DefId)
453 -> Option<ty::adjustment::CustomCoerceUnsized>
454 { bug!("custom_coerce_unsized_kind") }
455 fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
457 // trait/impl-item info
458 fn trait_of_item(&self, def_id: DefId) -> Option<DefId> { bug!("trait_of_item") }
459 fn associated_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
460 -> Option<ty::AssociatedItem> { bug!("associated_item") }
463 fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
464 fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
465 fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
466 fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") }
467 fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
468 fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
471 fn dylib_dependency_formats(&self, cnum: CrateNum)
472 -> Vec<(CrateNum, LinkagePreference)>
473 { bug!("dylib_dependency_formats") }
474 fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>
475 { bug!("lang_items") }
476 fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
477 { bug!("missing_lang_items") }
478 fn is_staged_api(&self, cnum: CrateNum) -> bool { bug!("is_staged_api") }
479 fn dep_kind(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
480 fn export_macros(&self, cnum: CrateNum) { bug!("export_macros") }
481 fn is_allocator(&self, cnum: CrateNum) -> bool { bug!("is_allocator") }
482 fn is_panic_runtime(&self, cnum: CrateNum) -> bool { bug!("is_panic_runtime") }
483 fn is_compiler_builtins(&self, cnum: CrateNum) -> bool { bug!("is_compiler_builtins") }
484 fn panic_strategy(&self, cnum: CrateNum) -> PanicStrategy {
485 bug!("panic_strategy")
487 fn extern_crate(&self, cnum: CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
488 fn crate_name(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
489 fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
490 bug!("original_crate_name")
492 fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
493 fn crate_disambiguator(&self, cnum: CrateNum)
494 -> Symbol { bug!("crate_disambiguator") }
495 fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
496 { bug!("plugin_registrar_fn") }
497 fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
498 { bug!("derive_registrar_fn") }
499 fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
500 { bug!("native_libraries") }
501 fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId> { bug!("exported_symbols") }
502 fn is_no_builtins(&self, cnum: CrateNum) -> bool { bug!("is_no_builtins") }
505 fn retrace_path(&self,
507 path_data: &[DisambiguatedDefPathData])
512 fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
513 fn def_path(&self, def: DefId) -> hir_map::DefPath {
514 bug!("relative_def_path")
516 fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
517 fn item_children(&self, did: DefId) -> Vec<def::Export> { bug!("item_children") }
518 fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro { bug!("load_macro") }
521 fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
522 -> Option<(&'tcx InlinedItem, ast::NodeId)> {
523 bug!("maybe_get_item_ast")
525 fn local_node_for_inlined_defid(&'tcx self, def_id: DefId) -> Option<ast::NodeId> {
526 bug!("local_node_for_inlined_defid")
528 fn defid_for_inlined_node(&'tcx self, node_id: ast::NodeId) -> Option<DefId> {
529 bug!("defid_for_inlined_node")
532 fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
533 -> Mir<'tcx> { bug!("get_item_mir") }
534 fn is_item_mir_available(&self, def: DefId) -> bool {
535 bug!("is_item_mir_available")
537 fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool {
538 bug!("can_have_local_instance")
541 // This is basically a 1-based range of ints, which is a little
542 // silly - I may fix that.
543 fn crates(&self) -> Vec<CrateNum> { vec![] }
544 fn used_libraries(&self) -> Vec<NativeLibrary> { vec![] }
545 fn used_link_args(&self) -> Vec<String> { vec![] }
548 fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
549 fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
550 fn used_crates(&self, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)>
552 fn used_crate_source(&self, cnum: CrateNum) -> CrateSource { bug!("used_crate_source") }
553 fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum> { None }
554 fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
555 reexports: &def::ExportMap,
556 link_meta: &LinkMeta,
557 reachable: &NodeSet) -> Vec<u8> { vec![] }
558 fn metadata_encoding_version(&self) -> &[u8] { bug!("metadata_encoding_version") }
561 pub trait CrateLoader {
562 fn process_item(&mut self, item: &ast::Item, defs: &Definitions);
563 fn postprocess(&mut self, krate: &ast::Crate);