No need to expect RPITIT projections in opaque item bounds
This commit is contained in:
parent
23776619a8
commit
44c8ab9f8b
4 changed files with 3 additions and 30 deletions
|
@ -576,7 +576,6 @@ fn find_and_apply_rpit_args<'tcx>(
|
||||||
struct Visitor<'tcx> {
|
struct Visitor<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
opaque: DefId,
|
opaque: DefId,
|
||||||
function: DefId,
|
|
||||||
seen: FxHashSet<DefId>,
|
seen: FxHashSet<DefId>,
|
||||||
}
|
}
|
||||||
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for Visitor<'tcx> {
|
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for Visitor<'tcx> {
|
||||||
|
@ -601,19 +600,6 @@ fn find_and_apply_rpit_args<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Alias(ty::Projection, alias) => {
|
|
||||||
if self.tcx.is_impl_trait_in_trait(alias.def_id)
|
|
||||||
&& self.tcx.impl_trait_in_trait_parent_fn(alias.def_id) == self.function
|
|
||||||
{
|
|
||||||
// If we're lowering to associated item, install the opaque type which is just
|
|
||||||
// the `type_of` of the trait's associated item. If we're using the old lowering
|
|
||||||
// strategy, then just reinterpret the associated type like an opaque :^)
|
|
||||||
self.tcx
|
|
||||||
.type_of(alias.def_id)
|
|
||||||
.instantiate(self.tcx, alias.args)
|
|
||||||
.visit_with(self)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ty::Alias(ty::Weak, alias) => {
|
ty::Alias(ty::Weak, alias) => {
|
||||||
self.tcx
|
self.tcx
|
||||||
.type_of(alias.def_id)
|
.type_of(alias.def_id)
|
||||||
|
@ -627,7 +613,7 @@ fn find_and_apply_rpit_args<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let ControlFlow::Break(args) =
|
if let ControlFlow::Break(args) =
|
||||||
ret.visit_with(&mut Visitor { tcx, function, opaque, seen: Default::default() })
|
ret.visit_with(&mut Visitor { tcx, opaque, seen: Default::default() })
|
||||||
{
|
{
|
||||||
trace!(?args);
|
trace!(?args);
|
||||||
trace!("expected: {hidden_ty:#?}");
|
trace!("expected: {hidden_ty:#?}");
|
||||||
|
|
|
@ -558,10 +558,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
{
|
{
|
||||||
let pred = clause.kind().rebind(match clause.kind().skip_binder() {
|
let pred = clause.kind().rebind(match clause.kind().skip_binder() {
|
||||||
ty::ClauseKind::Trait(trait_pred) => {
|
ty::ClauseKind::Trait(trait_pred) => {
|
||||||
// FIXME(rpitit): This will need to be fixed when we move to associated types
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
*trait_pred.trait_ref.self_ty().kind(),
|
*trait_pred.trait_ref.self_ty().kind(),
|
||||||
ty::Alias(_, ty::AliasTy { def_id, args: alias_args, .. })
|
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args: alias_args, .. })
|
||||||
if def_id == rpit_def_id && args == alias_args
|
if def_id == rpit_def_id && args == alias_args
|
||||||
));
|
));
|
||||||
ty::ClauseKind::Trait(trait_pred.with_self_ty(self.tcx, ty))
|
ty::ClauseKind::Trait(trait_pred.with_self_ty(self.tcx, ty))
|
||||||
|
@ -569,7 +568,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ty::ClauseKind::Projection(mut proj_pred) => {
|
ty::ClauseKind::Projection(mut proj_pred) => {
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
*proj_pred.projection_ty.self_ty().kind(),
|
*proj_pred.projection_ty.self_ty().kind(),
|
||||||
ty::Alias(_, ty::AliasTy { def_id, args: alias_args, .. })
|
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args: alias_args, .. })
|
||||||
if def_id == rpit_def_id && args == alias_args
|
if def_id == rpit_def_id && args == alias_args
|
||||||
));
|
));
|
||||||
proj_pred = proj_pred.with_self_ty(self.tcx, ty);
|
proj_pred = proj_pred.with_self_ty(self.tcx, ty);
|
||||||
|
|
|
@ -723,11 +723,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.iter_instantiated_copied(self.tcx, args)
|
.iter_instantiated_copied(self.tcx, args)
|
||||||
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
|
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
|
||||||
ty::Error(_) => return None,
|
ty::Error(_) => return None,
|
||||||
ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => self
|
|
||||||
.tcx
|
|
||||||
.explicit_item_bounds(proj.def_id)
|
|
||||||
.iter_instantiated_copied(self.tcx, proj.args)
|
|
||||||
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
|
|
||||||
_ => span_bug!(
|
_ => span_bug!(
|
||||||
self.tcx.def_span(expr_def_id),
|
self.tcx.def_span(expr_def_id),
|
||||||
"async fn generator return type not an inference variable: {ret_ty}"
|
"async fn generator return type not an inference variable: {ret_ty}"
|
||||||
|
|
|
@ -619,13 +619,6 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
{
|
{
|
||||||
hidden_ty
|
hidden_ty
|
||||||
}
|
}
|
||||||
// FIXME(RPITIT): This can go away when we move to associated types
|
|
||||||
// FIXME(inherent_associated_types): Extend this to support `ty::Inherent`, too.
|
|
||||||
ty::Alias(ty::Projection, ty::AliasTy { def_id: def_id2, args: args2, .. })
|
|
||||||
if def_id == def_id2 && args == args2 =>
|
|
||||||
{
|
|
||||||
hidden_ty
|
|
||||||
}
|
|
||||||
_ => ty,
|
_ => ty,
|
||||||
},
|
},
|
||||||
lt_op: |lt| lt,
|
lt_op: |lt| lt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue