Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 1 | ||||
| -rw-r--r-- | crates/hir_ty/src/tests/method_resolution.rs | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 9b789b5fa2..507742c22a 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -348,6 +348,7 @@ pub fn def_crates( } TyKind::Str => lang_item_crate!("str_alloc", "str"), TyKind::Slice(_) => lang_item_crate!("slice_alloc", "slice"), + TyKind::Array(..) => lang_item_crate!("array"), TyKind::Raw(Mutability::Not, _) => lang_item_crate!("const_ptr"), TyKind::Raw(Mutability::Mut, _) => lang_item_crate!("mut_ptr"), TyKind::Dyn(_) => { diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 0c50227309..f8d7f2b642 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -37,6 +37,24 @@ fn infer_slice_method() { } #[test] +fn infer_array_inherent_impl() { + check_types( + r#" + #[lang = "array"] + impl<T, const N: usize> [T; N] { + fn foo(&self) -> T { + loop {} + } + } + fn test(x: &[u8; 0]) { + <[_; 0]>::foo(x); + //^^^^^^^^^^^^^^^^ u8 + } + "#, + ); +} + +#[test] fn infer_associated_method_struct() { check_infer( r#" |