From ee13e895e337d01ea283a94b7896fddc0a922cb8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jun 2021 21:57:56 +0300 Subject: internal: switch some tests to minicore --- crates/hir_ty/src/tests/regression.rs | 50 +++++++++++++++++------------------ crates/hir_ty/src/tests/traits.rs | 37 ++++++-------------------- 2 files changed, 32 insertions(+), 55 deletions(-) (limited to 'crates') diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 1019e783b..1e0233b55 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -927,35 +927,33 @@ fn issue_6628() { fn issue_6852() { check_infer( r#" - #[lang = "deref"] - pub trait Deref { - type Target; - } +//- minicore: deref +use core::ops::Deref; - struct BufWriter {} +struct BufWriter {} - struct Mutex {} - struct MutexGuard<'a, T> {} - impl Mutex { - fn lock(&self) -> MutexGuard<'_, T> {} - } - impl<'a, T: 'a> Deref for MutexGuard<'a, T> { - type Target = T; - } - fn flush(&self) { - let w: &Mutex; - *(w.lock()); - } - "#, +struct Mutex {} +struct MutexGuard<'a, T> {} +impl Mutex { + fn lock(&self) -> MutexGuard<'_, T> {} +} +impl<'a, T: 'a> Deref for MutexGuard<'a, T> { + type Target = T; +} +fn flush(&self) { + let w: &Mutex; + *(w.lock()); +} +"#, expect![[r#" - 156..160 'self': &Mutex - 183..185 '{}': () - 267..271 'self': &{unknown} - 273..323 '{ ...()); }': () - 283..284 'w': &Mutex - 309..320 '*(w.lock())': BufWriter - 311..312 'w': &Mutex - 311..319 'w.lock()': MutexGuard + 123..127 'self': &Mutex + 150..152 '{}': () + 234..238 'self': &{unknown} + 240..290 '{ ...()); }': () + 250..251 'w': &Mutex + 276..287 '*(w.lock())': BufWriter + 278..279 'w': &Mutex + 278..286 'w.lock()': MutexGuard "#]], ); } diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index c830e576e..d237c3998 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -704,14 +704,9 @@ mod ops { fn deref_trait() { check_types( r#" -#[lang = "deref"] -trait Deref { - type Target; - fn deref(&self) -> &Self::Target; -} - +//- minicore: deref struct Arc; -impl Deref for Arc { +impl core::ops::Deref for Arc { type Target = T; } @@ -731,16 +726,10 @@ fn test(s: Arc) { fn deref_trait_with_inference_var() { check_types( r#" -//- /main.rs -#[lang = "deref"] -trait Deref { - type Target; - fn deref(&self) -> &Self::Target; -} - +//- minicore: deref struct Arc; fn new_arc() -> Arc {} -impl Deref for Arc { +impl core::ops::Deref for Arc { type Target = T; } @@ -761,15 +750,10 @@ fn test() { fn deref_trait_infinite_recursion() { check_types( r#" -#[lang = "deref"] -trait Deref { - type Target; - fn deref(&self) -> &Self::Target; -} - +//- minicore: deref struct S; -impl Deref for S { +impl core::ops::Deref for S { type Target = S; } @@ -784,14 +768,9 @@ fn test(s: S) { fn deref_trait_with_question_mark_size() { check_types( r#" -#[lang = "deref"] -trait Deref { - type Target; - fn deref(&self) -> &Self::Target; -} - +//- minicore: deref struct Arc; -impl Deref for Arc { +impl core::ops::Deref for Arc { type Target = T; } -- cgit v1.2.3