}
}
- /// If the given def ID describes an item belonging to a trait,
- /// return the ID of the trait that the trait item belongs to.
- /// Otherwise, return `None`.
- pub fn trait_of_item(self, def_id: DefId) -> Option<DefId> {
- if def_id.krate != LOCAL_CRATE {
- return self.sess.cstore.trait_of_item(def_id);
- }
- self.opt_associated_item(def_id)
- .and_then(|associated_item| {
- match associated_item.container {
- TraitContainer(def_id) => Some(def_id),
- ImplContainer(_) => None
- }
- })
- }
-
/// Construct a parameter environment suitable for static contexts or other contexts where there
/// are no free type/lifetime parameters in scope.
pub fn empty_parameter_environment(self) -> ParameterEnvironment<'tcx> {
tcx.hir.span_if_local(def_id).unwrap()
}
+/// If the given def ID describes an item belonging to a trait,
+/// return the ID of the trait that the trait item belongs to.
+/// Otherwise, return `None`.
+fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> {
+ if def_id.krate != LOCAL_CRATE {
+ return None
+ }
+ tcx.opt_associated_item(def_id)
+ .and_then(|associated_item| {
+ match associated_item.container {
+ TraitContainer(def_id) => Some(def_id),
+ ImplContainer(_) => None
+ }
+ })
+}
+
+
pub fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
associated_item,
adt_sized_constraint,
adt_dtorck_constraint,
def_span,
+ trait_of_item,
..*providers
};
}