Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer.rs')
| -rw-r--r-- | crates/hir-ty/src/infer.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index a19ff8bf60..4b80f06a3a 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -125,6 +125,31 @@ impl Default for BindingMode { } } +/// Used to generalize patterns and assignee expressions. +trait PatLike: Into<ExprOrPatId> + Copy { + type BindingMode: Copy; + + fn infer( + this: &mut InferenceContext, + id: Self, + expected_ty: &Ty, + default_bm: Self::BindingMode, + ) -> Ty; +} + +impl PatLike for PatId { + type BindingMode = BindingMode; + + fn infer( + this: &mut InferenceContext, + id: Self, + expected_ty: &Ty, + default_bm: Self::BindingMode, + ) -> Ty { + this.infer_pat(id, expected_ty, default_bm) + } +} + #[derive(Debug)] pub(crate) struct InferOk<T> { value: T, |