aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/simple.rs')
-rw-r--r--crates/hir_ty/src/tests/simple.rs58
1 files changed, 56 insertions, 2 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index 12ec4657b..f5069eba5 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -1,5 +1,4 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark;
3 2
4use super::{check_infer, check_types}; 3use super::{check_infer, check_types};
5 4
@@ -2314,7 +2313,7 @@ fn generic_default_depending_on_other_type_arg_forward() {
2314 2313
2315#[test] 2314#[test]
2316fn infer_operator_overload() { 2315fn infer_operator_overload() {
2317 mark::check!(infer_expr_inner_binary_operator_overload); 2316 cov_mark::check!(infer_expr_inner_binary_operator_overload);
2318 2317
2319 check_infer( 2318 check_infer(
2320 r#" 2319 r#"
@@ -2491,3 +2490,58 @@ fn inner_use_enum_rename() {
2491 "#]], 2490 "#]],
2492 ) 2491 )
2493} 2492}
2493
2494#[test]
2495fn box_into_vec() {
2496 check_infer(
2497 r#"
2498#[lang = "sized"]
2499pub trait Sized {}
2500
2501#[lang = "unsize"]
2502pub trait Unsize<T: ?Sized> {}
2503
2504#[lang = "coerce_unsized"]
2505pub trait CoerceUnsized<T> {}
2506
2507pub unsafe trait Allocator {}
2508
2509pub struct Global;
2510unsafe impl Allocator for Global {}
2511
2512#[lang = "owned_box"]
2513#[fundamental]
2514pub struct Box<T: ?Sized, A: Allocator = Global>;
2515
2516impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
2517
2518pub struct Vec<T, A: Allocator = Global> {}
2519
2520#[lang = "slice"]
2521impl<T> [T] {}
2522
2523#[lang = "slice_alloc"]
2524impl<T> [T] {
2525 pub fn into_vec<A: Allocator>(self: Box<Self, A>) -> Vec<T, A> {
2526 unimplemented!()
2527 }
2528}
2529
2530fn test() {
2531 let vec = <[_]>::into_vec(box [1i32]);
2532}
2533"#,
2534 expect![[r#"
2535 569..573 'self': Box<[T], A>
2536 602..634 '{ ... }': Vec<T, A>
2537 612..628 'unimpl...ted!()': Vec<T, A>
2538 648..694 '{ ...2]); }': ()
2539 658..661 'vec': Vec<i32, Global>
2540 664..679 '<[_]>::into_vec': fn into_vec<i32, Global>(Box<[i32], Global>) -> Vec<i32, Global>
2541 664..691 '<[_]>:...1i32])': Vec<i32, Global>
2542 680..690 'box [1i32]': Box<[i32; _], Global>
2543 684..690 '[1i32]': [i32; _]
2544 685..689 '1i32': i32
2545 "#]],
2546 )
2547}