diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests/macros.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 0d9a35ce0..9c29a054e 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -266,3 +266,54 @@ fn main() { | |||
266 | "### | 266 | "### |
267 | ); | 267 | ); |
268 | } | 268 | } |
269 | |||
270 | #[test] | ||
271 | fn infer_derive_clone_simple() { | ||
272 | let (db, pos) = TestDB::with_position( | ||
273 | r#" | ||
274 | //- /main.rs crate:main deps:std | ||
275 | #[derive(Clone)] | ||
276 | struct S; | ||
277 | fn test() { | ||
278 | S.clone()<|>; | ||
279 | } | ||
280 | |||
281 | //- /lib.rs crate:std | ||
282 | #[prelude_import] | ||
283 | use clone::*; | ||
284 | mod clone { | ||
285 | trait Clone { | ||
286 | fn clone(&self) -> Self; | ||
287 | } | ||
288 | } | ||
289 | "#, | ||
290 | ); | ||
291 | assert_eq!("S", type_at_pos(&db, pos)); | ||
292 | } | ||
293 | |||
294 | #[test] | ||
295 | fn infer_derive_clone_with_params() { | ||
296 | let (db, pos) = TestDB::with_position( | ||
297 | r#" | ||
298 | //- /main.rs crate:main deps:std | ||
299 | #[derive(Clone)] | ||
300 | struct S; | ||
301 | #[derive(Clone)] | ||
302 | struct Wrapper<T>(T); | ||
303 | struct NonClone; | ||
304 | fn test() { | ||
305 | (Wrapper(S).clone(), Wrapper(NonClone).clone())<|>; | ||
306 | } | ||
307 | |||
308 | //- /lib.rs crate:std | ||
309 | #[prelude_import] | ||
310 | use clone::*; | ||
311 | mod clone { | ||
312 | trait Clone { | ||
313 | fn clone(&self) -> Self; | ||
314 | } | ||
315 | } | ||
316 | "#, | ||
317 | ); | ||
318 | assert_eq!("(Wrapper<S>, {unknown})", type_at_pos(&db, pos)); | ||
319 | } | ||