about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/instance.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-02-05 19:17:18 +0000
committerMichael Goulet <michael@errs.io>2024-02-06 20:52:13 +0000
commit08af64e96be28c3680d6e8c96d437a560d3a9ae3 (patch)
tree14543323961dbf4252fb9db9c8644e775a7d03b6 /compiler/rustc_ty_utils/src/instance.rs
parent0dd40786b555c04afa52b9d0c789a29dbd4e3dd2 (diff)
downloadrust-08af64e96be28c3680d6e8c96d437a560d3a9ae3.tar.gz
rust-08af64e96be28c3680d6e8c96d437a560d3a9ae3.zip
Regular closures now built-in impls for AsyncFn*
Diffstat (limited to 'compiler/rustc_ty_utils/src/instance.rs')
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 9faad10dd14..bcc7c98ed69 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -306,6 +306,19 @@ fn resolve_associated_item<'tcx>(
                             Some(Instance::new(coroutine_closure_def_id, args))
                         }
                     }
+                    ty::Closure(closure_def_id, args) => {
+                        let trait_closure_kind = tcx.fn_trait_kind_from_def_id(trait_id).unwrap();
+                        Some(Instance::resolve_closure(
+                            tcx,
+                            closure_def_id,
+                            args,
+                            trait_closure_kind,
+                        ))
+                    }
+                    ty::FnDef(..) | ty::FnPtr(..) => Some(Instance {
+                        def: ty::InstanceDef::FnPtrShim(trait_item_id, rcvr_args.type_at(0)),
+                        args: rcvr_args,
+                    }),
                     _ => bug!(
                         "no built-in definition for `{trait_ref}::{}` for non-lending-closure type",
                         tcx.item_name(trait_item_id)