@@ -61,7 +61,18 @@ pub struct LinkMeta {
6161pub struct CrateSource {
6262 pub dylib : Option < ( PathBuf , PathKind ) > ,
6363 pub rlib : Option < ( PathBuf , PathKind ) > ,
64- pub cnum : CrateNum ,
64+ }
65+
66+ #[ derive( RustcEncodable , RustcDecodable , Copy , Clone , Ord , PartialOrd , Eq , PartialEq , Debug ) ]
67+ pub enum DepKind {
68+ /// A dependency that is only used for its macros.
69+ MacrosOnly ,
70+ /// A dependency that is always injected into the dependency list and so
71+ /// doesn't need to be linked to an rlib, e.g. the injected allocator.
72+ Implicit ,
73+ /// A dependency that is required by an rlib version of this crate.
74+ /// Ordinary `extern crate`s result in `Explicit` dependencies.
75+ Explicit ,
6576}
6677
6778#[ derive( Copy , Debug , PartialEq , Clone , RustcEncodable , RustcDecodable ) ]
@@ -170,10 +181,10 @@ pub trait CrateStore<'tcx> {
170181 // crate metadata
171182 fn dylib_dependency_formats ( & self , cnum : CrateNum )
172183 -> Vec < ( CrateNum , LinkagePreference ) > ;
184+ fn dep_kind ( & self , cnum : CrateNum ) -> DepKind ;
173185 fn lang_items ( & self , cnum : CrateNum ) -> Vec < ( DefIndex , usize ) > ;
174186 fn missing_lang_items ( & self , cnum : CrateNum ) -> Vec < lang_items:: LangItem > ;
175187 fn is_staged_api ( & self , cnum : CrateNum ) -> bool ;
176- fn is_explicitly_linked ( & self , cnum : CrateNum ) -> bool ;
177188 fn is_allocator ( & self , cnum : CrateNum ) -> bool ;
178189 fn is_panic_runtime ( & self , cnum : CrateNum ) -> bool ;
179190 fn is_compiler_builtins ( & self , cnum : CrateNum ) -> bool ;
@@ -200,6 +211,7 @@ pub trait CrateStore<'tcx> {
200211 fn relative_def_path ( & self , def : DefId ) -> Option < hir_map:: DefPath > ;
201212 fn struct_field_names ( & self , def : DefId ) -> Vec < ast:: Name > ;
202213 fn item_children ( & self , did : DefId ) -> Vec < def:: Export > ;
214+ fn load_macro ( & self , did : DefId , sess : & Session ) -> ast:: MacroDef ;
203215
204216 // misc. metadata
205217 fn maybe_get_item_ast < ' a > ( & ' tcx self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
@@ -342,7 +354,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
342354 fn missing_lang_items ( & self , cnum : CrateNum ) -> Vec < lang_items:: LangItem >
343355 { bug ! ( "missing_lang_items" ) }
344356 fn is_staged_api ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_staged_api" ) }
345- fn is_explicitly_linked ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_explicitly_linked" ) }
357+ fn dep_kind ( & self , cnum : CrateNum ) -> DepKind { bug ! ( "is_explicitly_linked" ) }
346358 fn is_allocator ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_allocator" ) }
347359 fn is_panic_runtime ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_panic_runtime" ) }
348360 fn is_compiler_builtins ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_compiler_builtins" ) }
@@ -371,6 +383,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
371383 }
372384 fn struct_field_names ( & self , def : DefId ) -> Vec < ast:: Name > { bug ! ( "struct_field_names" ) }
373385 fn item_children ( & self , did : DefId ) -> Vec < def:: Export > { bug ! ( "item_children" ) }
386+ fn load_macro ( & self , did : DefId , sess : & Session ) -> ast:: MacroDef { bug ! ( "load_macro" ) }
374387
375388 // misc. metadata
376389 fn maybe_get_item_ast < ' a > ( & ' tcx self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
@@ -410,22 +423,8 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
410423 fn metadata_encoding_version ( & self ) -> & [ u8 ] { bug ! ( "metadata_encoding_version" ) }
411424}
412425
413- pub enum LoadedMacros {
414- MacroRules ( Vec < ast:: MacroDef > ) ,
415- ProcMacros ( Vec < ( ast:: Name , SyntaxExtension ) > ) ,
416- }
417-
418- impl LoadedMacros {
419- pub fn is_proc_macros ( & self ) -> bool {
420- match * self {
421- LoadedMacros :: ProcMacros ( _) => true ,
422- _ => false ,
423- }
424- }
425- }
426-
427426pub trait CrateLoader {
428427 fn process_item ( & mut self , item : & ast:: Item , defs : & Definitions , load_macros : bool )
429- -> Option < LoadedMacros > ;
428+ -> Vec < ( ast :: Name , SyntaxExtension ) > ;
430429 fn postprocess ( & mut self , krate : & ast:: Crate ) ;
431430}
0 commit comments