aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap39
-rw-r--r--crates/ra_hir/src/ty/tests.rs32
2 files changed, 71 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap
new file mode 100644
index 000000000..99df39fc2
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap
@@ -0,0 +1,39 @@
1---
2created: "2019-02-16T19:27:11.573533475Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[74; 78) 'self': A<[unknown], [unknown]>
8[85; 107) '{ ... }': [unknown]
9[95; 99) 'self': A<[unknown], [unknown]>
10[95; 101) 'self.x': [unknown]
11[117; 121) 'self': A<[unknown], [unknown]>
12[128; 150) '{ ... }': [unknown]
13[138; 142) 'self': A<[unknown], [unknown]>
14[138; 144) 'self.y': [unknown]
15[163; 167) 'self': A<[unknown], [unknown]>
16[169; 170) 't': T
17[188; 223) '{ ... }': ([unknown], [unknown], T)
18[198; 217) '(self.....y, t)': ([unknown], [unknown], T)
19[199; 203) 'self': A<[unknown], [unknown]>
20[199; 205) 'self.x': [unknown]
21[207; 211) 'self': A<[unknown], [unknown]>
22[207; 213) 'self.y': [unknown]
23[215; 216) 't': T
24[245; 342) '{ ...(1); }': ()
25[255; 256) 'a': A<u64, i64>
26[259; 281) 'A { x:...1i64 }': A<u64, i64>
27[266; 270) '1u64': u64
28[275; 279) '1i64': i64
29[287; 288) 'a': A<u64, i64>
30[287; 292) 'a.x()': [unknown]
31[298; 299) 'a': A<u64, i64>
32[298; 303) 'a.y()': [unknown]
33[309; 310) 'a': A<u64, i64>
34[309; 319) 'a.z(1i128)': ([unknown], [unknown], i128)
35[313; 318) '1i128': i128
36[325; 326) 'a': A<u64, i64>
37[325; 339) 'a.z::<u128>(1)': ([unknown], [unknown], i32)
38[337; 338) '1': i32
39
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]
510fn infer_impl_generics() {
511 check_inference(
512 "infer_impl_generics",
513 r#"
514struct A<T1, T2> {
515 x: T1,
516 y: T2,
517}
518impl<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
530fn 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]
510fn infer_generic_chain() { 542fn infer_generic_chain() {
511 check_inference( 543 check_inference(
512 "infer_generic_chain", 544 "infer_generic_chain",