From e313efb9926be80a5d7614d800e425b6891cf7d9 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 29 Feb 2020 22:01:36 +0100 Subject: Do array unsizing for method receivers It turns out rustc actually only unsizes array method receivers, so we don't need to do any trait solving for this (at least for now). Fixes #2670. --- crates/ra_hir_ty/src/tests/method_resolution.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crates/ra_hir_ty/src/tests/method_resolution.rs') diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/ra_hir_ty/src/tests/method_resolution.rs index 644d59e17..f9b394f05 100644 --- a/crates/ra_hir_ty/src/tests/method_resolution.rs +++ b/crates/ra_hir_ty/src/tests/method_resolution.rs @@ -838,6 +838,24 @@ fn test() { (&S).foo()<|>; } assert_eq!(t, "u128"); } +#[test] +fn method_resolution_unsize_array() { + let t = type_at( + r#" +//- /main.rs +#[lang = "slice"] +impl [T] { + fn len(&self) -> usize { loop {} } +} +fn test() { + let a = [1, 2, 3]; + a.len()<|>; +} +"#, + ); + assert_eq!(t, "usize"); +} + #[test] fn method_resolution_trait_from_prelude() { let (db, pos) = TestDB::with_position( -- cgit v1.2.3