@@ -2360,7 +2360,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23602360 if let Some ( id) = self . hir . as_local_node_id ( did) {
23612361 Attributes :: Borrowed ( self . hir . attrs ( id) )
23622362 } else {
2363- Attributes :: Owned ( self . sess . cstore . item_attrs ( did) )
2363+ Attributes :: Owned ( self . item_attrs ( did) )
23642364 }
23652365 }
23662366
@@ -2396,7 +2396,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23962396 let trait_ref = self . impl_trait_ref ( impl_def_id) . unwrap ( ) ;
23972397
23982398 // Record the trait->implementation mapping.
2399- let parent = self . sess . cstore . impl_parent ( impl_def_id) . unwrap_or ( trait_id) ;
2399+ let parent = self . impl_parent ( impl_def_id) . unwrap_or ( trait_id) ;
24002400 def. record_remote_impl ( self , impl_def_id, trait_ref, parent) ;
24012401 }
24022402
@@ -2433,22 +2433,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24332433 }
24342434 }
24352435
2436- /// If the given def ID describes an item belonging to a trait,
2437- /// return the ID of the trait that the trait item belongs to.
2438- /// Otherwise, return `None`.
2439- pub fn trait_of_item ( self , def_id : DefId ) -> Option < DefId > {
2440- if def_id. krate != LOCAL_CRATE {
2441- return self . sess . cstore . trait_of_item ( def_id) ;
2442- }
2443- self . opt_associated_item ( def_id)
2444- . and_then ( |associated_item| {
2445- match associated_item. container {
2446- TraitContainer ( def_id) => Some ( def_id) ,
2447- ImplContainer ( _) => None
2448- }
2449- } )
2450- }
2451-
24522436 /// Construct a parameter environment suitable for static contexts or other contexts where there
24532437 /// are no free type/lifetime parameters in scope.
24542438 pub fn empty_parameter_environment ( self ) -> ParameterEnvironment < ' tcx > {
@@ -2688,13 +2672,28 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span {
26882672 tcx. hir . span_if_local ( def_id) . unwrap ( )
26892673}
26902674
2675+ /// If the given def ID describes an item belonging to a trait,
2676+ /// return the ID of the trait that the trait item belongs to.
2677+ /// Otherwise, return `None`.
2678+ fn trait_of_item < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> Option < DefId > {
2679+ tcx. opt_associated_item ( def_id)
2680+ . and_then ( |associated_item| {
2681+ match associated_item. container {
2682+ TraitContainer ( def_id) => Some ( def_id) ,
2683+ ImplContainer ( _) => None
2684+ }
2685+ } )
2686+ }
2687+
2688+
26912689pub fn provide ( providers : & mut ty:: maps:: Providers ) {
26922690 * providers = ty:: maps:: Providers {
26932691 associated_item,
26942692 associated_item_def_ids,
26952693 adt_sized_constraint,
26962694 adt_dtorck_constraint,
26972695 def_span,
2696+ trait_of_item,
26982697 ..* providers
26992698 } ;
27002699}
0 commit comments