diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e1165f682..f74d6f5ea 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -3,6 +3,7 @@ use std::fmt::Write; | |||
3 | 3 | ||
4 | use ra_db::{SourceDatabase, salsa::Database}; | 4 | use ra_db::{SourceDatabase, salsa::Database}; |
5 | use ra_syntax::ast::{self, AstNode}; | 5 | use ra_syntax::ast::{self, AstNode}; |
6 | use test_utils::covers; | ||
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | source_binder, | 9 | source_binder, |
@@ -562,6 +563,37 @@ fn quux() { | |||
562 | ); | 563 | ); |
563 | } | 564 | } |
564 | 565 | ||
566 | #[test] | ||
567 | fn recursive_vars() { | ||
568 | covers!(type_var_cycles_resolve_completely); | ||
569 | covers!(type_var_cycles_resolve_as_possible); | ||
570 | check_inference( | ||
571 | "recursive_vars", | ||
572 | r#" | ||
573 | fn test() { | ||
574 | let y = unknown; | ||
575 | [y, &y]; | ||
576 | } | ||
577 | "#, | ||
578 | ); | ||
579 | } | ||
580 | |||
581 | #[test] | ||
582 | fn recursive_vars_2() { | ||
583 | covers!(type_var_cycles_resolve_completely); | ||
584 | covers!(type_var_cycles_resolve_as_possible); | ||
585 | check_inference( | ||
586 | "recursive_vars_2", | ||
587 | r#" | ||
588 | fn test() { | ||
589 | let x = unknown; | ||
590 | let y = unknown; | ||
591 | [(x, y), (&y, &x)]; | ||
592 | } | ||
593 | "#, | ||
594 | ); | ||
595 | } | ||
596 | |||
565 | fn infer(content: &str) -> String { | 597 | fn infer(content: &str) -> String { |
566 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 598 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
567 | let source_file = db.parse(file_id); | 599 | let source_file = db.parse(file_id); |