Rollup merge of #93362 - compiler-errors:ice-gat-in-rpit, r=oli-obk

Do not register infer var for GAT projection in RPIT

Fixes #93340
Fixes #91603

r? ```@oli-obk```
This commit is contained in:
Matthias Krüger 2022-01-30 00:04:12 +01:00 committed by GitHub
commit 4484165cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 7 deletions

View File

@ -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,

View File

@ -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() {}