@@ -16,7 +16,7 @@ use schema::CrateRoot;
16
16
17
17
use rustc:: hir:: def_id:: { CrateNum , DefIndex } ;
18
18
use rustc:: hir:: svh:: Svh ;
19
- use rustc:: middle:: cstore:: LoadedMacros ;
19
+ use rustc:: middle:: cstore:: { DepKind , LoadedMacros } ;
20
20
use rustc:: session:: { config, Session } ;
21
21
use rustc_back:: PanicStrategy ;
22
22
use rustc:: session:: search_paths:: PathKind ;
@@ -29,7 +29,7 @@ use std::cell::{RefCell, Cell};
29
29
use std:: ops:: Deref ;
30
30
use std:: path:: PathBuf ;
31
31
use std:: rc:: Rc ;
32
- use std:: fs ;
32
+ use std:: { cmp , fs } ;
33
33
34
34
use syntax:: ast;
35
35
use syntax:: abi:: Abi ;
@@ -60,7 +60,7 @@ fn dump_crates(cstore: &CStore) {
60
60
info ! ( " name: {}" , data. name( ) ) ;
61
61
info ! ( " cnum: {}" , data. cnum) ;
62
62
info ! ( " hash: {}" , data. hash( ) ) ;
63
- info ! ( " reqd: {}" , data. explicitly_linked . get( ) ) ;
63
+ info ! ( " reqd: {:? }" , data. dep_kind . get( ) ) ;
64
64
let CrateSource { dylib, rlib } = data. source . clone ( ) ;
65
65
dylib. map ( |dl| info ! ( " dylib: {}" , dl. 0 . display( ) ) ) ;
66
66
rlib. map ( |rl| info ! ( " rlib: {}" , rl. 0 . display( ) ) ) ;
@@ -258,7 +258,7 @@ impl<'a> CrateLoader<'a> {
258
258
name : & str ,
259
259
span : Span ,
260
260
lib : Library ,
261
- explicitly_linked : bool )
261
+ dep_kind : DepKind )
262
262
-> ( CrateNum , Rc < cstore:: CrateMetadata > ) {
263
263
info ! ( "register crate `extern crate {} as {}`" , name, ident) ;
264
264
let crate_root = lib. metadata . get_root ( ) ;
@@ -299,7 +299,7 @@ impl<'a> CrateLoader<'a> {
299
299
cnum_map : RefCell :: new ( cnum_map) ,
300
300
cnum : cnum,
301
301
codemap_import_info : RefCell :: new ( vec ! [ ] ) ,
302
- explicitly_linked : Cell :: new ( explicitly_linked ) ,
302
+ dep_kind : Cell :: new ( dep_kind ) ,
303
303
source : cstore:: CrateSource {
304
304
dylib : dylib,
305
305
rlib : rlib,
@@ -317,7 +317,7 @@ impl<'a> CrateLoader<'a> {
317
317
hash : Option < & Svh > ,
318
318
span : Span ,
319
319
kind : PathKind ,
320
- explicitly_linked : bool )
320
+ dep_kind : DepKind )
321
321
-> ( CrateNum , Rc < cstore:: CrateMetadata > ) {
322
322
info ! ( "resolving crate `extern crate {} as {}`" , name, ident) ;
323
323
let result = match self . existing_match ( name, hash, kind) {
@@ -350,12 +350,11 @@ impl<'a> CrateLoader<'a> {
350
350
match result {
351
351
LoadResult :: Previous ( cnum) => {
352
352
let data = self . cstore . get_crate_data ( cnum) ;
353
- data. explicitly_linked . set ( explicitly_linked || data. explicitly_linked . get ( ) ) ;
353
+ data. dep_kind . set ( cmp :: max ( data. dep_kind . get ( ) , dep_kind ) ) ;
354
354
( cnum, data)
355
355
}
356
356
LoadResult :: Loaded ( library) => {
357
- self . register_crate ( root, ident, name, span, library,
358
- explicitly_linked)
357
+ self . register_crate ( root, ident, name, span, library, dep_kind)
359
358
}
360
359
}
361
360
}
@@ -442,7 +441,7 @@ impl<'a> CrateLoader<'a> {
442
441
Some ( & dep. hash ) ,
443
442
span,
444
443
PathKind :: Dependency ,
445
- dep. explicitly_linked ) ;
444
+ dep. kind ) ;
446
445
( CrateNum :: new ( crate_num + 1 ) , local_cnum)
447
446
} ) . collect ( ) ;
448
447
@@ -716,7 +715,7 @@ impl<'a> CrateLoader<'a> {
716
715
// #![panic_runtime] crate.
717
716
self . inject_dependency_if ( cnum, "a panic runtime" ,
718
717
& |data| data. needs_panic_runtime ( ) ) ;
719
- runtime_found = runtime_found || data. explicitly_linked . get ( ) ;
718
+ runtime_found = runtime_found || data. dep_kind . get ( ) == DepKind :: Explicit ;
720
719
}
721
720
} ) ;
722
721
@@ -745,8 +744,9 @@ impl<'a> CrateLoader<'a> {
745
744
} ;
746
745
info ! ( "panic runtime not found -- loading {}" , name) ;
747
746
747
+ let dep_kind = DepKind :: Implicit ;
748
748
let ( cnum, data) =
749
- self . resolve_crate ( & None , name, name, None , DUMMY_SP , PathKind :: Crate , false ) ;
749
+ self . resolve_crate ( & None , name, name, None , DUMMY_SP , PathKind :: Crate , dep_kind ) ;
750
750
751
751
// Sanity check the loaded crate to ensure it is indeed a panic runtime
752
752
// and the panic strategy is indeed what we thought it was.
@@ -780,7 +780,7 @@ impl<'a> CrateLoader<'a> {
780
780
self . inject_dependency_if ( cnum, "an allocator" ,
781
781
& |data| data. needs_allocator ( ) ) ;
782
782
found_required_allocator = found_required_allocator ||
783
- data. explicitly_linked . get ( ) ;
783
+ data. dep_kind . get ( ) == DepKind :: Explicit ;
784
784
}
785
785
} ) ;
786
786
if !needs_allocator || found_required_allocator { return }
@@ -826,8 +826,9 @@ impl<'a> CrateLoader<'a> {
826
826
} else {
827
827
& self . sess . target . target . options . exe_allocation_crate
828
828
} ;
829
+ let dep_kind = DepKind :: Implicit ;
829
830
let ( cnum, data) =
830
- self . resolve_crate ( & None , name, name, None , DUMMY_SP , PathKind :: Crate , false ) ;
831
+ self . resolve_crate ( & None , name, name, None , DUMMY_SP , PathKind :: Crate , dep_kind ) ;
831
832
832
833
// Sanity check the crate we loaded to ensure that it is indeed an
833
834
// allocator.
@@ -993,7 +994,7 @@ impl<'a> middle::cstore::CrateLoader for CrateLoader<'a> {
993
994
if let PMDSource :: Owned ( lib) = ekrate. metadata {
994
995
if ekrate. target_only || config:: host_triple ( ) == self . sess . opts . target_triple {
995
996
let ExternCrateInfo { ref ident, ref name, .. } = info;
996
- self . register_crate ( & None , ident, name, item. span , lib, true ) ;
997
+ self . register_crate ( & None , ident, name, item. span , lib, DepKind :: Explicit ) ;
997
998
}
998
999
}
999
1000
@@ -1006,7 +1007,7 @@ impl<'a> middle::cstore::CrateLoader for CrateLoader<'a> {
1006
1007
} ;
1007
1008
1008
1009
let ( cnum, ..) = self . resolve_crate (
1009
- & None , & info. ident , & info. name , None , item. span , PathKind :: Crate , true ,
1010
+ & None , & info. ident , & info. name , None , item. span , PathKind :: Crate , DepKind :: Explicit ,
1010
1011
) ;
1011
1012
1012
1013
let def_id = definitions. opt_local_def_id ( item. id ) . unwrap ( ) ;
0 commit comments