aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs63
1 files changed, 61 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 82c4aeddb..8d8a0eaaa 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1427,6 +1427,65 @@ fn test() {
1427} 1427}
1428 1428
1429#[test] 1429#[test]
1430fn infer_associated_method_generics_without_args() {
1431 assert_snapshot_matches!(
1432 infer(r#"
1433struct Gen<T> {
1434 val: T
1435}
1436
1437impl<T> Gen<T> {
1438 pub fn make() -> Gen<T> {
1439 loop { }
1440 }
1441}
1442
1443fn test() {
1444 let a = Gen::<u32>::make();
1445}
1446"#),
1447 @r###"
1448[76; 100) '{ ... }': !
1449[86; 94) 'loop { }': !
1450[91; 94) '{ }': ()
1451[114; 149) '{ ...e(); }': ()
1452[124; 125) 'a': Gen<u32>
1453[128; 144) 'Gen::<...::make': fn make<u32>() -> Gen<T>
1454[128; 146) 'Gen::<...make()': Gen<u32>"###
1455 );
1456}
1457
1458#[test]
1459fn infer_associated_method_generics_2_type_params_without_args() {
1460 assert_snapshot_matches!(
1461 infer(r#"
1462struct Gen<T, U> {
1463 val: T,
1464 val2: U,
1465}
1466
1467impl<T> Gen<u32, T> {
1468 pub fn make() -> Gen<u32,T> {
1469 loop { }
1470 }
1471}
1472
1473fn test() {
1474 let a = Gen::<u32, u64>::make();
1475}
1476"#),
1477 @r###"
1478[102; 126) '{ ... }': !
1479[112; 120) 'loop { }': !
1480[117; 120) '{ }': ()
1481[140; 180) '{ ...e(); }': ()
1482[150; 151) 'a': Gen<u32, u64>
1483[154; 175) 'Gen::<...::make': fn make<u64>() -> Gen<u32, T>
1484[154; 177) 'Gen::<...make()': Gen<u32, u64>"###
1485 );
1486}
1487
1488#[test]
1430fn infer_type_alias() { 1489fn infer_type_alias() {
1431 assert_snapshot_matches!( 1490 assert_snapshot_matches!(
1432 infer(r#" 1491 infer(r#"
@@ -1814,8 +1873,8 @@ pub fn main_loop() {
1814 @r###" 1873 @r###"
1815[144; 146) '{}': () 1874[144; 146) '{}': ()
1816[169; 198) '{ ...t(); }': () 1875[169; 198) '{ ...t(); }': ()
1817[175; 193) 'FxHash...efault': fn default<{unknown}, {unknown}>() -> HashSet<T, H> 1876[175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H>
1818[175; 195) 'FxHash...ault()': HashSet<{unknown}, {unknown}>"### 1877[175; 195) 'FxHash...ault()': HashSet<{unknown}, FxHasher>"###
1819 ); 1878 );
1820} 1879}
1821 1880