Skip to content

Commit 1853100

Browse files
committed
Use identity instantiation in opaque_has_multiple_bounds
The helper only inspects clause kinds (the trait `def_id` + polarity for `Trait`, and `TypeOutlives`), all invariant under instantiation. Switch from `iter_instantiated_copied(tcx, args)` to `iter_identity_copied()` and drop the `args` parameter.
1 parent 112b04f commit 1853100

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,13 +1105,13 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
11051105
}
11061106
match ty.kind() {
11071107
// RPITIT trait-side appears as `Projection`, not `Opaque`.
1108-
ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
1109-
self.opaque_has_multiple_bounds(*def_id, args)
1108+
ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, .. }) => {
1109+
self.opaque_has_multiple_bounds(*def_id)
11101110
}
1111-
ty::Alias(ty::AliasTy { kind: ty::Projection { def_id }, args, .. })
1111+
ty::Alias(ty::AliasTy { kind: ty::Projection { def_id }, .. })
11121112
if self.tcx().is_impl_trait_in_trait(*def_id) =>
11131113
{
1114-
self.opaque_has_multiple_bounds(*def_id, args)
1114+
self.opaque_has_multiple_bounds(*def_id)
11151115
}
11161116
ty::Dynamic(predicates, region) => {
11171117
if self.should_print_optional_region(*region) {
@@ -1143,23 +1143,22 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
11431143
/// the synthetic `Sized` / `?Sized` / `MetaSized` / `PointeeSized` suffix
11441144
/// each contribute one top-level joinable component. Regressions land in
11451145
/// `tests/ui/impl-trait/in-trait/refine-rustfix-parens.rs`.
1146-
fn opaque_has_multiple_bounds(&self, def_id: DefId, args: ty::GenericArgsRef<'tcx>) -> bool {
1146+
fn opaque_has_multiple_bounds(&self, def_id: DefId) -> bool {
11471147
let tcx = self.tcx();
11481148
let bounds = tcx.explicit_item_bounds(def_id);
11491149

11501150
// Mirror `pretty_print_opaque_impl_type`'s sized-bound handling:
11511151
// positive `Sized` and `MetaSized` are absorbed into the synthetic
11521152
// suffix below; negative `Sized` (`?Sized`) falls through and is
1153-
// printed inline.
1153+
// printed inline. Only clause *kinds* are inspected here, so the
1154+
// identity-instantiated bounds carry all the information we need.
11541155
let mut trait_emits = 0usize;
11551156
let mut lifetimes_count = 0usize;
11561157
let mut has_sized_bound = false;
11571158
let mut has_negative_sized_bound = false;
11581159
let mut has_meta_sized_bound = false;
11591160

1160-
for (predicate, _) in
1161-
bounds.iter_instantiated_copied(tcx, args).map(Unnormalized::skip_norm_wip)
1162-
{
1161+
for (predicate, _) in bounds.iter_identity_copied().map(Unnormalized::skip_norm_wip) {
11631162
match predicate.kind().skip_binder() {
11641163
ty::ClauseKind::Trait(pred) => match tcx.as_lang_item(pred.def_id()) {
11651164
Some(LangItem::Sized) => match pred.polarity {

0 commit comments

Comments
 (0)