Skip to content

Commit c098a3f

Browse files
committed
Add comment and mark
1 parent a28d4be commit c098a3f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

crates/ra_hir/src/marks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ test_utils::marks!(
33
item_map_enum_importing
44
type_var_cycles_resolve_completely
55
type_var_cycles_resolve_as_possible
6+
type_var_resolves_to_int_var
67
);

crates/ra_hir/src/ty.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,13 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
10031003
/// otherwise, return ty.
10041004
fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> {
10051005
let mut ty = Cow::Borrowed(ty);
1006-
for _ in 0..3 {
1007-
// the type variable could resolve to a int/float variable
1006+
// The type variable could resolve to a int/float variable. Hence try
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+
}
10081013
match &*ty {
10091014
Ty::Infer(tv) => {
10101015
let inner = tv.to_inner();
@@ -1019,6 +1024,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
10191024
_ => return ty,
10201025
}
10211026
}
1027+
log::error!("Inference variable still not resolved: {:?}", ty);
10221028
ty
10231029
}
10241030

crates/ra_hir/src/ty/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ fn write() {
652652

653653
#[test]
654654
fn infer_std_crash_2() {
655+
covers!(type_var_resolves_to_int_var);
655656
// caused "equating two type variables, ...", taken from std
656657
check_inference(
657658
"infer_std_crash_2",

0 commit comments

Comments
 (0)