diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/coercion.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/regression.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 28 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 12 |
4 files changed, 38 insertions, 12 deletions
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs index 3e3d55c04..b2c971f02 100644 --- a/crates/ra_hir_ty/src/tests/coercion.rs +++ b/crates/ra_hir_ty/src/tests/coercion.rs | |||
@@ -407,16 +407,16 @@ fn test() { | |||
407 | [30; 31) 'x': &Foo | 407 | [30; 31) 'x': &Foo |
408 | [39; 41) '{}': () | 408 | [39; 41) '{}': () |
409 | [52; 133) '{ ...oo); }': () | 409 | [52; 133) '{ ...oo); }': () |
410 | [58; 71) 'takes_ref_foo': fn takes_ref_foo(&Foo) -> () | 410 | [58; 71) 'takes_ref_foo': fn takes_ref_foo(&Foo) |
411 | [58; 77) 'takes_...(&Foo)': () | 411 | [58; 77) 'takes_...(&Foo)': () |
412 | [72; 76) '&Foo': &Foo | 412 | [72; 76) '&Foo': &Foo |
413 | [73; 76) 'Foo': Foo | 413 | [73; 76) 'Foo': Foo |
414 | [83; 96) 'takes_ref_foo': fn takes_ref_foo(&Foo) -> () | 414 | [83; 96) 'takes_ref_foo': fn takes_ref_foo(&Foo) |
415 | [83; 103) 'takes_...&&Foo)': () | 415 | [83; 103) 'takes_...&&Foo)': () |
416 | [97; 102) '&&Foo': &&Foo | 416 | [97; 102) '&&Foo': &&Foo |
417 | [98; 102) '&Foo': &Foo | 417 | [98; 102) '&Foo': &Foo |
418 | [99; 102) 'Foo': Foo | 418 | [99; 102) 'Foo': Foo |
419 | [109; 122) 'takes_ref_foo': fn takes_ref_foo(&Foo) -> () | 419 | [109; 122) 'takes_ref_foo': fn takes_ref_foo(&Foo) |
420 | [109; 130) 'takes_...&&Foo)': () | 420 | [109; 130) 'takes_...&&Foo)': () |
421 | [123; 129) '&&&Foo': &&&Foo | 421 | [123; 129) '&&&Foo': &&&Foo |
422 | [124; 129) '&&Foo': &&Foo | 422 | [124; 129) '&&Foo': &&Foo |
@@ -484,7 +484,7 @@ fn test() { | |||
484 | [171; 178) 'loop {}': ! | 484 | [171; 178) 'loop {}': ! |
485 | [176; 178) '{}': () | 485 | [176; 178) '{}': () |
486 | [191; 236) '{ ... }); }': () | 486 | [191; 236) '{ ... }); }': () |
487 | [197; 210) 'takes_ref_str': fn takes_ref_str(&str) -> () | 487 | [197; 210) 'takes_ref_str': fn takes_ref_str(&str) |
488 | [197; 233) 'takes_...g() })': () | 488 | [197; 233) 'takes_...g() })': () |
489 | [211; 232) '&{ ret...ng() }': &String | 489 | [211; 232) '&{ ret...ng() }': &String |
490 | [212; 232) '{ retu...ng() }': String | 490 | [212; 232) '{ retu...ng() }': String |
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index 2ee9b8f10..3402e0cb5 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs | |||
@@ -376,7 +376,7 @@ fn issue_2669() { | |||
376 | ), | 376 | ), |
377 | @r###" | 377 | @r###" |
378 | [147; 262) '{ ... }': () | 378 | [147; 262) '{ ... }': () |
379 | [161; 164) 'end': fn end<{unknown}>() -> () | 379 | [161; 164) 'end': fn end<{unknown}>() |
380 | [161; 166) 'end()': () | 380 | [161; 166) 'end()': () |
381 | [199; 252) '{ ... }': () | 381 | [199; 252) '{ ... }': () |
382 | [221; 223) '_x': ! | 382 | [221; 223) '_x': ! |
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index a600b947d..c2f1ded2f 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs | |||
@@ -521,7 +521,7 @@ fn test() -> &mut &f64 { | |||
521 | [88; 89) 'a': u32 | 521 | [88; 89) 'a': u32 |
522 | [92; 108) 'unknow...nction': {unknown} | 522 | [92; 108) 'unknow...nction': {unknown} |
523 | [92; 110) 'unknow...tion()': u32 | 523 | [92; 110) 'unknow...tion()': u32 |
524 | [116; 125) 'takes_u32': fn takes_u32(u32) -> () | 524 | [116; 125) 'takes_u32': fn takes_u32(u32) |
525 | [116; 128) 'takes_u32(a)': () | 525 | [116; 128) 'takes_u32(a)': () |
526 | [126; 127) 'a': u32 | 526 | [126; 127) 'a': u32 |
527 | [138; 139) 'b': i32 | 527 | [138; 139) 'b': i32 |
@@ -1729,3 +1729,29 @@ fn foo() -> u32 { | |||
1729 | "### | 1729 | "### |
1730 | ); | 1730 | ); |
1731 | } | 1731 | } |
1732 | |||
1733 | #[test] | ||
1734 | fn fn_pointer_return() { | ||
1735 | assert_snapshot!( | ||
1736 | infer(r#" | ||
1737 | struct Vtable { | ||
1738 | method: fn(), | ||
1739 | } | ||
1740 | |||
1741 | fn main() { | ||
1742 | let vtable = Vtable { method: || {} }; | ||
1743 | let m = vtable.method; | ||
1744 | } | ||
1745 | "#), | ||
1746 | @r###" | ||
1747 | [48; 121) '{ ...hod; }': () | ||
1748 | [58; 64) 'vtable': Vtable | ||
1749 | [67; 91) 'Vtable...| {} }': Vtable | ||
1750 | [84; 89) '|| {}': || -> () | ||
1751 | [87; 89) '{}': () | ||
1752 | [101; 102) 'm': fn() | ||
1753 | [105; 111) 'vtable': Vtable | ||
1754 | [105; 118) 'vtable.method': fn() | ||
1755 | "### | ||
1756 | ); | ||
1757 | } | ||
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index f009a708c..081aa943a 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -263,7 +263,7 @@ fn test() { | |||
263 | [119; 120) 'S': S<u32>(u32) -> S<u32> | 263 | [119; 120) 'S': S<u32>(u32) -> S<u32> |
264 | [119; 129) 'S(unknown)': S<u32> | 264 | [119; 129) 'S(unknown)': S<u32> |
265 | [121; 128) 'unknown': u32 | 265 | [121; 128) 'unknown': u32 |
266 | [135; 138) 'foo': fn foo<S<u32>>(S<u32>) -> () | 266 | [135; 138) 'foo': fn foo<S<u32>>(S<u32>) |
267 | [135; 141) 'foo(s)': () | 267 | [135; 141) 'foo(s)': () |
268 | [139; 140) 's': S<u32> | 268 | [139; 140) 's': S<u32> |
269 | "### | 269 | "### |
@@ -962,7 +962,7 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u32>) { | |||
962 | [224; 225) 'S': S<u16>(u16) -> S<u16> | 962 | [224; 225) 'S': S<u16>(u16) -> S<u16> |
963 | [224; 228) 'S(1)': S<u16> | 963 | [224; 228) 'S(1)': S<u16> |
964 | [226; 227) '1': u16 | 964 | [226; 227) '1': u16 |
965 | [234; 237) 'bar': fn bar(S<u16>) -> () | 965 | [234; 237) 'bar': fn bar(S<u16>) |
966 | [234; 240) 'bar(z)': () | 966 | [234; 240) 'bar(z)': () |
967 | [238; 239) 'z': S<u16> | 967 | [238; 239) 'z': S<u16> |
968 | [246; 247) 'x': impl Trait<u64> | 968 | [246; 247) 'x': impl Trait<u64> |
@@ -1108,8 +1108,8 @@ fn test() { | |||
1108 | [40; 47) 'loop {}': ! | 1108 | [40; 47) 'loop {}': ! |
1109 | [45; 47) '{}': () | 1109 | [45; 47) '{}': () |
1110 | [91; 124) '{ ...foo; }': () | 1110 | [91; 124) '{ ...foo; }': () |
1111 | [101; 102) 'f': fn(S) -> () | 1111 | [101; 102) 'f': fn(S) |
1112 | [118; 121) 'foo': fn foo(S) -> () | 1112 | [118; 121) 'foo': fn foo(S) |
1113 | "### | 1113 | "### |
1114 | ); | 1114 | ); |
1115 | } | 1115 | } |
@@ -1962,7 +1962,7 @@ fn test() -> impl Trait<i32> { | |||
1962 | [229; 241) 'S(default())': S<u32> | 1962 | [229; 241) 'S(default())': S<u32> |
1963 | [231; 238) 'default': fn default<u32>() -> u32 | 1963 | [231; 238) 'default': fn default<u32>() -> u32 |
1964 | [231; 240) 'default()': u32 | 1964 | [231; 240) 'default()': u32 |
1965 | [247; 250) 'foo': fn foo(S<u32>) -> () | 1965 | [247; 250) 'foo': fn foo(S<u32>) |
1966 | [247; 254) 'foo(s1)': () | 1966 | [247; 254) 'foo(s1)': () |
1967 | [251; 253) 's1': S<u32> | 1967 | [251; 253) 's1': S<u32> |
1968 | [264; 265) 'x': i32 | 1968 | [264; 265) 'x': i32 |
@@ -2012,7 +2012,7 @@ fn main() { | |||
2012 | [147; 149) '_v': F | 2012 | [147; 149) '_v': F |
2013 | [192; 195) '{ }': () | 2013 | [192; 195) '{ }': () |
2014 | [207; 238) '{ ... }); }': () | 2014 | [207; 238) '{ ... }); }': () |
2015 | [213; 223) 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ()) -> () | 2015 | [213; 223) 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ()) |
2016 | [213; 235) 'f::<()... z; })': () | 2016 | [213; 235) 'f::<()... z; })': () |
2017 | [224; 234) '|z| { z; }': |&()| -> () | 2017 | [224; 234) '|z| { z; }': |&()| -> () |
2018 | [225; 226) 'z': &() | 2018 | [225; 226) 'z': &() |