- trait_cache: RefCell<FnvHashMap<ty::PolyTraitRef<'tcx>,
- traits::Vtable<'tcx, ()>>>,
+ trait_cache: RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>>,
+}
+
+// Implement DepTrackingMapConfig for `trait_cache`
+pub struct TraitSelectionCache<'tcx> {
+ data: PhantomData<&'tcx ()>
+}
+
+impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> {
+ type Key = ty::PolyTraitRef<'tcx>;
+ type Value = traits::Vtable<'tcx, ()>;
+ fn to_dep_node(key: &ty::PolyTraitRef<'tcx>) -> DepNode {
+ ty::tls::with(|tcx| {
+ let lifted_key = tcx.lift(key).unwrap();
+ lifted_key.to_poly_trait_predicate().dep_node()
+ })
+ }