diff options
author | Florian Diebold <[email protected]> | 2019-02-16 19:29:36 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-02-16 22:06:41 +0000 |
commit | ccfc6b11c1e55e28e42bb79414d8349e8eb36086 (patch) | |
tree | ae5fb44e1c9de2aec7a1413e256399350c3d8923 /crates/ra_hir/src/ty/tests.rs | |
parent | edd4c1d8a6c270fe39ae881c23c722c658c87c32 (diff) |
Add a test for impl generics
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 203f1fe4d..1eca68dc5 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -507,6 +507,38 @@ fn test() { | |||
507 | } | 507 | } |
508 | 508 | ||
509 | #[test] | 509 | #[test] |
510 | fn infer_impl_generics() { | ||
511 | check_inference( | ||
512 | "infer_impl_generics", | ||
513 | r#" | ||
514 | struct A<T1, T2> { | ||
515 | x: T1, | ||
516 | y: T2, | ||
517 | } | ||
518 | impl<Y, X> A<X, Y> { | ||
519 | fn x(self) -> X { | ||
520 | self.x | ||
521 | } | ||
522 | fn y(self) -> Y { | ||
523 | self.y | ||
524 | } | ||
525 | fn z<T>(self, t: T) -> (X, Y, T) { | ||
526 | (self.x, self.y, t) | ||
527 | } | ||
528 | } | ||
529 | |||
530 | fn test() -> i128 { | ||
531 | let a = A { x: 1u64, y: 1i64 }; | ||
532 | a.x(); | ||
533 | a.y(); | ||
534 | a.z(1i128); | ||
535 | a.z::<u128>(1); | ||
536 | } | ||
537 | "#, | ||
538 | ); | ||
539 | } | ||
540 | |||
541 | #[test] | ||
510 | fn infer_generic_chain() { | 542 | fn infer_generic_chain() { |
511 | check_inference( | 543 | check_inference( |
512 | "infer_generic_chain", | 544 | "infer_generic_chain", |