diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 9b789b5fa2f..507742c22a9 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 0c502273099..f8d7f2b642b 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -36,6 +36,24 @@ fn infer_slice_method() { ); } +#[test] +fn infer_array_inherent_impl() { + check_types( + r#" + #[lang = "array"] + impl [T; N] { + fn foo(&self) -> T { + loop {} + } + } + fn test(x: &[u8; 0]) { + <[_; 0]>::foo(x); + //^^^^^^^^^^^^^^^^ u8 + } + "#, + ); +} + #[test] fn infer_associated_method_struct() { check_infer(