diff options
| author | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2024-07-01 11:51:28 +0200 | 
|---|---|---|
| committer | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2024-07-01 11:52:38 +0200 | 
| commit | 9be3a3d761060a047667226bd742346f8c25c6cf (patch) | |
| tree | f5dba21c82e771c33f7f463a11f0e8c5457ed7ad | |
| parent | eea5cf87b29c1ab4b2dc50a1a6dca87ec3628b19 (diff) | |
| download | rust-9be3a3d761060a047667226bd742346f8c25c6cf.tar.gz rust-9be3a3d761060a047667226bd742346f8c25c6cf.zip | |
Add description for why this PR was made
| -rw-r--r-- | compiler/rustc_borrowck/src/constraints/mod.rs | 28 | 
1 files changed, 25 insertions, 3 deletions
| diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs index 9a76539f579..bb2fc3b67e9 100644 --- a/compiler/rustc_borrowck/src/constraints/mod.rs +++ b/compiler/rustc_borrowck/src/constraints/mod.rs @@ -66,18 +66,40 @@ impl<'tcx> OutlivesConstraintSet<'tcx> { }) } - /// This method handles universe errors by rewriting the constraint + /// This method handles Universe errors 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's universe is smaller than X's and A is a placeholder, - /// add A: 'static. + /// 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::has_incompatible_universes()`]. /// + /// This edge case used to be handled during constraint propagation + /// by iterating over the strongly connected components in the constraint + /// graph while maintaining a set of bookkeeping mappings similar + /// to what is stored in `RegionTracker` and manually adding 'sttaic as + /// needed. + /// + /// 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: + /// + /// 1. Implementing Polonius is difficult enough without also + /// handling them. + /// 2. 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 - /// `IllegalUniverse` constraint. + /// internal `IllegalUniverse` constraint. #[instrument(skip(self, universal_regions, definitions))] pub(crate) fn add_outlives_static( &mut self, | 
