aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs36
1 files changed, 22 insertions, 14 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index ff2c8b0d4..75fe2cc6e 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -359,31 +359,39 @@ fn test(x: &str, y: isize) {
359} 359}
360 360
361#[test] 361#[test]
362fn infer_pattern() { 362fn infer_simple_pattern() {
363 check_inference( 363 check_inference(
364 r#" 364 r#"
365enum E {
366 A { x: usize },
367 B
368}
369
370fn test(x: &i32) { 365fn test(x: &i32) {
371 let y = x; 366 let y = x;
372 let &z = x; 367 let &z = x;
373 let a = z; 368 let a = z;
374 let (c, d) = (1, "hello"); 369 let (c, d) = (1, "hello");
370}
371"#,
372 "pattern.txt",
373 );
374}
375
376#[test]
377fn infer_adt_pattern() {
378 check_inference(
379 r#"
380enum E {
381 A { x: usize },
382 B
383}
384
385struct S(u32, E);
375 386
387fn test() {
376 let e = E::A { x: 3 }; 388 let e = E::A { x: 3 };
377 if let E::A { x: x } = e { 389
378 x 390 let S(y, z) = foo;
379 }; 391 let E::A { x: new_var } = e;
380 match e {
381 E::A { x } => x,
382 E::B => 1,
383 };
384} 392}
385"#, 393"#,
386 "pattern.txt", 394 "adt_pattern.txt",
387 ); 395 );
388} 396}
389 397