diff options
author | Unreal Hoang <[email protected]> | 2019-07-20 12:11:18 +0100 |
---|---|---|
committer | Unreal Hoang <[email protected]> | 2019-07-20 12:12:19 +0100 |
commit | bacf926a77a3e4040ccaf64cce1b1517e41a8d47 (patch) | |
tree | 0b979a84ccd68739dab8cc6d2aa1294611a1d7de /crates/ra_hir/src/ty/tests.rs | |
parent | 5ac9f5cdc7a88dcb9545d2e150780c8edee83b06 (diff) |
infer type for await
by projecting inner_ty to Future::Output alias
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 265740e54..d4bfcb888 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -21,6 +21,41 @@ use crate::{ | |||
21 | // update the snapshots. | 21 | // update the snapshots. |
22 | 22 | ||
23 | #[test] | 23 | #[test] |
24 | fn infer_await() { | ||
25 | let (mut db, pos) = MockDatabase::with_position( | ||
26 | r#" | ||
27 | //- /main.rs | ||
28 | |||
29 | struct IntFuture; | ||
30 | |||
31 | impl Future for IntFuture { | ||
32 | type Output = u64; | ||
33 | } | ||
34 | |||
35 | fn test() { | ||
36 | let r = IntFuture; | ||
37 | let v = r.await; | ||
38 | v<|>; | ||
39 | } | ||
40 | |||
41 | //- /std.rs | ||
42 | #[prelude_import] use future::*; | ||
43 | mod future { | ||
44 | trait Future { | ||
45 | type Output; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | "#, | ||
50 | ); | ||
51 | db.set_crate_graph_from_fixture(crate_graph! { | ||
52 | "main": ("/main.rs", ["std"]), | ||
53 | "std": ("/std.rs", []), | ||
54 | }); | ||
55 | assert_eq!("u64", type_at_pos(&db, pos)); | ||
56 | } | ||
57 | |||
58 | #[test] | ||
24 | fn infer_try() { | 59 | fn infer_try() { |
25 | let (mut db, pos) = MockDatabase::with_position( | 60 | let (mut db, pos) = MockDatabase::with_position( |
26 | r#" | 61 | r#" |