@@ -2430,22 +2430,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2430
2430
}
2431
2431
}
2432
2432
2433
- /// If the given def ID describes an item belonging to a trait,
2434
- /// return the ID of the trait that the trait item belongs to.
2435
- /// Otherwise, return `None`.
2436
- pub fn trait_of_item ( self , def_id : DefId ) -> Option < DefId > {
2437
- if def_id. krate != LOCAL_CRATE {
2438
- return self . sess . cstore . trait_of_item ( def_id) ;
2439
- }
2440
- self . opt_associated_item ( def_id)
2441
- . and_then ( |associated_item| {
2442
- match associated_item. container {
2443
- TraitContainer ( def_id) => Some ( def_id) ,
2444
- ImplContainer ( _) => None
2445
- }
2446
- } )
2447
- }
2448
-
2449
2433
/// Construct a parameter environment suitable for static contexts or other contexts where there
2450
2434
/// are no free type/lifetime parameters in scope.
2451
2435
pub fn empty_parameter_environment ( self ) -> ParameterEnvironment < ' tcx > {
@@ -2693,13 +2677,31 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span {
2693
2677
tcx. hir . span_if_local ( def_id) . unwrap ( )
2694
2678
}
2695
2679
2680
+ /// If the given def ID describes an item belonging to a trait,
2681
+ /// return the ID of the trait that the trait item belongs to.
2682
+ /// Otherwise, return `None`.
2683
+ fn trait_of_item < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> Option < DefId > {
2684
+ if def_id. krate != LOCAL_CRATE {
2685
+ return None
2686
+ }
2687
+ tcx. opt_associated_item ( def_id)
2688
+ . and_then ( |associated_item| {
2689
+ match associated_item. container {
2690
+ TraitContainer ( def_id) => Some ( def_id) ,
2691
+ ImplContainer ( _) => None
2692
+ }
2693
+ } )
2694
+ }
2695
+
2696
+
2696
2697
pub fn provide ( providers : & mut ty:: maps:: Providers ) {
2697
2698
* providers = ty:: maps:: Providers {
2698
2699
associated_item,
2699
2700
associated_item_def_ids,
2700
2701
adt_sized_constraint,
2701
2702
adt_dtorck_constraint,
2702
2703
def_span,
2704
+ trait_of_item,
2703
2705
..* providers
2704
2706
} ;
2705
2707
}
0 commit comments