From f521e4185323699cd5d063b2704367a319583982 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jun 2021 21:02:40 +0300 Subject: internal: introduce minicore -- a subset of libcore for testing --- crates/hir_ty/src/tests/coercion.rs | 47 +++++++++++++++---------------------- 1 file changed, 19 insertions(+), 28 deletions(-) (limited to 'crates/hir_ty/src') 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() { fn coerce_places() { check_infer( r#" - struct S { a: T } +//- minicore: coerce_unsized +struct S { a: T } - fn f(_: &[T]) -> T { loop {} } - fn g(_: S<&[T]>) -> T { loop {} } +fn f(_: &[T]) -> T { loop {} } +fn g(_: S<&[T]>) -> T { loop {} } - fn gen() -> *mut [T; 2] { loop {} } - fn test1() -> *mut [U] { - gen() - } - - fn test2() { - let arr: &[u8; 1] = &[1]; +fn gen() -> *mut [T; 2] { loop {} } +fn test1() -> *mut [U] { + gen() +} - let a: &[_] = arr; - let b = f(arr); - let c: &[_] = { arr }; - let d = g(S { a: arr }); - let e: [&[_]; 1] = [arr]; - let f: [&[_]; 2] = [arr; 2]; - let g: (&[_], &[_]) = (arr, arr); - } +fn test2() { + let arr: &[u8; 1] = &[1]; - #[lang = "sized"] - pub trait Sized {} - #[lang = "unsize"] - pub trait Unsize {} - #[lang = "coerce_unsized"] - pub trait CoerceUnsized {} - - impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} - impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} - "#, + let a: &[_] = arr; + let b = f(arr); + let c: &[_] = { arr }; + let d = g(S { a: arr }); + let e: [&[_]; 1] = [arr]; + let f: [&[_]; 2] = [arr; 2]; + let g: (&[_], &[_]) = (arr, arr); +} +"#, expect![[r#" 30..31 '_': &[T] 44..55 '{ loop {} }': T -- cgit v1.2.3