From e5fd550dfdc7b67e22b0889983c5698439dc0bd5 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 4 Dec 2020 18:41:37 +0100 Subject: Use correct, full substs for self type in impl Without arbitrary self types, the self type could never refer to the method type parameters, so this wasn't a problem; but with arbitrary self types, it can. This fixes the crash from #6668; but it doesn't make method resolution work for these methods. --- crates/hir_ty/src/tests/method_resolution.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/hir_ty/src/tests/method_resolution.rs') diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 0f17ff151..a6a54e542 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -1087,3 +1087,22 @@ fn method_resolution_foreign_opaque_type() { "#]], ); } + +#[test] +fn method_with_allocator_box_self_type() { + check_types( + r#" +struct Slice {} +struct Box {} + +impl Slice { + pub fn into_vec(self: Box) { } +} + +fn main() { + let foo: Slice; + (foo.into_vec()); // we don't actually support arbitrary self types, but we shouldn't crash at least +} //^ {unknown} +"#, + ); +} -- cgit v1.2.3