pub(crate) fn compute_sccs_applying_placeholder_outlives_constraints<'tcx>(
constraints: MirTypeckRegionConstraints<'tcx>,
universal_region_relations: &Frozen<UniversalRegionRelations<'tcx>>,
infcx: &BorrowckInferCtxt<'tcx>,
) -> LoweredConstraints<'tcx>
Expand description
This method handles placeholders by rewriting the constraint graph. For each strongly connected component in the constraint graph such that there is a series of constraints A: B: C: … : X where A contains a placeholder whose universe cannot be named by X, add a constraint that A: ’static. This is a safe upper bound in the face of borrow checker/trait solver limitations that will eventually go away.
For a more precise definition, see the documentation for
RegionTracker
and its methods!
This edge case used to be handled during constraint propagation. It was rewritten as part of the Polonius project with the goal of moving higher-kindedness concerns out of the path of the borrow checker, for two reasons:
- Implementing Polonius is difficult enough without also handling them.
- The long-term goal is to handle higher-kinded concerns in the trait solver, where they belong. This avoids logic duplication and allows future trait solvers to compute better bounds than for example our “must outlive ’static” here.
This code is a stop-gap measure in preparation for the future trait solver.
Every constraint added by this method is an internal IllegalUniverse
constraint.