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.
This commit is contained in:
Florian Diebold 2020-12-04 18:41:37 +01:00
parent 6943b53023
commit e5fd550dfd
2 changed files with 26 additions and 1 deletions

View file

@ -1087,3 +1087,22 @@ fn method_resolution_foreign_opaque_type() {
"#]],
);
}
#[test]
fn method_with_allocator_box_self_type() {
check_types(
r#"
struct Slice<T> {}
struct Box<T, A> {}
impl<T> Slice<T> {
pub fn into_vec<A>(self: Box<Self, A>) { }
}
fn main() {
let foo: Slice<u32>;
(foo.into_vec()); // we don't actually support arbitrary self types, but we shouldn't crash at least
} //^ {unknown}
"#,
);
}