diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests/traits.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 93c5f9a15..6139adb72 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -116,6 +116,70 @@ mod collections { | |||
116 | } | 116 | } |
117 | 117 | ||
118 | #[test] | 118 | #[test] |
119 | fn infer_ops_neg() { | ||
120 | let (db, pos) = TestDB::with_position( | ||
121 | r#" | ||
122 | //- /main.rs crate:main deps:std | ||
123 | |||
124 | struct Bar; | ||
125 | struct Foo; | ||
126 | |||
127 | impl std::ops::Neg for Bar { | ||
128 | type Output = Foo; | ||
129 | } | ||
130 | |||
131 | fn test() { | ||
132 | let a = Bar; | ||
133 | let b = -a; | ||
134 | b<|>; | ||
135 | } | ||
136 | |||
137 | //- /std.rs crate:std | ||
138 | |||
139 | #[prelude_import] use ops::*; | ||
140 | mod ops { | ||
141 | pub trait Neg { | ||
142 | type Output; | ||
143 | } | ||
144 | } | ||
145 | "#, | ||
146 | ); | ||
147 | assert_eq!("Foo", type_at_pos(&db, pos)); | ||
148 | } | ||
149 | |||
150 | #[test] | ||
151 | fn infer_ops_not() { | ||
152 | let (db, pos) = TestDB::with_position( | ||
153 | r#" | ||
154 | //- /main.rs crate:main deps:std | ||
155 | |||
156 | struct Bar; | ||
157 | struct Foo; | ||
158 | |||
159 | impl std::ops::Not for Bar { | ||
160 | type Output = Foo; | ||
161 | } | ||
162 | |||
163 | fn test() { | ||
164 | let a = Bar; | ||
165 | let b = !a; | ||
166 | b<|>; | ||
167 | } | ||
168 | |||
169 | //- /std.rs crate:std | ||
170 | |||
171 | #[prelude_import] use ops::*; | ||
172 | mod ops { | ||
173 | pub trait Not { | ||
174 | type Output; | ||
175 | } | ||
176 | } | ||
177 | "#, | ||
178 | ); | ||
179 | assert_eq!("Foo", type_at_pos(&db, pos)); | ||
180 | } | ||
181 | |||
182 | #[test] | ||
119 | fn infer_from_bound_1() { | 183 | fn infer_from_bound_1() { |
120 | assert_snapshot!( | 184 | assert_snapshot!( |
121 | infer(r#" | 185 | infer(r#" |