mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-27 16:07:46 +00:00
Merge pull request #20971 from ShoyuVanilla/async-fn-sig
fix: Fix panicking while resolving callable sigs for `AsyncFnMut`
This commit is contained in:
commit
5ffe3f45ce
@ -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());
|
||||
|
||||
@ -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>>
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user