mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
introduce a stack depth
This commit is contained in:
parent
db1dfb2f36
commit
e64a7bf64b
@ -185,6 +185,9 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> {
|
|||||||
in_cycle: Cell<bool>,
|
in_cycle: Cell<bool>,
|
||||||
|
|
||||||
previous: TraitObligationStackList<'prev, 'tcx>,
|
previous: TraitObligationStackList<'prev, 'tcx>,
|
||||||
|
|
||||||
|
/// Number of parent frames plus one -- so the topmost frame has depth 1.
|
||||||
|
depth: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
@ -662,8 +665,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
) -> Result<EvaluationResult, OverflowError> {
|
) -> Result<EvaluationResult, OverflowError> {
|
||||||
self.evaluation_probe(|this| {
|
self.evaluation_probe(|this| {
|
||||||
this.evaluate_predicate_recursively(TraitObligationStackList::empty(),
|
this.evaluate_predicate_recursively(
|
||||||
obligation.clone())
|
TraitObligationStackList::empty(),
|
||||||
|
obligation.clone(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3743,6 +3748,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||||||
fresh_trait_ref,
|
fresh_trait_ref,
|
||||||
in_cycle: Cell::new(false),
|
in_cycle: Cell::new(false),
|
||||||
previous: previous_stack,
|
previous: previous_stack,
|
||||||
|
depth: previous_stack.depth() + 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3957,6 +3963,14 @@ impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
|
|||||||
fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
|
fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
|
||||||
self.head
|
self.head
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn depth(&self) -> usize {
|
||||||
|
if let Some(head) = self.head {
|
||||||
|
head.depth
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
|
impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
|
||||||
|
Loading…
Reference in New Issue
Block a user