change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata

This commit is contained in:
Kyle Matsuda
2023-01-10 14:57:22 -07:00
parent be130b57d4
commit f29a334c90
59 changed files with 108 additions and 127 deletions

View File

@@ -101,7 +101,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn impl_subject(self, def_id: DefId) -> ImplSubject<'tcx> {
self.bound_impl_trait_ref(def_id)
self.impl_trait_ref(def_id)
.map(|t| t.subst_identity())
.map(ImplSubject::Trait)
.unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id)))

View File

@@ -737,7 +737,7 @@ rustc_queries! {
/// Given an `impl_id`, return the trait it implements.
/// Return `None` if this is an inherent impl.
query impl_trait_ref(impl_id: DefId) -> Option<ty::TraitRef<'tcx>> {
query impl_trait_ref(impl_id: DefId) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
cache_on_disk_if { impl_id.is_local() }
separate_provide_extern

View File

@@ -1027,7 +1027,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Checks if the bound region is in Impl Item.
pub fn is_bound_region_in_impl_item(self, suitable_region_binding_scope: LocalDefId) -> bool {
let container_id = self.parent(suitable_region_binding_scope.to_def_id());
if self.bound_impl_trait_ref(container_id).is_some() {
if self.impl_trait_ref(container_id).is_some() {
// For now, we do not try to target impls of traits. This is
// because this message is going to suggest that the user
// change the fn signature, but they may not be free to do so,

View File

@@ -2187,12 +2187,8 @@ impl<'tcx> TyCtxt<'tcx> {
) -> Option<ImplOverlapKind> {
// If either trait impl references an error, they're allowed to overlap,
// as one of them essentially doesn't exist.
if self
.bound_impl_trait_ref(def_id1)
.map_or(false, |tr| tr.skip_binder().references_error())
|| self
.bound_impl_trait_ref(def_id2)
.map_or(false, |tr| tr.skip_binder().references_error())
if self.impl_trait_ref(def_id1).map_or(false, |tr| tr.skip_binder().references_error())
|| self.impl_trait_ref(def_id2).map_or(false, |tr| tr.skip_binder().references_error())
{
return Some(ImplOverlapKind::Permitted { marker: false });
}
@@ -2221,7 +2217,7 @@ impl<'tcx> TyCtxt<'tcx> {
let is_marker_overlap = {
let is_marker_impl = |def_id: DefId| -> bool {
let trait_ref = self.bound_impl_trait_ref(def_id);
let trait_ref = self.impl_trait_ref(def_id);
trait_ref.map_or(false, |tr| self.trait_def(tr.skip_binder().def_id).is_marker)
};
is_marker_impl(def_id1) && is_marker_impl(def_id2)
@@ -2368,7 +2364,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
/// If it implements no trait, returns `None`.
pub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId> {
self.bound_impl_trait_ref(def_id).map(|tr| tr.skip_binder().def_id)
self.impl_trait_ref(def_id).map(|tr| tr.skip_binder().def_id)
}
/// If the given `DefId` describes an item belonging to a trait,

View File

@@ -116,7 +116,7 @@ pub trait Printer<'tcx>: Sized {
DefPathData::Impl => {
let generics = self.tcx().generics_of(def_id);
let self_ty = self.tcx().bound_type_of(def_id);
let impl_trait_ref = self.tcx().bound_impl_trait_ref(def_id);
let impl_trait_ref = self.tcx().impl_trait_ref(def_id);
let (self_ty, impl_trait_ref) = if substs.len() >= generics.count() {
(
self_ty.subst(self.tcx(), substs),

View File

@@ -652,13 +652,6 @@ impl<'tcx> TyCtxt<'tcx> {
ty::EarlyBinder(self.fn_sig(def_id))
}
pub fn bound_impl_trait_ref(
self,
def_id: DefId,
) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
self.impl_trait_ref(def_id).map(|i| ty::EarlyBinder(i))
}
pub fn bound_explicit_item_bounds(
self,
def_id: DefId,