fix: Fix panicking while resolving callable sigs for `AsyncFnMut`
diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs
index 0f582a1..59e8d84 100644
--- a/crates/hir-ty/src/infer/unify.rs
+++ b/crates/hir-ty/src/infer/unify.rs
@@ -674,10 +674,13 @@
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 64c69af..90c81d1 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 @@
"#,
);
}
+
+#[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>>
+ "#]],
+ );
+}