Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-ty/src/infer/unify.rs5
-rw-r--r--crates/hir-ty/src/tests/regression/new_solver.rs28
2 files changed, 32 insertions, 1 deletions
diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs
index 0f582a1c23..59e8d84190 100644
--- a/crates/hir-ty/src/infer/unify.rs
+++ b/crates/hir-ty/src/infer/unify.rs
@@ -674,10 +674,13 @@ impl<'db> InferenceTable<'db> {
let args = [ty, arg_ty];
let trait_ref = TraitRef::new(self.interner(), fn_trait.into(), args);
+ let proj_args = self
+ .infer_ctxt
+ .fill_rest_fresh_args(output_assoc_type.into(), args.into_iter().map(Into::into));
let projection = Ty::new_alias(
self.interner(),
rustc_type_ir::AliasTyKind::Projection,
- AliasTy::new(self.interner(), output_assoc_type.into(), args),
+ AliasTy::new(self.interner(), output_assoc_type.into(), proj_args),
);
let pred = Predicate::upcast_from(trait_ref, self.interner());
diff --git a/crates/hir-ty/src/tests/regression/new_solver.rs b/crates/hir-ty/src/tests/regression/new_solver.rs
index 64c69afa29..90c81d1e8f 100644
--- a/crates/hir-ty/src/tests/regression/new_solver.rs
+++ b/crates/hir-ty/src/tests/regression/new_solver.rs
@@ -524,3 +524,31 @@ fn g(it: *const (dyn Trait)) {
"#,
);
}
+
+#[test]
+fn regression_20951() {
+ check_infer(
+ r#"
+//- minicore: async_fn
+trait DoesSomething {
+ fn do_something(&self) -> impl Future<Output = usize>;
+}
+
+impl<F> DoesSomething for F
+where
+ F: AsyncFn() -> usize,
+{
+ fn do_something(&self) -> impl Future<Output = usize> {
+ self()
+ }
+}
+"#,
+ expect![[r#"
+ 43..47 'self': &'? Self
+ 168..172 'self': &'? F
+ 205..227 '{ ... }': <F as AsyncFnMut<()>>::CallRefFuture<'<erased>>
+ 215..219 'self': &'? F
+ 215..221 'self()': <F as AsyncFnMut<()>>::CallRefFuture<'<erased>>
+ "#]],
+ );
+}