diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index fe5e89f2d..d5c03c4bc 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -21,6 +21,42 @@ use crate::{ | |||
21 | // update the snapshots. | 21 | // update the snapshots. |
22 | 22 | ||
23 | #[test] | 23 | #[test] |
24 | fn infer_try() { | ||
25 | let (mut db, pos) = MockDatabase::with_position( | ||
26 | r#" | ||
27 | //- /main.rs | ||
28 | enum Result<O, E> { | ||
29 | Ok(O), | ||
30 | Err(E) | ||
31 | } | ||
32 | |||
33 | impl<O, E> ::std::ops::Try for Result<O, E> { | ||
34 | type Ok = O; | ||
35 | type Error = E; | ||
36 | } | ||
37 | fn test() { | ||
38 | let r: Result<i32, u64> = Result::Ok(1); | ||
39 | let v = r?; | ||
40 | v<|>; | ||
41 | } | ||
42 | |||
43 | //- /lib.rs | ||
44 | mod ops { | ||
45 | trait Try { | ||
46 | type Ok; | ||
47 | type Error; | ||
48 | } | ||
49 | } | ||
50 | "#, | ||
51 | ); | ||
52 | db.set_crate_graph_from_fixture(crate_graph! { | ||
53 | "main": ("/main.rs", ["std"]), | ||
54 | "std": ("/lib.rs", []), | ||
55 | }); | ||
56 | assert_eq!("i32", type_at_pos(&db, pos)); | ||
57 | } | ||
58 | |||
59 | #[test] | ||
24 | fn infer_for_loop() { | 60 | fn infer_for_loop() { |
25 | let (mut db, pos) = MockDatabase::with_position( | 61 | let (mut db, pos) = MockDatabase::with_position( |
26 | r#" | 62 | r#" |
@@ -56,6 +92,7 @@ mod iter { | |||
56 | }); | 92 | }); |
57 | assert_eq!("&str", type_at_pos(&db, pos)); | 93 | assert_eq!("&str", type_at_pos(&db, pos)); |
58 | } | 94 | } |
95 | |||
59 | #[test] | 96 | #[test] |
60 | fn infer_basics() { | 97 | fn infer_basics() { |
61 | assert_snapshot_matches!( | 98 | assert_snapshot_matches!( |