Skip to content

Commit

Permalink
Rollup merge of #93362 - compiler-errors:ice-gat-in-rpit, r=oli-obk
Browse files Browse the repository at this point in the history
Do not register infer var for GAT projection in RPIT

Fixes #93340
Fixes #91603

r? ```@oli-obk```
  • Loading branch information
matthiaskrgr committed Jan 29, 2022
2 parents 103c3a3 + c6f6e3e commit 4484165
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
16 changes: 9 additions & 7 deletions compiler/rustc_infer/src/infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,15 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
let predicate = predicate.fold_with(&mut BottomUpFolder {
tcx,
ty_op: |ty| match ty.kind() {
ty::Projection(projection_ty) => infcx.infer_projection(
self.param_env,
*projection_ty,
traits::ObligationCause::misc(self.value_span, self.body_id),
0,
&mut self.obligations,
),
ty::Projection(projection_ty) if !projection_ty.has_escaping_bound_vars() => {
infcx.infer_projection(
self.param_env,
*projection_ty,
traits::ObligationCause::misc(self.value_span, self.body_id),
0,
&mut self.obligations,
)
}
_ => ty,
},
lt_op: |lt| lt,
Expand Down
20 changes: 20 additions & 0 deletions src/test/ui/generic-associated-types/issue-93340.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// check-pass

#![feature(generic_associated_types)]

pub trait Scalar: 'static {
type RefType<'a>: ScalarRef<'a>;
}

pub trait ScalarRef<'a>: 'a {}

fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefType<'b>) -> O {
todo!()
}

fn build_expression<A: Scalar, B: Scalar, O: Scalar>(
) -> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O {
cmp_eq
}

fn main() {}

0 comments on commit 4484165

Please sign in to comment.