diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/marks.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 10 | ||||
-rw-r--r-- | 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!( | |||
3 | item_map_enum_importing | 3 | item_map_enum_importing |
4 | type_var_cycles_resolve_completely | 4 | type_var_cycles_resolve_completely |
5 | type_var_cycles_resolve_as_possible | 5 | type_var_cycles_resolve_as_possible |
6 | type_var_resolves_to_int_var | ||
6 | ); | 7 | ); |
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> { | |||
1003 | /// otherwise, return ty. | 1003 | /// otherwise, return ty. |
1004 | fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> { | 1004 | fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> { |
1005 | let mut ty = Cow::Borrowed(ty); | 1005 | let mut ty = Cow::Borrowed(ty); |
1006 | for _ in 0..3 { | 1006 | // The type variable could resolve to a int/float variable. Hence try |
1007 | // the type variable could resolve to a int/float variable | 1007 | // resolving up to three times; each type of variable shouldn't occur |
1008 | // more than once | ||
1009 | for i in 0..3 { | ||
1010 | if i > 0 { | ||
1011 | tested_by!(type_var_resolves_to_int_var); | ||
1012 | } | ||
1008 | match &*ty { | 1013 | match &*ty { |
1009 | Ty::Infer(tv) => { | 1014 | Ty::Infer(tv) => { |
1010 | let inner = tv.to_inner(); | 1015 | let inner = tv.to_inner(); |
@@ -1019,6 +1024,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1019 | _ => return ty, | 1024 | _ => return ty, |
1020 | } | 1025 | } |
1021 | } | 1026 | } |
1027 | log::error!("Inference variable still not resolved: {:?}", ty); | ||
1022 | ty | 1028 | ty |
1023 | } | 1029 | } |
1024 | 1030 | ||
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() { | |||
652 | 652 | ||
653 | #[test] | 653 | #[test] |
654 | fn infer_std_crash_2() { | 654 | fn infer_std_crash_2() { |
655 | covers!(type_var_resolves_to_int_var); | ||
655 | // caused "equating two type variables, ...", taken from std | 656 | // caused "equating two type variables, ...", taken from std |
656 | check_inference( | 657 | check_inference( |
657 | "infer_std_crash_2", | 658 | "infer_std_crash_2", |