@@ -2360,7 +2360,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2360
2360
if let Some ( id) = self . hir . as_local_node_id ( did) {
2361
2361
Attributes :: Borrowed ( self . hir . attrs ( id) )
2362
2362
} else {
2363
- Attributes :: Owned ( self . sess . cstore . item_attrs ( did) )
2363
+ Attributes :: Owned ( self . item_attrs ( did) )
2364
2364
}
2365
2365
}
2366
2366
@@ -2396,7 +2396,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2396
2396
let trait_ref = self . impl_trait_ref ( impl_def_id) . unwrap ( ) ;
2397
2397
2398
2398
// 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) ;
2400
2400
def. record_remote_impl ( self , impl_def_id, trait_ref, parent) ;
2401
2401
}
2402
2402
@@ -2433,22 +2433,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2433
2433
}
2434
2434
}
2435
2435
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
-
2452
2436
/// Construct a parameter environment suitable for static contexts or other contexts where there
2453
2437
/// are no free type/lifetime parameters in scope.
2454
2438
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 {
2688
2672
tcx. hir . span_if_local ( def_id) . unwrap ( )
2689
2673
}
2690
2674
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
+
2691
2689
pub fn provide ( providers : & mut ty:: maps:: Providers ) {
2692
2690
* providers = ty:: maps:: Providers {
2693
2691
associated_item,
2694
2692
associated_item_def_ids,
2695
2693
adt_sized_constraint,
2696
2694
adt_dtorck_constraint,
2697
2695
def_span,
2696
+ trait_of_item,
2698
2697
..* providers
2699
2698
} ;
2700
2699
}
0 commit comments