From f4b52682dad6dbf31fb17beb645e362e359ee119 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jun 2021 21:39:44 +0300 Subject: internal: unindent some tests --- crates/hir_ty/src/tests/simple.rs | 507 +++++++++++++++++++------------------- 1 file changed, 252 insertions(+), 255 deletions(-) diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 81d0215cf..2687c6a44 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs @@ -175,16 +175,17 @@ fn test() { fn infer_basics() { check_infer( r#" - fn test(a: u32, b: isize, c: !, d: &str) { - a; - b; - c; - d; - 1usize; - 1isize; - "test"; - 1.0f32; - }"#, +fn test(a: u32, b: isize, c: !, d: &str) { + a; + b; + c; + d; + 1usize; + 1isize; + "test"; + 1.0f32; +} +"#, expect![[r#" 8..9 'a': u32 16..17 'b': isize @@ -207,15 +208,15 @@ fn infer_basics() { fn infer_let() { check_infer( r#" - fn test() { - let a = 1isize; - let b: usize = 1; - let c = b; - let d: u32; - let e; - let f: i32 = e; - } - "#, +fn test() { + let a = 1isize; + let b: usize = 1; + let c = b; + let d: u32; + let e; + let f: i32 = e; +} +"#, expect![[r#" 10..117 '{ ...= e; }': () 20..21 'a': isize @@ -236,17 +237,17 @@ fn infer_let() { fn infer_paths() { check_infer( r#" - fn a() -> u32 { 1 } +fn a() -> u32 { 1 } - mod b { - fn c() -> u32 { 1 } - } +mod b { + fn c() -> u32 { 1 } +} - fn test() { - a(); - b::c(); - } - "#, +fn test() { + a(); + b::c(); +} +"#, expect![[r#" 14..19 '{ 1 }': u32 16..17 '1': u32 @@ -265,17 +266,17 @@ fn infer_paths() { fn infer_path_type() { check_infer( r#" - struct S; +struct S; - impl S { - fn foo() -> i32 { 1 } - } +impl S { + fn foo() -> i32 { 1 } +} - fn test() { - S::foo(); - ::foo(); - } - "#, +fn test() { + S::foo(); + ::foo(); +} +"#, expect![[r#" 40..45 '{ 1 }': i32 42..43 '1': i32 @@ -292,21 +293,21 @@ fn infer_path_type() { fn infer_struct() { check_infer( r#" - struct A { - b: B, - c: C, - } - struct B; - struct C(usize); +struct A { + b: B, + c: C, +} +struct B; +struct C(usize); - fn test() { - let c = C(1); - B; - let a: A = A { b: B, c: C(1) }; - a.b; - a.c; - } - "#, +fn test() { + let c = C(1); + B; + let a: A = A { b: B, c: C(1) }; + a.b; + a.c; +} +"#, expect![[r#" 71..153 '{ ...a.c; }': () 81..82 'c': C @@ -332,14 +333,15 @@ fn infer_struct() { fn infer_enum() { check_infer( r#" - enum E { - V1 { field: u32 }, - V2 - } - fn test() { - E::V1 { field: 1 }; - E::V2; - }"#, +enum E { + V1 { field: u32 }, + V2 +} +fn test() { + E::V1 { field: 1 }; + E::V2; +} +"#, expect![[r#" 51..89 '{ ...:V2; }': () 57..75 'E::V1 ...d: 1 }': E @@ -353,23 +355,23 @@ fn infer_enum() { fn infer_union() { check_infer( r#" - union MyUnion { - foo: u32, - bar: f32, - } +union MyUnion { + foo: u32, + bar: f32, +} - fn test() { - let u = MyUnion { foo: 0 }; - unsafe { baz(u); } - let u = MyUnion { bar: 0.0 }; - unsafe { baz(u); } - } +fn test() { + let u = MyUnion { foo: 0 }; + unsafe { baz(u); } + let u = MyUnion { bar: 0.0 }; + unsafe { baz(u); } +} - unsafe fn baz(u: MyUnion) { - let inner = u.foo; - let inner = u.bar; - } - "#, +unsafe fn baz(u: MyUnion) { + let inner = u.foo; + let inner = u.bar; +} +"#, expect![[r#" 57..172 '{ ...); } }': () 67..68 'u': MyUnion @@ -404,19 +406,19 @@ fn infer_union() { fn infer_refs() { check_infer( r#" - fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { - a; - *a; - &a; - &mut a; - b; - *b; - &b; - c; - *c; - d; - *d; - } +fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { + a; + *a; + &a; + &mut a; + b; + *b; + &b; + c; + *c; + d; + *d; +} "#, expect![[r#" 8..9 'a': &u32 @@ -450,11 +452,11 @@ fn infer_refs() { fn infer_raw_ref() { check_infer( r#" - fn test(a: i32) { - &raw mut a; - &raw const a; - } - "#, +fn test(a: i32) { + &raw mut a; + &raw const a; +} +"#, expect![[r#" 8..9 'a': i32 16..53 '{ ...t a; }': () @@ -524,26 +526,26 @@ h"; fn infer_unary_op() { check_infer( r#" - enum SomeType {} - - fn test(x: SomeType) { - let b = false; - let c = !b; - let a = 100; - let d: i128 = -a; - let e = -100; - let f = !!!true; - let g = !42; - let h = !10u32; - let j = !a; - -3.14; - !3; - -x; - !x; - -"hello"; - !"hello"; - } - "#, +enum SomeType {} + +fn test(x: SomeType) { + let b = false; + let c = !b; + let a = 100; + let d: i128 = -a; + let e = -100; + let f = !!!true; + let g = !42; + let h = !10u32; + let j = !a; + -3.14; + !3; + -x; + !x; + -"hello"; + !"hello"; +} +"#, expect![[r#" 26..27 'x': SomeType 39..271 '{ ...lo"; }': () @@ -594,19 +596,19 @@ fn infer_unary_op() { fn infer_backwards() { check_infer( r#" - fn takes_u32(x: u32) {} +fn takes_u32(x: u32) {} - struct S { i32_field: i32 } +struct S { i32_field: i32 } - fn test() -> &mut &f64 { - let a = unknown_function(); - takes_u32(a); - let b = unknown_function(); - S { i32_field: b }; - let c = unknown_function(); - &mut &c - } - "#, +fn test() -> &mut &f64 { + let a = unknown_function(); + takes_u32(a); + let b = unknown_function(); + S { i32_field: b }; + let c = unknown_function(); + &mut &c +} +"#, expect![[r#" 13..14 'x': u32 21..23 '{}': () @@ -636,23 +638,23 @@ fn infer_backwards() { fn infer_self() { check_infer( r#" - struct S; +struct S; - impl S { - fn test(&self) { - self; - } - fn test2(self: &Self) { - self; - } - fn test3() -> Self { - S {} - } - fn test4() -> Self { - Self {} - } - } - "#, +impl S { + fn test(&self) { + self; + } + fn test2(self: &Self) { + self; + } + fn test3() -> Self { + S {} + } + fn test4() -> Self { + Self {} + } +} +"#, expect![[r#" 33..37 'self': &S 39..60 '{ ... }': () @@ -672,30 +674,30 @@ fn infer_self() { fn infer_self_as_path() { check_infer( r#" - struct S1; - struct S2(isize); - enum E { - V1, - V2(u32), - } +struct S1; +struct S2(isize); +enum E { + V1, + V2(u32), +} - impl S1 { - fn test() { - Self; - } - } - impl S2 { - fn test() { - Self(1); - } - } - impl E { - fn test() { - Self::V1; - Self::V2(1); - } - } - "#, +impl S1 { + fn test() { + Self; + } +} +impl S2 { + fn test() { + Self(1); + } +} +impl E { + fn test() { + Self::V1; + Self::V2(1); + } +} +"#, expect![[r#" 86..107 '{ ... }': () 96..100 'Self': S1 @@ -716,26 +718,26 @@ fn infer_self_as_path() { fn infer_binary_op() { check_infer( r#" - fn f(x: bool) -> i32 { - 0i32 - } +fn f(x: bool) -> i32 { + 0i32 +} - fn test() -> bool { - let x = a && b; - let y = true || false; - let z = x == y; - let t = x != y; - let minus_forty: isize = -40isize; - let h = minus_forty <= CONST_2; - let c = f(z || y) + 5; - let d = b; - let g = minus_forty ^= i; - let ten: usize = 10; - let ten_is_eleven = ten == some_num; - - ten < 3 - } - "#, +fn test() -> bool { + let x = a && b; + let y = true || false; + let z = x == y; + let t = x != y; + let minus_forty: isize = -40isize; + let h = minus_forty <= CONST_2; + let c = f(z || y) + 5; + let d = b; + let g = minus_forty ^= i; + let ten: usize = 10; + let ten_is_eleven = ten == some_num; + + ten < 3 +} +"#, expect![[r#" 5..6 'x': bool 21..33 '{ 0i32 }': i32 @@ -795,11 +797,11 @@ fn infer_binary_op() { fn infer_shift_op() { check_infer( r#" - fn test() { - 1u32 << 5u8; - 1u32 >> 5u8; - } - "#, +fn test() { + 1u32 << 5u8; + 1u32 >> 5u8; +} +"#, expect![[r#" 10..47 '{ ...5u8; }': () 16..20 '1u32': u32 @@ -816,29 +818,29 @@ fn infer_shift_op() { fn infer_field_autoderef() { check_infer( r#" - struct A { - b: B, - } - struct B; - - fn test1(a: A) { - let a1 = a; - a1.b; - let a2 = &a; - a2.b; - let a3 = &mut a; - a3.b; - let a4 = &&&&&&&a; - a4.b; - let a5 = &mut &&mut &&mut a; - a5.b; - } +struct A { + b: B, +} +struct B; - fn test2(a1: *const A, a2: *mut A) { - a1.b; - a2.b; - } - "#, +fn test1(a: A) { + let a1 = a; + a1.b; + let a2 = &a; + a2.b; + let a3 = &mut a; + a3.b; + let a4 = &&&&&&&a; + a4.b; + let a5 = &mut &&mut &&mut a; + a5.b; +} + +fn test2(a1: *const A, a2: *mut A) { + a1.b; + a2.b; +} +"#, expect![[r#" 43..44 'a': A 49..212 '{ ...5.b; }': () @@ -891,58 +893,53 @@ fn infer_field_autoderef() { fn infer_argument_autoderef() { check_infer( r#" - #[lang = "deref"] - pub trait Deref { - type Target; - fn deref(&self) -> &Self::Target; - } - - struct A(T); +//- minicore: deref +use core::ops::Deref; +struct A(T); - impl A { - fn foo(&self) -> &T { - &self.0 - } - } +impl A { + fn foo(&self) -> &T { + &self.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() { - let t = A::foo(&&B(B(A(42)))); - } - "#, +fn test() { + let t = A::foo(&&B(B(A(42)))); +} +"#, expect![[r#" - 67..71 'self': &Self - 138..142 'self': &A - 150..173 '{ ... }': &T - 160..167 '&self.0': &T - 161..165 'self': &A - 161..167 'self.0': T - 254..258 'self': &B - 277..300 '{ ... }': &T - 287..294 '&self.0': &T - 288..292 'self': &B - 288..294 'self.0': T - 314..352 '{ ...))); }': () - 324..325 't': &i32 - 328..334 'A::foo': fn foo(&A) -> &i32 - 328..349 'A::foo...42))))': &i32 - 335..348 '&&B(B(A(42)))': &&B>> - 336..348 '&B(B(A(42)))': &B>> - 337..338 'B': B>>(B>) -> B>> - 337..348 'B(B(A(42)))': B>> - 339..340 'B': B>(A) -> B> - 339..347 'B(A(42))': B> - 341..342 'A': A(i32) -> A - 341..346 'A(42)': A - 343..345 '42': i32 + 66..70 'self': &A + 78..101 '{ ... }': &T + 88..95 '&self.0': &T + 89..93 'self': &A + 89..95 'self.0': T + 182..186 'self': &B + 205..228 '{ ... }': &T + 215..222 '&self.0': &T + 216..220 'self': &B + 216..222 'self.0': T + 242..280 '{ ...))); }': () + 252..253 't': &i32 + 256..262 'A::foo': fn foo(&A) -> &i32 + 256..277 'A::foo...42))))': &i32 + 263..276 '&&B(B(A(42)))': &&B>> + 264..276 '&B(B(A(42)))': &B>> + 265..266 'B': B>>(B>) -> B>> + 265..276 'B(B(A(42)))': B>> + 267..268 'B': B>(A) -> B> + 267..275 'B(A(42))': B> + 269..270 'A': A(i32) -> A + 269..274 'A(42)': A + 271..273 '42': i32 "#]], ); } -- cgit v1.2.3