Move some TyCtxt trait methods close together

This commit is contained in:
Cameron Steffen 2025-07-24 16:08:35 -05:00
parent 9b2c9a8c5b
commit dcf76b6811
2 changed files with 13 additions and 13 deletions

View file

@ -3530,19 +3530,6 @@ impl<'tcx> TyCtxt<'tcx> {
crate::dep_graph::make_metadata(self)
}
/// Given an `impl_id`, return the trait it implements.
/// Return `None` if this is an inherent impl.
pub fn impl_trait_ref(
self,
def_id: impl IntoQueryParam<DefId>,
) -> Option<ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>> {
Some(self.impl_trait_header(def_id)?.trait_ref)
}
pub fn impl_polarity(self, def_id: impl IntoQueryParam<DefId>) -> ty::ImplPolarity {
self.impl_trait_header(def_id).map_or(ty::ImplPolarity::Positive, |h| h.polarity)
}
pub fn needs_coroutine_by_move_body_def_id(self, def_id: DefId) -> bool {
if let Some(hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure)) =
self.coroutine_kind(def_id)

View file

@ -1970,6 +1970,19 @@ impl<'tcx> TyCtxt<'tcx> {
}
}
pub fn impl_polarity(self, def_id: impl IntoQueryParam<DefId>) -> ty::ImplPolarity {
self.impl_trait_header(def_id).map_or(ty::ImplPolarity::Positive, |h| h.polarity)
}
/// Given an `impl_id`, return the trait it implements.
/// Return `None` if this is an inherent impl.
pub fn impl_trait_ref(
self,
def_id: impl IntoQueryParam<DefId>,
) -> Option<ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>> {
Some(self.impl_trait_header(def_id)?.trait_ref)
}
pub fn is_exportable(self, def_id: DefId) -> bool {
self.exportable_items(def_id.krate).contains(&def_id)
}