@@ -61,7 +61,18 @@ pub struct LinkMeta {
61
61
pub struct CrateSource {
62
62
pub dylib : Option < ( PathBuf , PathKind ) > ,
63
63
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 ,
65
76
}
66
77
67
78
#[ derive( Copy , Debug , PartialEq , Clone , RustcEncodable , RustcDecodable ) ]
@@ -170,10 +181,10 @@ pub trait CrateStore<'tcx> {
170
181
// crate metadata
171
182
fn dylib_dependency_formats ( & self , cnum : CrateNum )
172
183
-> Vec < ( CrateNum , LinkagePreference ) > ;
184
+ fn dep_kind ( & self , cnum : CrateNum ) -> DepKind ;
173
185
fn lang_items ( & self , cnum : CrateNum ) -> Vec < ( DefIndex , usize ) > ;
174
186
fn missing_lang_items ( & self , cnum : CrateNum ) -> Vec < lang_items:: LangItem > ;
175
187
fn is_staged_api ( & self , cnum : CrateNum ) -> bool ;
176
- fn is_explicitly_linked ( & self , cnum : CrateNum ) -> bool ;
177
188
fn is_allocator ( & self , cnum : CrateNum ) -> bool ;
178
189
fn is_panic_runtime ( & self , cnum : CrateNum ) -> bool ;
179
190
fn is_compiler_builtins ( & self , cnum : CrateNum ) -> bool ;
@@ -200,6 +211,7 @@ pub trait CrateStore<'tcx> {
200
211
fn relative_def_path ( & self , def : DefId ) -> Option < hir_map:: DefPath > ;
201
212
fn struct_field_names ( & self , def : DefId ) -> Vec < ast:: Name > ;
202
213
fn item_children ( & self , did : DefId ) -> Vec < def:: Export > ;
214
+ fn load_macro ( & self , did : DefId , sess : & Session ) -> ast:: MacroDef ;
203
215
204
216
// misc. metadata
205
217
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 {
342
354
fn missing_lang_items ( & self , cnum : CrateNum ) -> Vec < lang_items:: LangItem >
343
355
{ bug ! ( "missing_lang_items" ) }
344
356
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" ) }
346
358
fn is_allocator ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_allocator" ) }
347
359
fn is_panic_runtime ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_panic_runtime" ) }
348
360
fn is_compiler_builtins ( & self , cnum : CrateNum ) -> bool { bug ! ( "is_compiler_builtins" ) }
@@ -371,6 +383,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
371
383
}
372
384
fn struct_field_names ( & self , def : DefId ) -> Vec < ast:: Name > { bug ! ( "struct_field_names" ) }
373
385
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" ) }
374
387
375
388
// misc. metadata
376
389
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 {
410
423
fn metadata_encoding_version ( & self ) -> & [ u8 ] { bug ! ( "metadata_encoding_version" ) }
411
424
}
412
425
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
-
427
426
pub trait CrateLoader {
428
427
fn process_item ( & mut self , item : & ast:: Item , defs : & Definitions , load_macros : bool )
429
- -> Option < LoadedMacros > ;
428
+ -> Vec < ( ast :: Name , SyntaxExtension ) > ;
430
429
fn postprocess ( & mut self , krate : & ast:: Crate ) ;
431
430
}
0 commit comments