aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorUnreal Hoang <[email protected]>2019-07-08 16:02:15 +0100
committerUnreal Hoang <[email protected]>2019-07-08 16:19:09 +0100
commit944f71afc692733cbc151bb3113d45a8159de132 (patch)
treed7f7e23f43a461d526d143cd4e4e0ba7021a7c4e /crates/ra_hir/src/ty/tests.rs
parent64b718bff7df788bfe6e8e2dce24b20faf9be235 (diff)
projection over std::ops::Try::Ok to infer try/?
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs37
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]
24fn infer_try() {
25 let (mut db, pos) = MockDatabase::with_position(
26 r#"
27//- /main.rs
28enum Result<O, E> {
29 Ok(O),
30 Err(E)
31}
32
33impl<O, E> ::std::ops::Try for Result<O, E> {
34 type Ok = O;
35 type Error = E;
36}
37fn test() {
38 let r: Result<i32, u64> = Result::Ok(1);
39 let v = r?;
40 v<|>;
41}
42
43//- /lib.rs
44mod 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]
24fn infer_for_loop() { 60fn 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]
60fn infer_basics() { 97fn infer_basics() {
61 assert_snapshot_matches!( 98 assert_snapshot_matches!(