mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 00:53:48 +00:00
iter_identity is a better name
This commit is contained in:
parent
289deb9ed7
commit
58aad3c72c
@ -477,7 +477,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
|
||||
param_env,
|
||||
item_def_id,
|
||||
tcx.explicit_item_bounds(item_def_id)
|
||||
.instantiate_identity_iter_copied()
|
||||
.iter_identity_copied()
|
||||
.collect::<Vec<_>>(),
|
||||
&FxIndexSet::default(),
|
||||
gat_def_id,
|
||||
@ -1204,17 +1204,16 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
|
||||
let bounds = wfcx.tcx().explicit_item_bounds(item.def_id);
|
||||
|
||||
debug!("check_associated_type_bounds: bounds={:?}", bounds);
|
||||
let wf_obligations =
|
||||
bounds.instantiate_identity_iter_copied().flat_map(|(bound, bound_span)| {
|
||||
let normalized_bound = wfcx.normalize(span, None, bound);
|
||||
traits::wf::clause_obligations(
|
||||
wfcx.infcx,
|
||||
wfcx.param_env,
|
||||
wfcx.body_def_id,
|
||||
normalized_bound,
|
||||
bound_span,
|
||||
)
|
||||
});
|
||||
let wf_obligations = bounds.iter_identity_copied().flat_map(|(bound, bound_span)| {
|
||||
let normalized_bound = wfcx.normalize(span, None, bound);
|
||||
traits::wf::clause_obligations(
|
||||
wfcx.infcx,
|
||||
wfcx.param_env,
|
||||
wfcx.body_def_id,
|
||||
normalized_bound,
|
||||
bound_span,
|
||||
)
|
||||
});
|
||||
|
||||
wfcx.register_obligations(wf_obligations);
|
||||
}
|
||||
|
@ -1752,10 +1752,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||
fcx.probe(|_| {
|
||||
let ocx = ObligationCtxt::new(fcx);
|
||||
ocx.register_obligations(
|
||||
fcx.tcx
|
||||
.item_super_predicates(rpit_def_id)
|
||||
.instantiate_identity_iter()
|
||||
.filter_map(|clause| {
|
||||
fcx.tcx.item_super_predicates(rpit_def_id).iter_identity().filter_map(
|
||||
|clause| {
|
||||
let predicate = clause
|
||||
.kind()
|
||||
.map_bound(|clause| match clause {
|
||||
@ -1776,7 +1774,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||
fcx.param_env,
|
||||
predicate,
|
||||
))
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
ocx.select_where_possible().is_empty()
|
||||
})
|
||||
|
@ -76,9 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
|
||||
// For every projection predicate in the opaque type's explicit bounds,
|
||||
// check that the type that we're assigning actually satisfies the bounds
|
||||
// of the associated type.
|
||||
for (pred, pred_span) in
|
||||
cx.tcx.explicit_item_bounds(def_id).instantiate_identity_iter_copied()
|
||||
{
|
||||
for (pred, pred_span) in cx.tcx.explicit_item_bounds(def_id).iter_identity_copied() {
|
||||
infcx.enter_forall(pred.kind(), |predicate| {
|
||||
let ty::ClauseKind::Projection(proj) = predicate else {
|
||||
return;
|
||||
|
@ -298,9 +298,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||
ty::Alias(ty::Opaque | ty::Projection, ty::AliasTy { def_id: def, .. }) => {
|
||||
elaborate(
|
||||
cx.tcx,
|
||||
cx.tcx
|
||||
.explicit_item_super_predicates(def)
|
||||
.instantiate_identity_iter_copied(),
|
||||
cx.tcx.explicit_item_super_predicates(def).iter_identity_copied(),
|
||||
)
|
||||
// We only care about self bounds for the impl-trait
|
||||
.filter_only_self()
|
||||
|
@ -394,7 +394,7 @@ impl<'tcx> GenericPredicates<'tcx> {
|
||||
}
|
||||
|
||||
pub fn instantiate_own_identity(&self) -> impl Iterator<Item = (Clause<'tcx>, Span)> {
|
||||
EarlyBinder::bind(self.predicates).instantiate_identity_iter_copied()
|
||||
EarlyBinder::bind(self.predicates).iter_identity_copied()
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self, tcx))]
|
||||
|
@ -203,7 +203,7 @@ fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span
|
||||
tcx.associated_items(trait_def_id)
|
||||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Type)
|
||||
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).instantiate_identity_iter_copied())
|
||||
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).iter_identity_copied())
|
||||
.filter_map(|c| predicate_references_self(tcx, c))
|
||||
.collect()
|
||||
}
|
||||
|
@ -169,10 +169,8 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
|
||||
// Collect opaque types nested within the associated type bounds of this opaque type.
|
||||
// We use identity args here, because we already know that the opaque type uses
|
||||
// only generic parameters, and thus instantiating would not give us more information.
|
||||
for (pred, span) in self
|
||||
.tcx
|
||||
.explicit_item_bounds(alias_ty.def_id)
|
||||
.instantiate_identity_iter_copied()
|
||||
for (pred, span) in
|
||||
self.tcx.explicit_item_bounds(alias_ty.def_id).iter_identity_copied()
|
||||
{
|
||||
trace!(?pred);
|
||||
self.visit_spanned(span, pred);
|
||||
|
@ -62,7 +62,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
|
||||
}
|
||||
}
|
||||
DefKind::OpaqueTy => {
|
||||
for (pred, span) in tcx.explicit_item_bounds(item).instantiate_identity_iter_copied() {
|
||||
for (pred, span) in tcx.explicit_item_bounds(item).iter_identity_copied() {
|
||||
try_visit!(visitor.visit(span, pred));
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ where
|
||||
|
||||
/// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity),
|
||||
/// but on an iterator of `TypeFoldable` values.
|
||||
pub fn instantiate_identity_iter(self) -> Iter::IntoIter {
|
||||
pub fn iter_identity(self) -> Iter::IntoIter {
|
||||
self.value.into_iter()
|
||||
}
|
||||
}
|
||||
@ -515,9 +515,7 @@ where
|
||||
|
||||
/// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity),
|
||||
/// but on an iterator of values that deref to a `TypeFoldable`.
|
||||
pub fn instantiate_identity_iter_copied(
|
||||
self,
|
||||
) -> impl Iterator<Item = <Iter::Item as Deref>::Target> {
|
||||
pub fn iter_identity_copied(self) -> impl Iterator<Item = <Iter::Item as Deref>::Target> {
|
||||
self.value.into_iter().map(|v| *v)
|
||||
}
|
||||
}
|
||||
|
@ -1404,8 +1404,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
|
||||
|
||||
let mut predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates;
|
||||
if let ty::TraitContainer = assoc_item.container {
|
||||
let bounds =
|
||||
tcx.explicit_item_bounds(assoc_item.def_id).instantiate_identity_iter_copied();
|
||||
let bounds = tcx.explicit_item_bounds(assoc_item.def_id).iter_identity_copied();
|
||||
predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied()));
|
||||
}
|
||||
let mut generics = clean_ty_generics(
|
||||
|
@ -99,7 +99,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
||||
for (predicate, _span) in cx
|
||||
.tcx
|
||||
.explicit_item_super_predicates(def_id)
|
||||
.instantiate_identity_iter_copied()
|
||||
.iter_identity_copied()
|
||||
{
|
||||
match predicate.kind().skip_binder() {
|
||||
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
||||
|
Loading…
Reference in New Issue
Block a user