diff --git a/crates/ra_hir/src/marks.rs b/crates/ra_hir/src/marks.rs index d704c3adb8a7..aba0c9968943 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 5d5bde3050b0..7203a8a10147 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 8cc771084fe9..e64fd2749630 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",