@@ -25,33 +25,41 @@ fn infer_try() {
25
25
let ( mut db, pos) = MockDatabase :: with_position (
26
26
r#"
27
27
//- /main.rs
28
- enum Result<O, E> {
29
- Ok(O),
30
- Err(E)
31
- }
32
28
33
- impl<O, E> ::std::ops::Try for Result<O, E> {
34
- type Ok = O;
35
- type Error = E;
36
- }
37
29
fn test() {
38
30
let r: Result<i32, u64> = Result::Ok(1);
39
31
let v = r?;
40
32
v<|>;
41
33
}
42
34
43
- //- /lib.rs
35
+ //- /std.rs
36
+
37
+ #[prelude_import] use ops::*;
44
38
mod ops {
45
39
trait Try {
46
40
type Ok;
47
41
type Error;
48
42
}
49
43
}
44
+
45
+ #[prelude_import] use result::*;
46
+ mod result {
47
+ enum Result<O, E> {
48
+ Ok(O),
49
+ Err(E)
50
+ }
51
+
52
+ impl<O, E> crate::ops::Try for Result<O, E> {
53
+ type Ok = O;
54
+ type Error = E;
55
+ }
56
+ }
57
+
50
58
"# ,
51
59
) ;
52
60
db. set_crate_graph_from_fixture ( crate_graph ! {
53
61
"main" : ( "/main.rs" , [ "std" ] ) ,
54
- "std" : ( "/lib .rs" , [ ] ) ,
62
+ "std" : ( "/std .rs" , [ ] ) ,
55
63
} ) ;
56
64
assert_eq ! ( "i32" , type_at_pos( & db, pos) ) ;
57
65
}
@@ -61,15 +69,9 @@ fn infer_for_loop() {
61
69
let ( mut db, pos) = MockDatabase :: with_position (
62
70
r#"
63
71
//- /main.rs
64
- struct Vec<T> {}
65
- impl<T> Vec<T> {
66
- fn new() -> Self { Vec {} }
67
- fn push(&mut self, t: T) { }
68
- }
69
72
70
- impl<T> ::std::iter::IntoIterator for Vec<T> {
71
- type Item=T;
72
- }
73
+ use std::collections::Vec;
74
+
73
75
fn test() {
74
76
let v = Vec::new();
75
77
v.push("foo");
@@ -78,17 +80,31 @@ fn test() {
78
80
}
79
81
}
80
82
81
- //- /lib.rs
83
+ //- /std.rs
84
+
85
+ #[prelude_import] use iter::*;
82
86
mod iter {
83
87
trait IntoIterator {
84
88
type Item;
85
89
}
86
90
}
91
+
92
+ mod collections {
93
+ struct Vec<T> {}
94
+ impl<T> Vec<T> {
95
+ fn new() -> Self { Vec {} }
96
+ fn push(&mut self, t: T) { }
97
+ }
98
+
99
+ impl<T> crate::iter::IntoIterator for Vec<T> {
100
+ type Item=T;
101
+ }
102
+ }
87
103
"# ,
88
104
) ;
89
105
db. set_crate_graph_from_fixture ( crate_graph ! {
90
106
"main" : ( "/main.rs" , [ "std" ] ) ,
91
- "std" : ( "/lib .rs" , [ ] ) ,
107
+ "std" : ( "/std .rs" , [ ] ) ,
92
108
} ) ;
93
109
assert_eq ! ( "&str" , type_at_pos( & db, pos) ) ;
94
110
}
0 commit comments