1
Fork 0

Changes from review

This commit is contained in:
Kyle Matsuda 2023-04-20 12:33:32 -06:00
parent e54854f6a9
commit 5a69b5d0f9
6 changed files with 25 additions and 20 deletions

View file

@ -571,7 +571,7 @@ fn check_must_not_suspend_ty<'tcx>(
// FIXME: support adding the attribute to TAITs // FIXME: support adding the attribute to TAITs
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
let mut has_emitted = false; 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. // 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)) = if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
predicate.kind().skip_binder() predicate.kind().skip_binder()

View file

@ -23,7 +23,7 @@ use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use rustc_middle::ty::codec::TyDecoder; use rustc_middle::ty::codec::TyDecoder;
use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::GeneratorDiagnosticData; 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::opaque::MemDecoder;
use rustc_serialize::{Decodable, Decoder}; use rustc_serialize::{Decodable, Decoder};
use rustc_session::cstore::{ 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 { fn get_variant(self, kind: &DefKind, index: DefIndex, parent_did: DefId) -> ty::VariantDef {
let adt_kind = match kind { let adt_kind = match kind {
DefKind::Variant => ty::AdtKind::Enum, DefKind::Variant => ty::AdtKind::Enum,

View file

@ -203,11 +203,7 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
} }
provide! { tcx, def_id, other, cdata, provide! { tcx, def_id, other, cdata,
explicit_item_bounds => { explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
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_predicates_of => { table } explicit_predicates_of => { table }
generics_of => { table } generics_of => { table }
inferred_outlives_of => { table_defaulted_array } inferred_outlives_of => { table_defaulted_array }

View file

@ -1611,7 +1611,7 @@ impl<'tcx> TyCtxt<'tcx> {
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false }; let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
let future_trait = self.require_lang_item(LangItem::Future, None); 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 { let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
return false; return false;
}; };

View file

@ -1800,7 +1800,7 @@ fn check_must_not_suspend_ty<'tcx>(
// FIXME: support adding the attribute to TAITs // FIXME: support adding the attribute to TAITs
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
let mut has_emitted = false; 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. // 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)) = if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
predicate.kind().skip_binder() predicate.kind().skip_binder()

View file

@ -50,12 +50,11 @@ impl<'tcx> RustIrDatabase<'tcx> {
where where
ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>, ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>,
{ {
let bounds = self.interner.tcx.explicit_item_bounds(def_id); self.interner
bounds .tcx
.0 .explicit_item_bounds(def_id)
.iter() .subst_iter_copied(self.interner.tcx, &bound_vars)
.map(|(bound, _)| bounds.rebind(*bound).subst(self.interner.tcx, &bound_vars)) .filter_map(|(bound, _)| LowerInto::<Option<_>>::lower_into(bound, self.interner))
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, self.interner))
.collect() .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 explicit_item_bounds = self.interner.tcx.explicit_item_bounds(opaque_ty_id.0);
let bounds = let bounds =
explicit_item_bounds explicit_item_bounds
.0 .subst_iter_copied(self.interner.tcx, &bound_vars)
.iter()
.map(|(bound, _)| { .map(|(bound, _)| {
explicit_item_bounds.rebind(*bound).subst(self.interner.tcx, &bound_vars)
})
.map(|bound| {
bound.fold_with(&mut ReplaceOpaqueTyFolder { bound.fold_with(&mut ReplaceOpaqueTyFolder {
tcx: self.interner.tcx, tcx: self.interner.tcx,
opaque_ty_id, opaque_ty_id,