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/snapshots/tests__infer_struct.snap6
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap23
-rw-r--r--crates/ra_hir/src/ty/tests.rs21
3 files changed, 47 insertions, 3 deletions
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
index 294186b06..32f1fa108 100644
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
@@ -1,19 +1,19 @@
1--- 1---
2created: "2019-02-17T16:16:58.863630956Z" 2created: "2019-02-20T21:31:12.910924715Z"
3creator: [email protected] 3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs 4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result" 5expression: "&result"
6--- 6---
7[72; 154) '{ ...a.c; }': () 7[72; 154) '{ ...a.c; }': ()
8[82; 83) 'c': C 8[82; 83) 'c': C
9[86; 87) 'C': fn C(usize) -> C 9[86; 87) 'C': C(usize) -> C
10[86; 90) 'C(1)': C 10[86; 90) 'C(1)': C
11[88; 89) '1': usize 11[88; 89) '1': usize
12[96; 97) 'B': B 12[96; 97) 'B': B
13[107; 108) 'a': A 13[107; 108) 'a': A
14[114; 133) 'A { b:...C(1) }': A 14[114; 133) 'A { b:...C(1) }': A
15[121; 122) 'B': B 15[121; 122) 'B': B
16[127; 128) 'C': fn C(usize) -> C 16[127; 128) 'C': C(usize) -> C
17[127; 131) 'C(1)': C 17[127; 131) 'C(1)': C
18[129; 130) '1': usize 18[129; 130) '1': usize
19[139; 140) 'a': A 19[139; 140) 'a': A
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap
new file mode 100644
index 000000000..783795cfd
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap
@@ -0,0 +1,23 @@
1---
2created: "2019-02-20T21:31:12.911275141Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[77; 185) '{ ...one; }': ()
8[83; 84) 'A': A<i32>(T) -> A<T>
9[83; 88) 'A(42)': A<i32>
10[85; 87) '42': i32
11[94; 95) 'A': A<u128>(T) -> A<T>
12[94; 103) 'A(42u128)': A<u128>
13[96; 102) '42u128': u128
14[109; 113) 'Some': Some<&str>(T) -> Option<T>
15[109; 118) 'Some("x")': Option<&str>
16[114; 117) '"x"': &str
17[124; 136) 'Option::Some': Some<&str>(T) -> Option<T>
18[124; 141) 'Option...e("x")': Option<&str>
19[137; 140) '"x"': &str
20[147; 151) 'None': Option<[unknown]>
21[161; 162) 'x': Option<i64>
22[178; 182) 'None': Option<i64>
23
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index fee6ed0b3..f04e9109c 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -466,6 +466,27 @@ fn test(a1: A<u32>, i: i32) {
466} 466}
467 467
468#[test] 468#[test]
469fn infer_tuple_struct_generics() {
470 check_inference(
471 "infer_tuple_struct_generics",
472 r#"
473struct A<T>(T);
474enum Option<T> { Some(T), None };
475use Option::*;
476
477fn test() {
478 A(42);
479 A(42u128);
480 Some("x");
481 Option::Some("x");
482 None;
483 let x: Option<i64> = None;
484}
485"#,
486 );
487}
488
489#[test]
469fn infer_generics_in_patterns() { 490fn infer_generics_in_patterns() {
470 check_inference( 491 check_inference(
471 "infer_generics_in_patterns", 492 "infer_generics_in_patterns",