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.rs32
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
4use ra_db::{SourceDatabase, salsa::Database}; 4use ra_db::{SourceDatabase, salsa::Database};
5use ra_syntax::ast::{self, AstNode}; 5use ra_syntax::ast::{self, AstNode};
6use test_utils::covers;
6 7
7use crate::{ 8use crate::{
8 source_binder, 9 source_binder,
@@ -562,6 +563,37 @@ fn quux() {
562 ); 563 );
563} 564}
564 565
566#[test]
567fn 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#"
573fn test() {
574 let y = unknown;
575 [y, &y];
576}
577"#,
578 );
579}
580
581#[test]
582fn 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#"
588fn test() {
589 let x = unknown;
590 let y = unknown;
591 [(x, y), (&y, &x)];
592}
593"#,
594 );
595}
596
565fn infer(content: &str) -> String { 597fn 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);