@@ -209,6 +209,36 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
209209 . universal_region
210210 . extend ( universal_regions. universal_regions ( ) ) ;
211211 populate_polonius_move_facts ( all_facts, move_data, location_table, & body) ;
212+
213+ // Emit universal regions facts, and their relations, for Polonius.
214+ //
215+ // 1: universal regions are modeled in Polonius as a pair:
216+ // - the universal region vid itself.
217+ // - a "placeholder loan" associated to this universal region. Since they don't exist in
218+ // the `borrow_set`, their `BorrowIndex` are synthesized as the universal region index
219+ // added to the existing number of loans, as if they succeeded them in the set.
220+ //
221+ let borrow_count = borrow_set. borrows . len ( ) ;
222+ debug ! (
223+ "compute_regions: polonius placeholders, num_universals={}, borrow_count={}" ,
224+ universal_regions. len( ) ,
225+ borrow_count
226+ ) ;
227+
228+ for universal_region in universal_regions. universal_regions ( ) {
229+ let universal_region_idx = universal_region. index ( ) ;
230+ let placeholder_loan_idx = borrow_count + universal_region_idx;
231+ all_facts. placeholder . push ( ( universal_region, placeholder_loan_idx. into ( ) ) ) ;
232+ }
233+
234+ // 2: the universal region relations `outlives` constraints are emitted as
235+ // `known_subset` facts.
236+ for ( fr1, fr2) in universal_region_relations. known_outlives ( ) {
237+ if fr1 != fr2 {
238+ debug ! ( "compute_regions: emitting polonius `known_subset` fr1={:?}, fr2={:?}" , fr1, fr2) ;
239+ all_facts. known_subset . push ( ( * fr1, * fr2) ) ;
240+ }
241+ }
212242 }
213243
214244 // Create the region inference context, taking ownership of the
0 commit comments