diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-25 20:16:02 +0000 |
---|---|---|
committer | Marcus Klaas de Vries <[email protected]> | 2019-01-27 16:59:21 +0000 |
commit | 3bd47c0285433b5eb258196a81b95141d2a70505 (patch) | |
tree | 41bd19f6e95e4c22bd39c35702a1d2e048dd9cef /crates/ra_hir/src/ty/tests.rs | |
parent | 3f4f50baaa21cb2d0f6c102f1ca521946071a8dc (diff) |
First attempt at generic type inference for fns
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 22 |
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] | ||
598 | fn infer_type_param() { | ||
599 | check_inference( | ||
600 | "generic_fn", | ||
601 | r#" | ||
602 | fn id<T>(x: T) -> T { | ||
603 | x | ||
604 | } | ||
605 | |||
606 | fn clone<T>(x: &T) -> T { | ||
607 | x | ||
608 | } | ||
609 | |||
610 | fn test() { | ||
611 | let y = 10u32; | ||
612 | id(y); | ||
613 | let x: bool = clone(z); | ||
614 | } | ||
615 | "#, | ||
616 | ); | ||
617 | } | ||
618 | |||
597 | fn infer(content: &str) -> String { | 619 | fn 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); |