Changes from review
This commit is contained in:
parent
e54854f6a9
commit
5a69b5d0f9
@ -571,7 +571,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
||||
// FIXME: support adding the attribute to TAITs
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
|
||||
let mut has_emitted = false;
|
||||
for (predicate, _) in fcx.tcx.explicit_item_bounds(def).subst_identity_iter_copied() {
|
||||
for &(predicate, _) in fcx.tcx.explicit_item_bounds(def).skip_binder() {
|
||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
|
||||
predicate.kind().skip_binder()
|
||||
|
@ -23,7 +23,7 @@ use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
||||
use rustc_middle::ty::codec::TyDecoder;
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||
use rustc_middle::ty::GeneratorDiagnosticData;
|
||||
use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility};
|
||||
use rustc_middle::ty::{self, ParameterizedOverTcx, Predicate, Ty, TyCtxt, Visibility};
|
||||
use rustc_serialize::opaque::MemDecoder;
|
||||
use rustc_serialize::{Decodable, Decoder};
|
||||
use rustc_session::cstore::{
|
||||
@ -857,6 +857,20 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
)
|
||||
}
|
||||
|
||||
fn get_explicit_item_bounds(
|
||||
self,
|
||||
index: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> ty::EarlyBinder<&'tcx [(Predicate<'tcx>, Span)]> {
|
||||
let lazy = self.root.tables.explicit_item_bounds.get(self, index);
|
||||
let output = if lazy.is_default() {
|
||||
&mut []
|
||||
} else {
|
||||
tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
|
||||
};
|
||||
ty::EarlyBinder(&*output)
|
||||
}
|
||||
|
||||
fn get_variant(self, kind: &DefKind, index: DefIndex, parent_did: DefId) -> ty::VariantDef {
|
||||
let adt_kind = match kind {
|
||||
DefKind::Variant => ty::AdtKind::Enum,
|
||||
|
@ -203,11 +203,7 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
|
||||
}
|
||||
|
||||
provide! { tcx, def_id, other, cdata,
|
||||
explicit_item_bounds => {
|
||||
let lazy = cdata.root.tables.explicit_item_bounds.get(cdata, def_id.index);
|
||||
let output = if lazy.is_default() { &mut [] } else { tcx.arena.alloc_from_iter(lazy.decode((cdata, tcx))) };
|
||||
ty::EarlyBinder(&*output)
|
||||
}
|
||||
explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
|
||||
explicit_predicates_of => { table }
|
||||
generics_of => { table }
|
||||
inferred_outlives_of => { table_defaulted_array }
|
||||
|
@ -1611,7 +1611,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
|
||||
let future_trait = self.require_lang_item(LangItem::Future, None);
|
||||
|
||||
self.explicit_item_bounds(def_id).subst_identity_iter_copied().any(|(predicate, _)| {
|
||||
self.explicit_item_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| {
|
||||
let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
|
||||
return false;
|
||||
};
|
||||
|
@ -1800,7 +1800,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
||||
// FIXME: support adding the attribute to TAITs
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
|
||||
let mut has_emitted = false;
|
||||
for (predicate, _) in tcx.explicit_item_bounds(def).subst_identity_iter_copied() {
|
||||
for &(predicate, _) in tcx.explicit_item_bounds(def).skip_binder() {
|
||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
|
||||
predicate.kind().skip_binder()
|
||||
|
@ -50,12 +50,11 @@ impl<'tcx> RustIrDatabase<'tcx> {
|
||||
where
|
||||
ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>,
|
||||
{
|
||||
let bounds = self.interner.tcx.explicit_item_bounds(def_id);
|
||||
bounds
|
||||
.0
|
||||
.iter()
|
||||
.map(|(bound, _)| bounds.rebind(*bound).subst(self.interner.tcx, &bound_vars))
|
||||
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, self.interner))
|
||||
self.interner
|
||||
.tcx
|
||||
.explicit_item_bounds(def_id)
|
||||
.subst_iter_copied(self.interner.tcx, &bound_vars)
|
||||
.filter_map(|(bound, _)| LowerInto::<Option<_>>::lower_into(bound, self.interner))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@ -509,12 +508,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
let explicit_item_bounds = self.interner.tcx.explicit_item_bounds(opaque_ty_id.0);
|
||||
let bounds =
|
||||
explicit_item_bounds
|
||||
.0
|
||||
.iter()
|
||||
.subst_iter_copied(self.interner.tcx, &bound_vars)
|
||||
.map(|(bound, _)| {
|
||||
explicit_item_bounds.rebind(*bound).subst(self.interner.tcx, &bound_vars)
|
||||
})
|
||||
.map(|bound| {
|
||||
bound.fold_with(&mut ReplaceOpaqueTyFolder {
|
||||
tcx: self.interner.tcx,
|
||||
opaque_ty_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user