Rework find_super_trait_path to protect against cycles

This commit is contained in:
Florian Diebold
2020-02-22 13:14:39 +01:00
parent c200025794
commit 3e106c77ff
5 changed files with 74 additions and 23 deletions

View File

@@ -814,13 +814,16 @@ pub trait TypeWalk {
where
Self: Sized,
{
self.fold_binders(&mut |ty, binders| match ty {
Ty::Bound(idx) if idx as usize >= binders => {
assert!(idx as i32 >= -n);
Ty::Bound((idx as i32 + n) as u32)
}
ty => ty,
}, 0)
self.fold_binders(
&mut |ty, binders| match ty {
Ty::Bound(idx) if idx as usize >= binders => {
assert!(idx as i32 >= -n);
Ty::Bound((idx as i32 + n) as u32)
}
ty => ty,
},
0,
)
}
}