From 2cdd1ff1b50b7c71e9f8aaf03a58501a4af97dce Mon Sep 17 00:00:00 2001 From: cynecx Date: Sun, 28 Feb 2021 21:15:26 +0100 Subject: hir_ty: use default type generic for box expressions --- crates/hir_ty/src/tests/simple.rs | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'crates/hir_ty/src/tests') diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 12ec4657b..2947857a5 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs @@ -2491,3 +2491,58 @@ fn inner_use_enum_rename() { "#]], ) } + +#[test] +fn box_into_vec() { + check_infer( + r#" +#[lang = "sized"] +pub trait Sized {} + +#[lang = "unsize"] +pub trait Unsize {} + +#[lang = "coerce_unsized"] +pub trait CoerceUnsized {} + +pub unsafe trait Allocator {} + +pub struct Global; +unsafe impl Allocator for Global {} + +#[lang = "owned_box"] +#[fundamental] +pub struct Box; + +impl, U: ?Sized, A: Allocator> CoerceUnsized> for Box {} + +pub struct Vec {} + +#[lang = "slice"] +impl [T] {} + +#[lang = "slice_alloc"] +impl [T] { + pub fn into_vec(self: Box) -> Vec { + unimplemented!() + } +} + +fn test() { + let vec = <[_]>::into_vec(box [1i32]); +} +"#, + expect![[r#" + 569..573 'self': Box<[T], A> + 602..634 '{ ... }': Vec + 612..628 'unimpl...ted!()': Vec + 648..694 '{ ...2]); }': () + 658..661 'vec': Vec + 664..679 '<[_]>::into_vec': fn into_vec(Box<[i32], Global>) -> Vec + 664..691 '<[_]>:...1i32])': Vec + 680..690 'box [1i32]': Box<[i32; _], Global> + 684..690 '[1i32]': [i32; _] + 685..689 '1i32': i32 + "#]], + ) +} -- cgit v1.2.3