diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index aacd94a26..fe5e89f2d 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_for_loop() { | ||
25 | let (mut db, pos) = MockDatabase::with_position( | ||
26 | r#" | ||
27 | //- /main.rs | ||
28 | struct Vec<T> {} | ||
29 | impl<T> Vec<T> { | ||
30 | fn new() -> Self { Vec {} } | ||
31 | fn push(&mut self, t: T) { } | ||
32 | } | ||
33 | |||
34 | impl<T> ::std::iter::IntoIterator for Vec<T> { | ||
35 | type Item=T; | ||
36 | } | ||
37 | fn test() { | ||
38 | let v = Vec::new(); | ||
39 | v.push("foo"); | ||
40 | for x in v { | ||
41 | x<|>; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | //- /lib.rs | ||
46 | mod iter { | ||
47 | trait IntoIterator { | ||
48 | type Item; | ||
49 | } | ||
50 | } | ||
51 | "#, | ||
52 | ); | ||
53 | db.set_crate_graph_from_fixture(crate_graph! { | ||
54 | "main": ("/main.rs", ["std"]), | ||
55 | "std": ("/lib.rs", []), | ||
56 | }); | ||
57 | assert_eq!("&str", type_at_pos(&db, pos)); | ||
58 | } | ||
59 | #[test] | ||
24 | fn infer_basics() { | 60 | fn infer_basics() { |
25 | assert_snapshot_matches!( | 61 | assert_snapshot_matches!( |
26 | infer(r#" | 62 | infer(r#" |