From c098a3fda52ef0b02188abfa91adcd67e82c0c02 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 9 Feb 2019 22:03:01 +0100 Subject: Add comment and mark --- crates/ra_hir/src/marks.rs | 1 + crates/ra_hir/src/ty.rs | 10 ++++++++-- crates/ra_hir/src/ty/tests.rs | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/ra_hir/src/marks.rs b/crates/ra_hir/src/marks.rs index d704c3adb..aba0c9968 100644 --- a/crates/ra_hir/src/marks.rs +++ b/crates/ra_hir/src/marks.rs @@ -3,4 +3,5 @@ test_utils::marks!( item_map_enum_importing type_var_cycles_resolve_completely type_var_cycles_resolve_as_possible + type_var_resolves_to_int_var ); diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 5d5bde305..7203a8a10 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -1003,8 +1003,13 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { /// otherwise, return ty. fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> { let mut ty = Cow::Borrowed(ty); - for _ in 0..3 { - // the type variable could resolve to a int/float variable + // The type variable could resolve to a int/float variable. Hence try + // resolving up to three times; each type of variable shouldn't occur + // more than once + for i in 0..3 { + if i > 0 { + tested_by!(type_var_resolves_to_int_var); + } match &*ty { Ty::Infer(tv) => { let inner = tv.to_inner(); @@ -1019,6 +1024,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { _ => return ty, } } + log::error!("Inference variable still not resolved: {:?}", ty); ty } diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 8cc771084..e64fd2749 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -652,6 +652,7 @@ fn write() { #[test] fn infer_std_crash_2() { + covers!(type_var_resolves_to_int_var); // caused "equating two type variables, ...", taken from std check_inference( "infer_std_crash_2", -- cgit v1.2.3