@@ -51,9 +51,7 @@ macro_rules! provide {
51
51
let ( $def_id, $other) = def_id_arg. into_args( ) ;
52
52
assert!( !$def_id. is_local( ) ) ;
53
53
54
- let $cdata = $tcx. crate_data_as_any( $def_id. krate) ;
55
- let $cdata = $cdata. downcast_ref:: <rmeta:: CrateMetadata >( )
56
- . expect( "CrateStore created data is not a CrateMetadata" ) ;
54
+ let $cdata = CStore :: from_tcx( $tcx) . get_crate_data( $def_id. krate) ;
57
55
58
56
if $tcx. dep_graph. is_fully_enabled( ) {
59
57
let crate_dep_node_index = $cdata. get_crate_dep_node_index( $tcx) ;
@@ -192,6 +190,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
192
190
}
193
191
crate_disambiguator => { cdata. root. disambiguator }
194
192
crate_hash => { cdata. root. hash }
193
+ crate_host_hash => { cdata. host_hash }
195
194
original_crate_name => { cdata. root. name }
196
195
197
196
extra_filename => { cdata. root. extra_filename. clone( ) }
@@ -377,6 +376,14 @@ pub fn provide(providers: &mut Providers<'_>) {
377
376
assert_eq ! ( cnum, LOCAL_CRATE ) ;
378
377
Lrc :: new ( crate :: dependency_format:: calculate ( tcx) )
379
378
} ,
379
+ has_global_allocator : |tcx, cnum| {
380
+ assert_eq ! ( cnum, LOCAL_CRATE ) ;
381
+ CStore :: from_tcx ( tcx) . has_global_allocator ( )
382
+ } ,
383
+ postorder_cnums : |tcx, cnum| {
384
+ assert_eq ! ( cnum, LOCAL_CRATE ) ;
385
+ tcx. arena . alloc_slice ( & CStore :: from_tcx ( tcx) . crate_dependencies_in_postorder ( cnum) )
386
+ } ,
380
387
381
388
..* providers
382
389
} ;
@@ -459,8 +466,8 @@ impl CStore {
459
466
}
460
467
461
468
impl CrateStore for CStore {
462
- fn crate_data_as_any ( & self , cnum : CrateNum ) -> & dyn Any {
463
- self . get_crate_data ( cnum )
469
+ fn as_any ( & self ) -> & dyn Any {
470
+ self
464
471
}
465
472
466
473
fn item_generics_cloned_untracked ( & self , def : DefId , sess : & Session ) -> ty:: Generics {
@@ -486,10 +493,6 @@ impl CrateStore for CStore {
486
493
self . get_crate_data ( cnum) . root . hash
487
494
}
488
495
489
- fn crate_host_hash_untracked ( & self , cnum : CrateNum ) -> Option < Svh > {
490
- self . get_crate_data ( cnum) . host_hash
491
- }
492
-
493
496
/// Returns the `DefKey` for a given `DefId`. This indicates the
494
497
/// parent `DefId` as well as some idea of what kind of data the
495
498
/// `DefId` refers to.
@@ -516,10 +519,6 @@ impl CrateStore for CStore {
516
519
result
517
520
}
518
521
519
- fn postorder_cnums_untracked ( & self ) -> Vec < CrateNum > {
520
- self . crate_dependencies_in_postorder ( LOCAL_CRATE )
521
- }
522
-
523
522
fn encode_metadata ( & self , tcx : TyCtxt < ' _ > ) -> EncodedMetadata {
524
523
encoder:: encode_metadata ( tcx)
525
524
}
@@ -529,15 +528,7 @@ impl CrateStore for CStore {
529
528
rmeta:: METADATA_HEADER
530
529
}
531
530
532
- fn injected_panic_runtime ( & self ) -> Option < CrateNum > {
533
- self . injected_panic_runtime ( )
534
- }
535
-
536
531
fn allocator_kind ( & self ) -> Option < AllocatorKind > {
537
532
self . allocator_kind ( )
538
533
}
539
-
540
- fn has_global_allocator ( & self ) -> bool {
541
- self . has_global_allocator ( )
542
- }
543
534
}
0 commit comments