aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs26
-rw-r--r--crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt17
2 files changed, 43 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index c590a09db..06e32df59 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -439,6 +439,32 @@ fn test(a1: A<u32>, i: i32) {
439} 439}
440 440
441#[test] 441#[test]
442fn infer_generics_in_patterns() {
443 check_inference(
444 r#"
445struct A<T> {
446 x: T,
447}
448
449enum Option<T> {
450 Some(T),
451 None,
452}
453
454fn test(a1: A<u32>, o: Option<u64>) {
455 let A { x: x2 } = a1;
456 let A::<i64> { x: x3 } = A { x: 1 };
457 match o {
458 Option::Some(t) => t,
459 _ => 1,
460 };
461}
462"#,
463 "generics_in_patterns.txt",
464 );
465}
466
467#[test]
442fn infer_function_generics() { 468fn infer_function_generics() {
443 check_inference( 469 check_inference(
444 r#" 470 r#"
diff --git a/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt b/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt
new file mode 100644
index 000000000..1b01ef19e
--- /dev/null
+++ b/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt
@@ -0,0 +1,17 @@
1[79; 81) 'a1': A<u32>
2[91; 92) 'o': Option<u64>
3[107; 244) '{ ... }; }': ()
4[117; 128) 'A { x: x2 }': A<u32>
5[124; 126) 'x2': u32
6[131; 133) 'a1': A<u32>
7[143; 161) 'A::<i6...: x3 }': A<i64>
8[157; 159) 'x3': i64
9[164; 174) 'A { x: 1 }': A<i64>
10[171; 172) '1': i64
11[180; 241) 'match ... }': u64
12[186; 187) 'o': Option<u64>
13[198; 213) 'Option::Some(t)': Option<u64>
14[211; 212) 't': u64
15[217; 218) 't': u64
16[228; 229) '_': Option<u64>
17[233; 234) '1': u64