internal: switch some tests to minicore

This commit is contained in:
Aleksey Kladov 2021-06-15 21:57:56 +03:00
parent 0bb1f1bc90
commit ee13e895e3
2 changed files with 32 additions and 55 deletions

View File

@ -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<T> {}
struct MutexGuard<'a, T> {}
impl<T> Mutex<T> {
fn lock(&self) -> MutexGuard<'_, T> {}
}
impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
type Target = T;
}
fn flush(&self) {
let w: &Mutex<BufWriter>;
*(w.lock());
}
"#,
struct Mutex<T> {}
struct MutexGuard<'a, T> {}
impl<T> Mutex<T> {
fn lock(&self) -> MutexGuard<'_, T> {}
}
impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
type Target = T;
}
fn flush(&self) {
let w: &Mutex<BufWriter>;
*(w.lock());
}
"#,
expect![[r#"
156..160 'self': &Mutex<T>
183..185 '{}': ()
267..271 'self': &{unknown}
273..323 '{ ...()); }': ()
283..284 'w': &Mutex<BufWriter>
309..320 '*(w.lock())': BufWriter
311..312 'w': &Mutex<BufWriter>
311..319 'w.lock()': MutexGuard<BufWriter>
123..127 'self': &Mutex<T>
150..152 '{}': ()
234..238 'self': &{unknown}
240..290 '{ ...()); }': ()
250..251 'w': &Mutex<BufWriter>
276..287 '*(w.lock())': BufWriter
278..279 'w': &Mutex<BufWriter>
278..286 'w.lock()': MutexGuard<BufWriter>
"#]],
);
}

View File

@ -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<T>;
impl<T> Deref for Arc<T> {
impl<T> core::ops::Deref for Arc<T> {
type Target = T;
}
@ -731,16 +726,10 @@ fn test(s: Arc<S>) {
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<T>;
fn new_arc<T>() -> Arc<T> {}
impl<T> Deref for Arc<T> {
impl<T> core::ops::Deref for Arc<T> {
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<T>;
impl<T> Deref for Arc<T> {
impl<T: ?Sized> core::ops::Deref for Arc<T> {
type Target = T;
}