From 77f92674f9a2ea8e8cd303d15710621a4f7839cb Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 26 Jan 2019 23:48:01 +0100 Subject: Handle cycles in type vars This might be the cause of #587. --- crates/ra_hir/src/ty/tests.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e1165f682..e34daa0f7 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -562,6 +562,33 @@ fn quux() { ); } +#[test] +fn recursive_vars() { + check_inference( + "recursive_vars", + r#" +fn test() { + let y = unknown; + [y, &y]; +} +"#, + ); +} + +#[test] +fn recursive_vars_2() { + check_inference( + "recursive_vars_2", + r#" +fn test() { + let x = unknown; + let y = unknown; + [(x, y), (&y, &x)]; +} +"#, + ); +} + fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.parse(file_id); -- cgit v1.2.3