aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <[email protected]>2019-01-25 20:16:02 +0000
committerMarcus Klaas de Vries <[email protected]>2019-01-27 16:59:21 +0000
commit3bd47c0285433b5eb258196a81b95141d2a70505 (patch)
tree41bd19f6e95e4c22bd39c35702a1d2e048dd9cef /crates/ra_hir/src/ty
parent3f4f50baaa21cb2d0f6c102f1ca521946071a8dc (diff)
First attempt at generic type inference for fns
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs22
1 files changed, 22 insertions, 0 deletions
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() {
594 ); 594 );
595} 595}
596 596
597#[test]
598fn infer_type_param() {
599 check_inference(
600 "generic_fn",
601 r#"
602fn id<T>(x: T) -> T {
603 x
604}
605
606fn clone<T>(x: &T) -> T {
607 x
608}
609
610fn test() {
611 let y = 10u32;
612 id(y);
613 let x: bool = clone(z);
614}
615"#,
616 );
617}
618
597fn infer(content: &str) -> String { 619fn infer(content: &str) -> String {
598 let (db, _, file_id) = MockDatabase::with_single_file(content); 620 let (db, _, file_id) = MockDatabase::with_single_file(content);
599 let source_file = db.parse(file_id); 621 let source_file = db.parse(file_id);