Skip to content

Commit 6842017

Browse files
committed
improve inference still problem generating alias
1 parent e668d7c commit 6842017

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lints/par_iter/src/lib.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,29 @@ fn get_all_methods<'tcx>(
190190
span: original_expr.span,
191191
});
192192

193-
let projection_ty = ty::AliasTy::new(tcx, into_iter_trait, GenericArgs::empty());
194-
let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Projection(
195-
ty::ProjectionPredicate {
196-
projection_ty,
197-
term: ty.into(),
198-
},
199-
)));
200-
ocx.register_obligation(Obligation::new(
193+
// Construct the alias type
194+
let alias_ty = ty::AliasTy::new(tcx, into_iter_trait, GenericArgs::empty());
195+
196+
let projection_predicate = ty::ProjectionPredicate {
197+
projection_ty: alias_ty,
198+
term: infcx
199+
.next_ty_var(TypeVariableOrigin {
200+
// Create a fresh type variable for the resulting type
201+
kind: TypeVariableOriginKind::TypeInference,
202+
span: original_expr.span,
203+
})
204+
.into(),
205+
};
206+
207+
let obligation = Obligation::new(
201208
tcx,
202209
ObligationCause::dummy(),
203210
param_env,
204-
projection,
205-
));
211+
ty::Binder::dummy(projection_predicate),
212+
);
213+
214+
ocx.register_obligation(obligation);
215+
206216
let errors = ocx.select_where_possible();
207217
if errors.is_empty() {
208218
dbg!("no errors"); // TODO: do something else here

0 commit comments

Comments
 (0)