Skip to content

Commit 44c8ab9

Browse files
No need to expect RPITIT projections in opaque item bounds
1 parent 2377661 commit 44c8ab9

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ fn find_and_apply_rpit_args<'tcx>(
576576
struct Visitor<'tcx> {
577577
tcx: TyCtxt<'tcx>,
578578
opaque: DefId,
579-
function: DefId,
580579
seen: FxHashSet<DefId>,
581580
}
582581
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for Visitor<'tcx> {
@@ -601,19 +600,6 @@ fn find_and_apply_rpit_args<'tcx>(
601600
}
602601
}
603602
}
604-
ty::Alias(ty::Projection, alias) => {
605-
if self.tcx.is_impl_trait_in_trait(alias.def_id)
606-
&& self.tcx.impl_trait_in_trait_parent_fn(alias.def_id) == self.function
607-
{
608-
// If we're lowering to associated item, install the opaque type which is just
609-
// the `type_of` of the trait's associated item. If we're using the old lowering
610-
// strategy, then just reinterpret the associated type like an opaque :^)
611-
self.tcx
612-
.type_of(alias.def_id)
613-
.instantiate(self.tcx, alias.args)
614-
.visit_with(self)?;
615-
}
616-
}
617603
ty::Alias(ty::Weak, alias) => {
618604
self.tcx
619605
.type_of(alias.def_id)
@@ -627,7 +613,7 @@ fn find_and_apply_rpit_args<'tcx>(
627613
}
628614
}
629615
if let ControlFlow::Break(args) =
630-
ret.visit_with(&mut Visitor { tcx, function, opaque, seen: Default::default() })
616+
ret.visit_with(&mut Visitor { tcx, opaque, seen: Default::default() })
631617
{
632618
trace!(?args);
633619
trace!("expected: {hidden_ty:#?}");

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,18 +558,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
558558
{
559559
let pred = clause.kind().rebind(match clause.kind().skip_binder() {
560560
ty::ClauseKind::Trait(trait_pred) => {
561-
// FIXME(rpitit): This will need to be fixed when we move to associated types
562561
assert!(matches!(
563562
*trait_pred.trait_ref.self_ty().kind(),
564-
ty::Alias(_, ty::AliasTy { def_id, args: alias_args, .. })
563+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args: alias_args, .. })
565564
if def_id == rpit_def_id && args == alias_args
566565
));
567566
ty::ClauseKind::Trait(trait_pred.with_self_ty(self.tcx, ty))
568567
}
569568
ty::ClauseKind::Projection(mut proj_pred) => {
570569
assert!(matches!(
571570
*proj_pred.projection_ty.self_ty().kind(),
572-
ty::Alias(_, ty::AliasTy { def_id, args: alias_args, .. })
571+
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args: alias_args, .. })
573572
if def_id == rpit_def_id && args == alias_args
574573
));
575574
proj_pred = proj_pred.with_self_ty(self.tcx, ty);

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
723723
.iter_instantiated_copied(self.tcx, args)
724724
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
725725
ty::Error(_) => return None,
726-
ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => self
727-
.tcx
728-
.explicit_item_bounds(proj.def_id)
729-
.iter_instantiated_copied(self.tcx, proj.args)
730-
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
731726
_ => span_bug!(
732727
self.tcx.def_span(expr_def_id),
733728
"async fn generator return type not an inference variable: {ret_ty}"

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,6 @@ impl<'tcx> InferCtxt<'tcx> {
619619
{
620620
hidden_ty
621621
}
622-
// FIXME(RPITIT): This can go away when we move to associated types
623-
// FIXME(inherent_associated_types): Extend this to support `ty::Inherent`, too.
624-
ty::Alias(ty::Projection, ty::AliasTy { def_id: def_id2, args: args2, .. })
625-
if def_id == def_id2 && args == args2 =>
626-
{
627-
hidden_ty
628-
}
629622
_ => ty,
630623
},
631624
lt_op: |lt| lt,

0 commit comments

Comments
 (0)