From b737b894cb8974361881d98d7d0a6f75839ca345 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jun 2021 21:36:50 +0300 Subject: internal: switch some tests to minicore --- crates/hir_ty/src/tests/method_resolution.rs | 55 +++++----- crates/hir_ty/src/tests/simple.rs | 158 +++++++++++++-------------- 2 files changed, 102 insertions(+), 111 deletions(-) (limited to 'crates') diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 79108054c..d9b5ee9cf 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -1222,11 +1222,7 @@ fn autoderef_visibility_method() { cov_mark::check!(autoderef_candidate_not_visible); check_infer( r#" -#[lang = "deref"] -pub trait Deref { - type Target; - fn deref(&self) -> &Self::Target; -} +//- minicore: deref mod a { pub struct Foo(pub char); impl Foo { @@ -1243,7 +1239,7 @@ mod a { self.0 } } - impl super::Deref for Bar { + impl core::ops::Deref for Bar { type Target = Foo; fn deref(&self) -> &Foo { &Foo('z') @@ -1257,30 +1253,29 @@ mod b { } "#, expect![[r#" - 67..71 'self': &Self - 168..172 'self': &Foo - 182..212 '{ ... }': char - 196..200 'self': &Foo - 196..202 'self.0': char - 288..319 '{ ... }': Bar - 302..306 'Self': Bar(i32) -> Bar - 302..309 'Self(0)': Bar - 307..308 '0': i32 - 338..342 'self': &Bar - 351..381 '{ ... }': i32 - 365..369 'self': &Bar - 365..371 'self.0': i32 - 465..469 'self': &Bar - 479..512 '{ ... }': &Foo - 493..502 '&Foo('z')': &Foo - 494..497 'Foo': Foo(char) -> Foo - 494..502 'Foo('z')': Foo - 498..501 ''z'': char - 542..595 '{ ... }': () - 556..557 'x': char - 560..578 'super:...r::new': fn new() -> Bar - 560..580 'super:...:new()': Bar - 560..588 'super:...ango()': char + 75..79 'self': &Foo + 89..119 '{ ... }': char + 103..107 'self': &Foo + 103..109 'self.0': char + 195..226 '{ ... }': Bar + 209..213 'Self': Bar(i32) -> Bar + 209..216 'Self(0)': Bar + 214..215 '0': i32 + 245..249 'self': &Bar + 258..288 '{ ... }': i32 + 272..276 'self': &Bar + 272..278 'self.0': i32 + 376..380 'self': &Bar + 390..423 '{ ... }': &Foo + 404..413 '&Foo('z')': &Foo + 405..408 'Foo': Foo(char) -> Foo + 405..413 'Foo('z')': Foo + 409..412 ''z'': char + 453..506 '{ ... }': () + 467..468 'x': char + 471..489 'super:...r::new': fn new() -> Bar + 471..491 'super:...:new()': Bar + 471..499 'super:...ango()': char "#]], ) } diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 3418ed21e..81d0215cf 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs @@ -951,62 +951,57 @@ fn infer_argument_autoderef() { fn infer_method_argument_autoderef() { check_infer( r#" - #[lang = "deref"] - pub trait Deref { - type Target; - fn deref(&self) -> &Self::Target; - } +//- minicore: deref +use core::ops::Deref; +struct A(*mut T); - struct A(*mut T); +impl A { + fn foo(&self, x: &A) -> &T { + &*x.0 + } +} - impl A { - fn foo(&self, x: &A) -> &T { - &*x.0 - } - } +struct B(T); - struct B(T); - - impl Deref for B { - type Target = T; - fn deref(&self) -> &Self::Target { - &self.0 - } - } +impl Deref for B { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } +} - fn test(a: A) { - let t = A(0 as *mut _).foo(&&B(B(a))); - } - "#, +fn test(a: A) { + let t = A(0 as *mut _).foo(&&B(B(a))); +} +"#, expect![[r#" - 67..71 'self': &Self - 143..147 'self': &A - 149..150 'x': &A - 165..186 '{ ... }': &T - 175..180 '&*x.0': &T - 176..180 '*x.0': T - 177..178 'x': &A - 177..180 'x.0': *mut T - 267..271 'self': &B - 290..313 '{ ... }': &T - 300..307 '&self.0': &T - 301..305 'self': &B - 301..307 'self.0': T - 325..326 'a': A - 336..382 '{ ...))); }': () - 346..347 't': &i32 - 350..351 'A': A(*mut i32) -> A - 350..364 'A(0 as *mut _)': A - 350..379 'A(0 as...B(a)))': &i32 - 352..353 '0': i32 - 352..363 '0 as *mut _': *mut i32 - 369..378 '&&B(B(a))': &&B>> - 370..378 '&B(B(a))': &B>> - 371..372 'B': B>>(B>) -> B>> - 371..378 'B(B(a))': B>> - 373..374 'B': B>(A) -> B> - 373..377 'B(a)': B> - 375..376 'a': A + 71..75 'self': &A + 77..78 'x': &A + 93..114 '{ ... }': &T + 103..108 '&*x.0': &T + 104..108 '*x.0': T + 105..106 'x': &A + 105..108 'x.0': *mut T + 195..199 'self': &B + 218..241 '{ ... }': &T + 228..235 '&self.0': &T + 229..233 'self': &B + 229..235 'self.0': T + 253..254 'a': A + 264..310 '{ ...))); }': () + 274..275 't': &i32 + 278..279 'A': A(*mut i32) -> A + 278..292 'A(0 as *mut _)': A + 278..307 'A(0 as...B(a)))': &i32 + 280..281 '0': i32 + 280..291 '0 as *mut _': *mut i32 + 297..306 '&&B(B(a))': &&B>> + 298..306 '&B(B(a))': &B>> + 299..300 'B': B>>(B>) -> B>> + 299..306 'B(B(a))': B>> + 301..302 'B': B>(A) -> B> + 301..305 'B(a)': B> + 303..304 'a': A "#]], ); } @@ -1015,15 +1010,15 @@ fn infer_method_argument_autoderef() { fn infer_in_elseif() { check_infer( r#" - struct Foo { field: i32 } - fn main(foo: Foo) { - if true { +struct Foo { field: i32 } +fn main(foo: Foo) { + if true { - } else if false { - foo.field - } - } - "#, + } else if false { + foo.field + } +} +"#, expect![[r#" 34..37 'foo': Foo 44..108 '{ ... } }': () @@ -1043,28 +1038,29 @@ fn infer_in_elseif() { fn infer_if_match_with_return() { check_infer( r#" - fn foo() { - let _x1 = if true { - 1 - } else { - return; - }; - let _x2 = if true { - 2 - } else { - return - }; - let _x3 = match true { - true => 3, - _ => { - return; - } - }; - let _x4 = match true { - true => 4, - _ => return - }; - }"#, +fn foo() { + let _x1 = if true { + 1 + } else { + return; + }; + let _x2 = if true { + 2 + } else { + return + }; + let _x3 = match true { + true => 3, + _ => { + return; + } + }; + let _x4 = match true { + true => 4, + _ => return + }; +} +"#, expect![[r#" 9..322 '{ ... }; }': () 19..22 '_x1': i32 -- cgit v1.2.3