Skip to content

Commit 58aad3c

Browse files
iter_identity is a better name
1 parent 289deb9 commit 58aad3c

File tree

11 files changed

+26
-37
lines changed

11 files changed

+26
-37
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
477477
param_env,
478478
item_def_id,
479479
tcx.explicit_item_bounds(item_def_id)
480-
.instantiate_identity_iter_copied()
480+
.iter_identity_copied()
481481
.collect::<Vec<_>>(),
482482
&FxIndexSet::default(),
483483
gat_def_id,
@@ -1204,17 +1204,16 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
12041204
let bounds = wfcx.tcx().explicit_item_bounds(item.def_id);
12051205

12061206
debug!("check_associated_type_bounds: bounds={:?}", bounds);
1207-
let wf_obligations =
1208-
bounds.instantiate_identity_iter_copied().flat_map(|(bound, bound_span)| {
1209-
let normalized_bound = wfcx.normalize(span, None, bound);
1210-
traits::wf::clause_obligations(
1211-
wfcx.infcx,
1212-
wfcx.param_env,
1213-
wfcx.body_def_id,
1214-
normalized_bound,
1215-
bound_span,
1216-
)
1217-
});
1207+
let wf_obligations = bounds.iter_identity_copied().flat_map(|(bound, bound_span)| {
1208+
let normalized_bound = wfcx.normalize(span, None, bound);
1209+
traits::wf::clause_obligations(
1210+
wfcx.infcx,
1211+
wfcx.param_env,
1212+
wfcx.body_def_id,
1213+
normalized_bound,
1214+
bound_span,
1215+
)
1216+
});
12181217

12191218
wfcx.register_obligations(wf_obligations);
12201219
}

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,10 +1752,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17521752
fcx.probe(|_| {
17531753
let ocx = ObligationCtxt::new(fcx);
17541754
ocx.register_obligations(
1755-
fcx.tcx
1756-
.item_super_predicates(rpit_def_id)
1757-
.instantiate_identity_iter()
1758-
.filter_map(|clause| {
1755+
fcx.tcx.item_super_predicates(rpit_def_id).iter_identity().filter_map(
1756+
|clause| {
17591757
let predicate = clause
17601758
.kind()
17611759
.map_bound(|clause| match clause {
@@ -1776,7 +1774,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17761774
fcx.param_env,
17771775
predicate,
17781776
))
1779-
}),
1777+
},
1778+
),
17801779
);
17811780
ocx.select_where_possible().is_empty()
17821781
})

compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
7676
// For every projection predicate in the opaque type's explicit bounds,
7777
// check that the type that we're assigning actually satisfies the bounds
7878
// of the associated type.
79-
for (pred, pred_span) in
80-
cx.tcx.explicit_item_bounds(def_id).instantiate_identity_iter_copied()
81-
{
79+
for (pred, pred_span) in cx.tcx.explicit_item_bounds(def_id).iter_identity_copied() {
8280
infcx.enter_forall(pred.kind(), |predicate| {
8381
let ty::ClauseKind::Projection(proj) = predicate else {
8482
return;

compiler/rustc_lint/src/unused.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
298298
ty::Alias(ty::Opaque | ty::Projection, ty::AliasTy { def_id: def, .. }) => {
299299
elaborate(
300300
cx.tcx,
301-
cx.tcx
302-
.explicit_item_super_predicates(def)
303-
.instantiate_identity_iter_copied(),
301+
cx.tcx.explicit_item_super_predicates(def).iter_identity_copied(),
304302
)
305303
// We only care about self bounds for the impl-trait
306304
.filter_only_self()

compiler/rustc_middle/src/ty/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ impl<'tcx> GenericPredicates<'tcx> {
394394
}
395395

396396
pub fn instantiate_own_identity(&self) -> impl Iterator<Item = (Clause<'tcx>, Span)> {
397-
EarlyBinder::bind(self.predicates).instantiate_identity_iter_copied()
397+
EarlyBinder::bind(self.predicates).iter_identity_copied()
398398
}
399399

400400
#[instrument(level = "debug", skip(self, tcx))]

compiler/rustc_trait_selection/src/traits/object_safety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span
203203
tcx.associated_items(trait_def_id)
204204
.in_definition_order()
205205
.filter(|item| item.kind == ty::AssocKind::Type)
206-
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).instantiate_identity_iter_copied())
206+
.flat_map(|item| tcx.explicit_item_bounds(item.def_id).iter_identity_copied())
207207
.filter_map(|c| predicate_references_self(tcx, c))
208208
.collect()
209209
}

compiler/rustc_ty_utils/src/opaque_types.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
169169
// Collect opaque types nested within the associated type bounds of this opaque type.
170170
// We use identity args here, because we already know that the opaque type uses
171171
// only generic parameters, and thus instantiating would not give us more information.
172-
for (pred, span) in self
173-
.tcx
174-
.explicit_item_bounds(alias_ty.def_id)
175-
.instantiate_identity_iter_copied()
172+
for (pred, span) in
173+
self.tcx.explicit_item_bounds(alias_ty.def_id).iter_identity_copied()
176174
{
177175
trace!(?pred);
178176
self.visit_spanned(span, pred);

compiler/rustc_ty_utils/src/sig_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
6262
}
6363
}
6464
DefKind::OpaqueTy => {
65-
for (pred, span) in tcx.explicit_item_bounds(item).instantiate_identity_iter_copied() {
65+
for (pred, span) in tcx.explicit_item_bounds(item).iter_identity_copied() {
6666
try_visit!(visitor.visit(span, pred));
6767
}
6868
}

compiler/rustc_type_ir/src/binder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ where
448448

449449
/// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity),
450450
/// but on an iterator of `TypeFoldable` values.
451-
pub fn instantiate_identity_iter(self) -> Iter::IntoIter {
451+
pub fn iter_identity(self) -> Iter::IntoIter {
452452
self.value.into_iter()
453453
}
454454
}
@@ -515,9 +515,7 @@ where
515515

516516
/// Similar to [`instantiate_identity`](EarlyBinder::instantiate_identity),
517517
/// but on an iterator of values that deref to a `TypeFoldable`.
518-
pub fn instantiate_identity_iter_copied(
519-
self,
520-
) -> impl Iterator<Item = <Iter::Item as Deref>::Target> {
518+
pub fn iter_identity_copied(self) -> impl Iterator<Item = <Iter::Item as Deref>::Target> {
521519
self.value.into_iter().map(|v| *v)
522520
}
523521
}

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
14041404

14051405
let mut predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates;
14061406
if let ty::TraitContainer = assoc_item.container {
1407-
let bounds =
1408-
tcx.explicit_item_bounds(assoc_item.def_id).instantiate_identity_iter_copied();
1407+
let bounds = tcx.explicit_item_bounds(assoc_item.def_id).iter_identity_copied();
14091408
predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied()));
14101409
}
14111410
let mut generics = clean_ty_generics(

src/tools/clippy/clippy_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
9999
for (predicate, _span) in cx
100100
.tcx
101101
.explicit_item_super_predicates(def_id)
102-
.instantiate_identity_iter_copied()
102+
.iter_identity_copied()
103103
{
104104
match predicate.kind().skip_binder() {
105105
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through

0 commit comments

Comments
 (0)