diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/pattern.txt | 15 |
2 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index fc1e5b09c..a55551cbb 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -362,11 +362,22 @@ fn test(x: &str, y: isize) { | |||
362 | fn infer_pattern() { | 362 | fn infer_pattern() { |
363 | check_inference( | 363 | check_inference( |
364 | r#" | 364 | r#" |
365 | enum E { A { x: usize }, B } | ||
366 | |||
365 | fn test(x: &i32) { | 367 | fn test(x: &i32) { |
366 | let y = x; | 368 | let y = x; |
367 | let &z = x; | 369 | let &z = x; |
368 | let a = z; | 370 | let a = z; |
369 | let (c, d) = (1, "hello"); | 371 | let (c, d) = (1, "hello"); |
372 | |||
373 | let e = E::A { x: 3 }; | ||
374 | if let E::A { x: x } = e { | ||
375 | x | ||
376 | }; | ||
377 | match e { | ||
378 | E::A { x } => x, | ||
379 | E::B => 1, | ||
380 | }; | ||
370 | } | 381 | } |
371 | "#, | 382 | "#, |
372 | "pattern.txt", | 383 | "pattern.txt", |
diff --git a/crates/ra_hir/src/ty/tests/data/pattern.txt b/crates/ra_hir/src/ty/tests/data/pattern.txt new file mode 100644 index 000000000..cca521833 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/pattern.txt | |||
@@ -0,0 +1,15 @@ | |||
1 | [9; 10) 'x': &i32 | ||
2 | [18; 98) '{ ...o"); }': () | ||
3 | [28; 29) 'y': &i32 | ||
4 | [32; 33) 'x': &i32 | ||
5 | [43; 45) '&z': &i32 | ||
6 | [44; 45) 'z': i32 | ||
7 | [48; 49) 'x': &i32 | ||
8 | [59; 60) 'a': i32 | ||
9 | [63; 64) 'z': i32 | ||
10 | [74; 80) '(c, d)': (i32, &str) | ||
11 | [75; 76) 'c': i32 | ||
12 | [78; 79) 'd': &str | ||
13 | [83; 95) '(1, "hello")': (i32, &str) | ||
14 | [84; 85) '1': i32 | ||
15 | [87; 94) '"hello"': &str | ||