make impl_subject more readable

This commit is contained in:
Kyle Matsuda 2023-04-13 16:43:34 -06:00
parent e2f5a5a71f
commit 8d5ee1a072

View File

@ -105,12 +105,10 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn impl_subject(self, def_id: DefId) -> EarlyBinder<ImplSubject<'tcx>> {
EarlyBinder(
self.impl_trait_ref(def_id)
.map(|t| t.subst_identity())
.map(ImplSubject::Trait)
.unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id).subst_identity())),
)
match self.impl_trait_ref(def_id) {
Some(t) => t.map_bound(ImplSubject::Trait),
None => self.type_of(def_id).map_bound(ImplSubject::Inherent),
}
}
}