Skip to content

Commit 726bdec

Browse files
committed
Improve comment
1 parent dadd7bb commit 726bdec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc/traits/select.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,15 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
10951095
.insert(trait_ref, WithDepNode::new(dep_node, result));
10961096
}
10971097

1098-
// Due to caching of projection results, it's possible for a subobligation
1098+
// For various reasons, it's possible for a subobligation
10991099
// to have a *lower* recursion_depth than the obligation used to create it.
1100+
// Projection sub-obligations may be returned from the projection cache,
1101+
// which results in obligations with an 'old' recursion_depth.
1102+
// Additionally, methods like ty::wf::obligations and
1103+
// InferCtxt.subtype_predicate produce subobligations without
1104+
// taking in a 'parent' depth, causing the generated subobligations
1105+
// to have a recursion_depth of 0
1106+
//
11001107
// To ensure that obligation_depth never decreasees, we force all subobligations
11011108
// to have at least the depth of the original obligation.
11021109
fn add_depth<T: 'cx, I: Iterator<Item = &'cx mut Obligation<'tcx, T>>>(&self, it: I,

0 commit comments

Comments
 (0)