@@ -185,6 +185,9 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> {
185
185
in_cycle : Cell < bool > ,
186
186
187
187
previous : TraitObligationStackList < ' prev , ' tcx > ,
188
+
189
+ /// Number of parent frames plus one -- so the topmost frame has depth 1.
190
+ depth : usize ,
188
191
}
189
192
190
193
#[ derive( Clone , Default ) ]
@@ -662,8 +665,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
662
665
obligation : & PredicateObligation < ' tcx > ,
663
666
) -> Result < EvaluationResult , OverflowError > {
664
667
self . evaluation_probe ( |this| {
665
- this. evaluate_predicate_recursively ( TraitObligationStackList :: empty ( ) ,
666
- obligation. clone ( ) )
668
+ this. evaluate_predicate_recursively (
669
+ TraitObligationStackList :: empty ( ) ,
670
+ obligation. clone ( ) ,
671
+ )
667
672
} )
668
673
}
669
674
@@ -3743,6 +3748,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
3743
3748
fresh_trait_ref,
3744
3749
in_cycle : Cell :: new ( false ) ,
3745
3750
previous : previous_stack,
3751
+ depth : previous_stack. depth ( ) + 1 ,
3746
3752
}
3747
3753
}
3748
3754
@@ -3957,6 +3963,14 @@ impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
3957
3963
fn head ( & self ) -> Option < & ' o TraitObligationStack < ' o , ' tcx > > {
3958
3964
self . head
3959
3965
}
3966
+
3967
+ fn depth ( & self ) -> usize {
3968
+ if let Some ( head) = self . head {
3969
+ head. depth
3970
+ } else {
3971
+ 0
3972
+ }
3973
+ }
3960
3974
}
3961
3975
3962
3976
impl < ' o , ' tcx > Iterator for TraitObligationStackList < ' o , ' tcx > {
0 commit comments