From 3bd47c0285433b5eb258196a81b95141d2a70505 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Fri, 25 Jan 2019 21:16:02 +0100 Subject: First attempt at generic type inference for fns --- crates/ra_hir/src/ty/tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index f74d6f5ea..40913b164 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -594,6 +594,28 @@ fn test() { ); } +#[test] +fn infer_type_param() { + check_inference( + "generic_fn", + r#" +fn id(x: T) -> T { + x +} + +fn clone(x: &T) -> T { + x +} + +fn test() { + let y = 10u32; + id(y); + let x: bool = clone(z); +} +"#, + ); +} + fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.parse(file_id); -- cgit v1.2.3 From aa06893a1493770f8009d098a5340f1a9ba13dec Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 26 Jan 2019 00:30:56 +0100 Subject: Add type params to FnSignature --- .../src/ty/snapshots/tests__infer_backwards.snap | 8 ++-- .../src/ty/snapshots/tests__infer_binary_op.snap | 8 ++-- .../snapshots/tests__infer_function_generics.snap | 30 ++++++------- .../ty/snapshots/tests__infer_generic_chain.snap | 52 +++++++++++----------- .../src/ty/snapshots/tests__infer_paths.snap | 10 ++--- 5 files changed, 54 insertions(+), 54 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap index 5c74bd8c7..e6b39f151 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:44:59.880187500+00:00" -creator: insta@0.4.0 +created: "2019-01-25T23:18:54.943309491+00:00" +creator: insta@0.5.2 expression: "&result" -source: "crates\\ra_hir\\src\\ty\\tests.rs" +source: crates/ra_hir/src/ty/tests.rs --- [14; 15) 'x': u32 [22; 24) '{}': () @@ -10,7 +10,7 @@ source: "crates\\ra_hir\\src\\ty\\tests.rs" [88; 89) 'a': u32 [92; 108) 'unknow...nction': [unknown] [92; 110) 'unknow...tion()': u32 -[116; 125) 'takes_u32': fn(u32) -> () +[116; 125) 'takes_u32': fn takes_u32 [116; 128) 'takes_u32(a)': () [126; 127) 'a': u32 [138; 139) 'b': i32 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap index c506bcadd..895c13ae6 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:44:59.880187500+00:00" -creator: insta@0.4.0 +created: "2019-01-25T23:18:54.949540810+00:00" +creator: insta@0.5.2 expression: "&result" -source: "crates\\ra_hir\\src\\ty\\tests.rs" +source: crates/ra_hir/src/ty/tests.rs --- [6; 7) 'x': bool [22; 34) '{ 0i32 }': i32 @@ -28,7 +28,7 @@ source: "crates\\ra_hir\\src\\ty\\tests.rs" [174; 196) 'minus_...ONST_2': bool [189; 196) 'CONST_2': isize [206; 207) 'c': i32 -[210; 211) 'f': fn(bool) -> i32 +[210; 211) 'f': fn f [210; 219) 'f(z || y)': i32 [210; 223) 'f(z || y) + 5': i32 [212; 213) 'z': bool diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap index 7203ad1e2..efe0e7adf 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap @@ -1,21 +1,21 @@ --- -created: "2019-01-22T14:44:59.954958500+00:00" -creator: insta@0.4.0 +created: "2019-01-25T23:18:54.962273460+00:00" +creator: insta@0.5.2 expression: "&result" -source: "crates\\ra_hir\\src\\ty\\tests.rs" +source: crates/ra_hir/src/ty/tests.rs --- -[10; 11) 't': [unknown] -[21; 26) '{ t }': [unknown] -[23; 24) 't': [unknown] +[10; 11) 't': T +[21; 26) '{ t }': T +[23; 24) 't': T [38; 98) '{ ...(1); }': () -[44; 46) 'id': fn(T) -> T -[44; 52) 'id(1u32)': T +[44; 46) 'id': fn id +[44; 52) 'id(1u32)': u32 [47; 51) '1u32': u32 -[58; 68) 'id::': fn(T) -> T -[58; 71) 'id::(1)': T -[69; 70) '1': T -[81; 82) 'x': T -[90; 92) 'id': fn(T) -> T -[90; 95) 'id(1)': T -[93; 94) '1': T +[58; 68) 'id::': fn id +[58; 71) 'id::(1)': i32 +[69; 70) '1': i32 +[81; 82) 'x': u64 +[90; 92) 'id': fn id +[90; 95) 'id(1)': u64 +[93; 94) '1': u64 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap index 4435180a1..aaf8ccea5 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap @@ -1,36 +1,36 @@ --- -created: "2019-01-22T14:44:59.961936900+00:00" -creator: insta@0.4.0 +created: "2019-01-25T23:18:54.978506051+00:00" +creator: insta@0.5.2 expression: "&result" -source: "crates\\ra_hir\\src\\ty\\tests.rs" +source: crates/ra_hir/src/ty/tests.rs --- [53; 57) 'self': A<[unknown]> [65; 87) '{ ... }': [unknown] [75; 79) 'self': A<[unknown]> [75; 81) 'self.x': [unknown] -[99; 100) 't': [unknown] -[110; 115) '{ t }': [unknown] -[112; 113) 't': [unknown] +[99; 100) 't': T +[110; 115) '{ t }': T +[112; 113) 't': T [135; 261) '{ ....x() }': i128 -[146; 147) 'x': T -[150; 151) '1': T -[162; 163) 'y': T -[166; 168) 'id': fn(T) -> T -[166; 171) 'id(x)': T -[169; 170) 'x': T -[182; 183) 'a': A -[186; 200) 'A { x: id(y) }': A -[193; 195) 'id': fn(T) -> T -[193; 198) 'id(y)': T -[196; 197) 'y': T -[211; 212) 'z': T -[215; 217) 'id': fn(T) -> T -[215; 222) 'id(a.x)': T -[218; 219) 'a': A -[218; 221) 'a.x': T -[233; 234) 'b': A -[237; 247) 'A { x: z }': A -[244; 245) 'z': T -[254; 255) 'b': A +[146; 147) 'x': i32 +[150; 151) '1': i32 +[162; 163) 'y': i32 +[166; 168) 'id': fn id +[166; 171) 'id(x)': i32 +[169; 170) 'x': i32 +[182; 183) 'a': A +[186; 200) 'A { x: id(y) }': A +[193; 195) 'id': fn id +[193; 198) 'id(y)': i32 +[196; 197) 'y': i32 +[211; 212) 'z': i32 +[215; 217) 'id': fn id +[215; 222) 'id(a.x)': i32 +[218; 219) 'a': A +[218; 221) 'a.x': i32 +[233; 234) 'b': A +[237; 247) 'A { x: z }': A +[244; 245) 'z': i32 +[254; 255) 'b': A [254; 259) 'b.x()': i128 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap index 0bceffaef..efca36058 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap @@ -1,16 +1,16 @@ --- -created: "2019-01-22T14:44:59.975899500+00:00" -creator: insta@0.4.0 +created: "2019-01-25T23:18:54.985011010+00:00" +creator: insta@0.5.2 expression: "&result" -source: "crates\\ra_hir\\src\\ty\\tests.rs" +source: crates/ra_hir/src/ty/tests.rs --- [15; 20) '{ 1 }': u32 [17; 18) '1': u32 [48; 53) '{ 1 }': u32 [50; 51) '1': u32 [67; 91) '{ ...c(); }': () -[73; 74) 'a': fn() -> u32 +[73; 74) 'a': fn a [73; 76) 'a()': u32 -[82; 86) 'b::c': fn() -> u32 +[82; 86) 'b::c': fn c [82; 88) 'b::c()': u32 -- cgit v1.2.3 From 04748a0f16624a1893c1da28a35ca3e220c81fce Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 26 Jan 2019 00:48:57 +0100 Subject: Add missing ty test snapshot --- .../ra_hir/src/ty/snapshots/tests__generic_fn.snap | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap new file mode 100644 index 000000000..4436dd8aa --- /dev/null +++ b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap @@ -0,0 +1,23 @@ +--- +created: "2019-01-25T23:18:55.019197432+00:00" +creator: insta@0.5.2 +expression: "&result" +source: crates/ra_hir/src/ty/tests.rs +--- +[10; 11) 'x': T +[21; 30) '{ x }': T +[27; 28) 'x': T +[44; 45) 'x': &T +[56; 65) '{ x }': &T +[62; 63) 'x': &T +[77; 138) '{ ...(z); }': () +[87; 88) 'y': u32 +[91; 96) '10u32': u32 +[102; 104) 'id': fn id +[102; 107) 'id(y)': u32 +[105; 106) 'y': u32 +[117; 118) 'x': bool +[127; 132) 'clone': fn clone +[127; 135) 'clone(z)': bool +[133; 134) 'z': &bool + -- cgit v1.2.3 From 0da1e8b2f8709cbdb20912664878121d979a5213 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 26 Jan 2019 18:47:22 +0100 Subject: Add a FnSig to Ty::FnDef --- crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap | 18 +++++++++--------- .../src/ty/snapshots/tests__infer_backwards.snap | 4 ++-- .../src/ty/snapshots/tests__infer_binary_op.snap | 4 ++-- .../ty/snapshots/tests__infer_function_generics.snap | 14 +++++++------- .../src/ty/snapshots/tests__infer_generic_chain.snap | 14 +++++++------- crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap | 6 +++--- 6 files changed, 30 insertions(+), 30 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap index 4436dd8aa..84fbe6e4c 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap @@ -1,23 +1,23 @@ --- -created: "2019-01-25T23:18:55.019197432+00:00" +created: "2019-01-26T17:46:03.963745056+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs --- -[10; 11) 'x': T -[21; 30) '{ x }': T -[27; 28) 'x': T -[44; 45) 'x': &T -[56; 65) '{ x }': &T -[62; 63) 'x': &T +[10; 11) 'x': [unknown] +[21; 30) '{ x }': [unknown] +[27; 28) 'x': [unknown] +[44; 45) 'x': &[unknown] +[56; 65) '{ x }': &[unknown] +[62; 63) 'x': &[unknown] [77; 138) '{ ...(z); }': () [87; 88) 'y': u32 [91; 96) '10u32': u32 -[102; 104) 'id': fn id +[102; 104) 'id': fn id(T) -> T [102; 107) 'id(y)': u32 [105; 106) 'y': u32 [117; 118) 'x': bool -[127; 132) 'clone': fn clone +[127; 132) 'clone': fn clone(&T) -> T [127; 135) 'clone(z)': bool [133; 134) 'z': &bool diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap index e6b39f151..f5840a934 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-25T23:18:54.943309491+00:00" +created: "2019-01-26T17:46:03.842478456+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs @@ -10,7 +10,7 @@ source: crates/ra_hir/src/ty/tests.rs [88; 89) 'a': u32 [92; 108) 'unknow...nction': [unknown] [92; 110) 'unknow...tion()': u32 -[116; 125) 'takes_u32': fn takes_u32 +[116; 125) 'takes_u32': fn takes_u32(u32) -> () [116; 128) 'takes_u32(a)': () [126; 127) 'a': u32 [138; 139) 'b': i32 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap index 895c13ae6..b9dda2bc0 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-25T23:18:54.949540810+00:00" +created: "2019-01-26T17:46:03.853259898+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs @@ -28,7 +28,7 @@ source: crates/ra_hir/src/ty/tests.rs [174; 196) 'minus_...ONST_2': bool [189; 196) 'CONST_2': isize [206; 207) 'c': i32 -[210; 211) 'f': fn f +[210; 211) 'f': fn f(bool) -> i32 [210; 219) 'f(z || y)': i32 [210; 223) 'f(z || y) + 5': i32 [212; 213) 'z': bool diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap index efe0e7adf..369705f84 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap @@ -1,21 +1,21 @@ --- -created: "2019-01-25T23:18:54.962273460+00:00" +created: "2019-01-26T17:46:03.856278205+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs --- -[10; 11) 't': T -[21; 26) '{ t }': T -[23; 24) 't': T +[10; 11) 't': [unknown] +[21; 26) '{ t }': [unknown] +[23; 24) 't': [unknown] [38; 98) '{ ...(1); }': () -[44; 46) 'id': fn id +[44; 46) 'id': fn id(T) -> T [44; 52) 'id(1u32)': u32 [47; 51) '1u32': u32 -[58; 68) 'id::': fn id +[58; 68) 'id::': fn id(T) -> T [58; 71) 'id::(1)': i32 [69; 70) '1': i32 [81; 82) 'x': u64 -[90; 92) 'id': fn id +[90; 92) 'id': fn id(T) -> T [90; 95) 'id(1)': u64 [93; 94) '1': u64 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap index aaf8ccea5..f21bffa75 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-25T23:18:54.978506051+00:00" +created: "2019-01-26T17:46:03.866825843+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs @@ -8,23 +8,23 @@ source: crates/ra_hir/src/ty/tests.rs [65; 87) '{ ... }': [unknown] [75; 79) 'self': A<[unknown]> [75; 81) 'self.x': [unknown] -[99; 100) 't': T -[110; 115) '{ t }': T -[112; 113) 't': T +[99; 100) 't': [unknown] +[110; 115) '{ t }': [unknown] +[112; 113) 't': [unknown] [135; 261) '{ ....x() }': i128 [146; 147) 'x': i32 [150; 151) '1': i32 [162; 163) 'y': i32 -[166; 168) 'id': fn id +[166; 168) 'id': fn id(T) -> T [166; 171) 'id(x)': i32 [169; 170) 'x': i32 [182; 183) 'a': A [186; 200) 'A { x: id(y) }': A -[193; 195) 'id': fn id +[193; 195) 'id': fn id(T) -> T [193; 198) 'id(y)': i32 [196; 197) 'y': i32 [211; 212) 'z': i32 -[215; 217) 'id': fn id +[215; 217) 'id': fn id(T) -> T [215; 222) 'id(a.x)': i32 [218; 219) 'a': A [218; 221) 'a.x': i32 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap index efca36058..afbe2f747 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-25T23:18:54.985011010+00:00" +created: "2019-01-26T17:46:03.928773630+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs @@ -9,8 +9,8 @@ source: crates/ra_hir/src/ty/tests.rs [48; 53) '{ 1 }': u32 [50; 51) '1': u32 [67; 91) '{ ...c(); }': () -[73; 74) 'a': fn a +[73; 74) 'a': fn a() -> u32 [73; 76) 'a()': u32 -[82; 86) 'b::c': fn c +[82; 86) 'b::c': fn c() -> u32 [82; 88) 'b::c()': u32 -- cgit v1.2.3 From f6eb44cd9e2a27d2004386c71fb6c72f79ba83b3 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 26 Jan 2019 19:25:57 +0100 Subject: Use type information from the turbofish --- crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap | 7 +++++-- .../ra_hir/src/ty/snapshots/tests__infer_function_generics.snap | 8 ++++---- crates/ra_hir/src/ty/tests.rs | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap index 84fbe6e4c..85aeefa0c 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-26T17:46:03.963745056+00:00" +created: "2019-01-26T18:16:16.568375+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs @@ -10,7 +10,7 @@ source: crates/ra_hir/src/ty/tests.rs [44; 45) 'x': &[unknown] [56; 65) '{ x }': &[unknown] [62; 63) 'x': &[unknown] -[77; 138) '{ ...(z); }': () +[77; 197) '{ ...(1); }': () [87; 88) 'y': u32 [91; 96) '10u32': u32 [102; 104) 'id': fn id(T) -> T @@ -20,4 +20,7 @@ source: crates/ra_hir/src/ty/tests.rs [127; 132) 'clone': fn clone(&T) -> T [127; 135) 'clone(z)': bool [133; 134) 'z': &bool +[173; 191) 'id::': fn id(T) -> T +[173; 194) 'id::(1)': i32 +[192; 193) '1': i32 diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap index 369705f84..8ff6e55a6 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-26T17:46:03.856278205+00:00" +created: "2019-01-26T18:16:16.530712344+00:00" creator: insta@0.5.2 expression: "&result" source: crates/ra_hir/src/ty/tests.rs @@ -11,9 +11,9 @@ source: crates/ra_hir/src/ty/tests.rs [44; 46) 'id': fn id(T) -> T [44; 52) 'id(1u32)': u32 [47; 51) '1u32': u32 -[58; 68) 'id::': fn id(T) -> T -[58; 71) 'id::(1)': i32 -[69; 70) '1': i32 +[58; 68) 'id::': fn id(T) -> T +[58; 71) 'id::(1)': i128 +[69; 70) '1': i128 [81; 82) 'x': u64 [90; 92) 'id': fn id(T) -> T [90; 95) 'id(1)': u64 diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 40913b164..fac566626 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -611,6 +611,9 @@ fn test() { let y = 10u32; id(y); let x: bool = clone(z); + + // bad turbofish - ignore! + id::(1); } "#, ); -- cgit v1.2.3 From 6249989e6c133792ff457896d4723c0eb0f42137 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sun, 27 Jan 2019 17:59:09 +0100 Subject: Process second review --- .../ra_hir/src/ty/snapshots/tests__generic_fn.snap | 26 ---------------------- .../src/ty/snapshots/tests__infer_type_param.snap | 26 ++++++++++++++++++++++ crates/ra_hir/src/ty/tests.rs | 6 ++--- 3 files changed, 28 insertions(+), 30 deletions(-) delete mode 100644 crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap create mode 100644 crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap b/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap deleted file mode 100644 index 85aeefa0c..000000000 --- a/crates/ra_hir/src/ty/snapshots/tests__generic_fn.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -created: "2019-01-26T18:16:16.568375+00:00" -creator: insta@0.5.2 -expression: "&result" -source: crates/ra_hir/src/ty/tests.rs ---- -[10; 11) 'x': [unknown] -[21; 30) '{ x }': [unknown] -[27; 28) 'x': [unknown] -[44; 45) 'x': &[unknown] -[56; 65) '{ x }': &[unknown] -[62; 63) 'x': &[unknown] -[77; 197) '{ ...(1); }': () -[87; 88) 'y': u32 -[91; 96) '10u32': u32 -[102; 104) 'id': fn id(T) -> T -[102; 107) 'id(y)': u32 -[105; 106) 'y': u32 -[117; 118) 'x': bool -[127; 132) 'clone': fn clone(&T) -> T -[127; 135) 'clone(z)': bool -[133; 134) 'z': &bool -[173; 191) 'id::': fn id(T) -> T -[173; 194) 'id::(1)': i32 -[192; 193) '1': i32 - diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap new file mode 100644 index 000000000..a99323264 --- /dev/null +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap @@ -0,0 +1,26 @@ +--- +created: "2019-01-27T16:54:18.368427685+00:00" +creator: insta@0.5.2 +expression: "&result" +source: crates/ra_hir/src/ty/tests.rs +--- +[10; 11) 'x': [unknown] +[21; 30) '{ x }': [unknown] +[27; 28) 'x': [unknown] +[44; 45) 'x': &[unknown] +[56; 65) '{ x }': &[unknown] +[62; 63) 'x': &[unknown] +[77; 157) '{ ...(1); }': () +[87; 88) 'y': u32 +[91; 96) '10u32': u32 +[102; 104) 'id': fn id(T) -> T +[102; 107) 'id(y)': u32 +[105; 106) 'y': u32 +[117; 118) 'x': bool +[127; 132) 'clone': fn clone(&T) -> T +[127; 135) 'clone(z)': bool +[133; 134) 'z': &bool +[141; 151) 'id::': fn id(T) -> T +[141; 154) 'id::(1)': i128 +[152; 153) '1': i128 + diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index fac566626..ac12d974b 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -597,7 +597,7 @@ fn test() { #[test] fn infer_type_param() { check_inference( - "generic_fn", + "infer_type_param", r#" fn id(x: T) -> T { x @@ -611,9 +611,7 @@ fn test() { let y = 10u32; id(y); let x: bool = clone(z); - - // bad turbofish - ignore! - id::(1); + id::(1); } "#, ); -- cgit v1.2.3