Skip to content

Commit 5a69b5d

Browse files
committed
Changes from review
1 parent e54854f commit 5a69b5d

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ fn check_must_not_suspend_ty<'tcx>(
571571
// FIXME: support adding the attribute to TAITs
572572
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
573573
let mut has_emitted = false;
574-
for (predicate, _) in fcx.tcx.explicit_item_bounds(def).subst_identity_iter_copied() {
574+
for &(predicate, _) in fcx.tcx.explicit_item_bounds(def).skip_binder() {
575575
// We only look at the `DefId`, so it is safe to skip the binder here.
576576
if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
577577
predicate.kind().skip_binder()

compiler/rustc_metadata/src/rmeta/decoder.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
2323
use rustc_middle::ty::codec::TyDecoder;
2424
use rustc_middle::ty::fast_reject::SimplifiedType;
2525
use rustc_middle::ty::GeneratorDiagnosticData;
26-
use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility};
26+
use rustc_middle::ty::{self, ParameterizedOverTcx, Predicate, Ty, TyCtxt, Visibility};
2727
use rustc_serialize::opaque::MemDecoder;
2828
use rustc_serialize::{Decodable, Decoder};
2929
use rustc_session::cstore::{
@@ -857,6 +857,20 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
857857
)
858858
}
859859

860+
fn get_explicit_item_bounds(
861+
self,
862+
index: DefIndex,
863+
tcx: TyCtxt<'tcx>,
864+
) -> ty::EarlyBinder<&'tcx [(Predicate<'tcx>, Span)]> {
865+
let lazy = self.root.tables.explicit_item_bounds.get(self, index);
866+
let output = if lazy.is_default() {
867+
&mut []
868+
} else {
869+
tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
870+
};
871+
ty::EarlyBinder(&*output)
872+
}
873+
860874
fn get_variant(self, kind: &DefKind, index: DefIndex, parent_did: DefId) -> ty::VariantDef {
861875
let adt_kind = match kind {
862876
DefKind::Variant => ty::AdtKind::Enum,

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,7 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
203203
}
204204

205205
provide! { tcx, def_id, other, cdata,
206-
explicit_item_bounds => {
207-
let lazy = cdata.root.tables.explicit_item_bounds.get(cdata, def_id.index);
208-
let output = if lazy.is_default() { &mut [] } else { tcx.arena.alloc_from_iter(lazy.decode((cdata, tcx))) };
209-
ty::EarlyBinder(&*output)
210-
}
206+
explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
211207
explicit_predicates_of => { table }
212208
generics_of => { table }
213209
inferred_outlives_of => { table_defaulted_array }

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ impl<'tcx> TyCtxt<'tcx> {
16111611
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
16121612
let future_trait = self.require_lang_item(LangItem::Future, None);
16131613

1614-
self.explicit_item_bounds(def_id).subst_identity_iter_copied().any(|(predicate, _)| {
1614+
self.explicit_item_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| {
16151615
let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
16161616
return false;
16171617
};

compiler/rustc_mir_transform/src/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ fn check_must_not_suspend_ty<'tcx>(
18001800
// FIXME: support adding the attribute to TAITs
18011801
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
18021802
let mut has_emitted = false;
1803-
for (predicate, _) in tcx.explicit_item_bounds(def).subst_identity_iter_copied() {
1803+
for &(predicate, _) in tcx.explicit_item_bounds(def).skip_binder() {
18041804
// We only look at the `DefId`, so it is safe to skip the binder here.
18051805
if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
18061806
predicate.kind().skip_binder()

compiler/rustc_traits/src/chalk/db.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ impl<'tcx> RustIrDatabase<'tcx> {
5050
where
5151
ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>,
5252
{
53-
let bounds = self.interner.tcx.explicit_item_bounds(def_id);
54-
bounds
55-
.0
56-
.iter()
57-
.map(|(bound, _)| bounds.rebind(*bound).subst(self.interner.tcx, &bound_vars))
58-
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, self.interner))
53+
self.interner
54+
.tcx
55+
.explicit_item_bounds(def_id)
56+
.subst_iter_copied(self.interner.tcx, &bound_vars)
57+
.filter_map(|(bound, _)| LowerInto::<Option<_>>::lower_into(bound, self.interner))
5958
.collect()
6059
}
6160
}
@@ -509,12 +508,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
509508
let explicit_item_bounds = self.interner.tcx.explicit_item_bounds(opaque_ty_id.0);
510509
let bounds =
511510
explicit_item_bounds
512-
.0
513-
.iter()
511+
.subst_iter_copied(self.interner.tcx, &bound_vars)
514512
.map(|(bound, _)| {
515-
explicit_item_bounds.rebind(*bound).subst(self.interner.tcx, &bound_vars)
516-
})
517-
.map(|bound| {
518513
bound.fold_with(&mut ReplaceOpaqueTyFolder {
519514
tcx: self.interner.tcx,
520515
opaque_ty_id,

0 commit comments

Comments
 (0)