diff options
author | Aleksey Kladov <[email protected]> | 2021-06-15 19:02:40 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-15 19:03:08 +0100 |
commit | f521e4185323699cd5d063b2704367a319583982 (patch) | |
tree | 249c358780bebe049e01f0003caf8e15eb3c4a26 /crates/hir_ty | |
parent | 3f5eead9e3b32f7e88562337c95f76ea75c82486 (diff) |
internal: introduce minicore -- a subset of libcore for testing
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/tests/coercion.rs | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs index 4f859fc85..91236e974 100644 --- a/crates/hir_ty/src/tests/coercion.rs +++ b/crates/hir_ty/src/tests/coercion.rs | |||
@@ -23,38 +23,29 @@ fn infer_block_expr_type_mismatch() { | |||
23 | fn coerce_places() { | 23 | fn coerce_places() { |
24 | check_infer( | 24 | check_infer( |
25 | r#" | 25 | r#" |
26 | struct S<T> { a: T } | 26 | //- minicore: coerce_unsized |
27 | struct S<T> { a: T } | ||
27 | 28 | ||
28 | fn f<T>(_: &[T]) -> T { loop {} } | 29 | fn f<T>(_: &[T]) -> T { loop {} } |
29 | fn g<T>(_: S<&[T]>) -> T { loop {} } | 30 | fn g<T>(_: S<&[T]>) -> T { loop {} } |
30 | 31 | ||
31 | fn gen<T>() -> *mut [T; 2] { loop {} } | 32 | fn gen<T>() -> *mut [T; 2] { loop {} } |
32 | fn test1<U>() -> *mut [U] { | 33 | fn test1<U>() -> *mut [U] { |
33 | gen() | 34 | gen() |
34 | } | 35 | } |
35 | |||
36 | fn test2() { | ||
37 | let arr: &[u8; 1] = &[1]; | ||
38 | 36 | ||
39 | let a: &[_] = arr; | 37 | fn test2() { |
40 | let b = f(arr); | 38 | let arr: &[u8; 1] = &[1]; |
41 | let c: &[_] = { arr }; | ||
42 | let d = g(S { a: arr }); | ||
43 | let e: [&[_]; 1] = [arr]; | ||
44 | let f: [&[_]; 2] = [arr; 2]; | ||
45 | let g: (&[_], &[_]) = (arr, arr); | ||
46 | } | ||
47 | 39 | ||
48 | #[lang = "sized"] | 40 | let a: &[_] = arr; |
49 | pub trait Sized {} | 41 | let b = f(arr); |
50 | #[lang = "unsize"] | 42 | let c: &[_] = { arr }; |
51 | pub trait Unsize<T: ?Sized> {} | 43 | let d = g(S { a: arr }); |
52 | #[lang = "coerce_unsized"] | 44 | let e: [&[_]; 1] = [arr]; |
53 | pub trait CoerceUnsized<T> {} | 45 | let f: [&[_]; 2] = [arr; 2]; |
54 | 46 | let g: (&[_], &[_]) = (arr, arr); | |
55 | impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} | 47 | } |
56 | impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} | 48 | "#, |
57 | "#, | ||
58 | expect![[r#" | 49 | expect![[r#" |
59 | 30..31 '_': &[T] | 50 | 30..31 '_': &[T] |
60 | 44..55 '{ loop {} }': T | 51 | 44..55 '{ loop {} }': T |