@@ -51,9 +51,7 @@ macro_rules! provide {
5151 let ( $def_id, $other) = def_id_arg. into_args( ) ;
5252 assert!( !$def_id. is_local( ) ) ;
5353
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) ;
5755
5856 if $tcx. dep_graph. is_fully_enabled( ) {
5957 let crate_dep_node_index = $cdata. get_crate_dep_node_index( $tcx) ;
@@ -192,6 +190,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
192190 }
193191 crate_disambiguator => { cdata. root. disambiguator }
194192 crate_hash => { cdata. root. hash }
193+ crate_host_hash => { cdata. host_hash }
195194 original_crate_name => { cdata. root. name }
196195
197196 extra_filename => { cdata. root. extra_filename. clone( ) }
@@ -377,6 +376,14 @@ pub fn provide(providers: &mut Providers<'_>) {
377376 assert_eq ! ( cnum, LOCAL_CRATE ) ;
378377 Lrc :: new ( crate :: dependency_format:: calculate ( tcx) )
379378 } ,
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+ } ,
380387
381388 ..* providers
382389 } ;
@@ -459,8 +466,8 @@ impl CStore {
459466}
460467
461468impl 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
464471 }
465472
466473 fn item_generics_cloned_untracked ( & self , def : DefId , sess : & Session ) -> ty:: Generics {
@@ -486,10 +493,6 @@ impl CrateStore for CStore {
486493 self . get_crate_data ( cnum) . root . hash
487494 }
488495
489- fn crate_host_hash_untracked ( & self , cnum : CrateNum ) -> Option < Svh > {
490- self . get_crate_data ( cnum) . host_hash
491- }
492-
493496 /// Returns the `DefKey` for a given `DefId`. This indicates the
494497 /// parent `DefId` as well as some idea of what kind of data the
495498 /// `DefId` refers to.
@@ -516,10 +519,6 @@ impl CrateStore for CStore {
516519 result
517520 }
518521
519- fn postorder_cnums_untracked ( & self ) -> Vec < CrateNum > {
520- self . crate_dependencies_in_postorder ( LOCAL_CRATE )
521- }
522-
523522 fn encode_metadata ( & self , tcx : TyCtxt < ' _ > ) -> EncodedMetadata {
524523 encoder:: encode_metadata ( tcx)
525524 }
@@ -529,15 +528,7 @@ impl CrateStore for CStore {
529528 rmeta:: METADATA_HEADER
530529 }
531530
532- fn injected_panic_runtime ( & self ) -> Option < CrateNum > {
533- self . injected_panic_runtime ( )
534- }
535-
536531 fn allocator_kind ( & self ) -> Option < AllocatorKind > {
537532 self . allocator_kind ( )
538533 }
539-
540- fn has_global_allocator ( & self ) -> bool {
541- self . has_global_allocator ( )
542- }
543534}
0 commit comments