@@ -984,14 +984,18 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
984
984
985
985
// Dorky hack to cause `dump_constraints` to only get called
986
986
// if debug mode is enabled:
987
- debug ! ( "----() End constraint listing {:?}---" , self . dump_constraints( ) ) ;
987
+ debug ! ( "----() End constraint listing (subject={}) {:?}---" ,
988
+ subject, self . dump_constraints( subject) ) ;
988
989
graphviz:: maybe_print_constraints_for ( self , subject) ;
989
990
991
+ let graph = self . construct_graph ( ) ;
992
+ self . expand_givens ( & graph) ;
990
993
self . expansion ( free_regions, & mut var_data) ;
991
994
self . contraction ( free_regions, & mut var_data) ;
992
995
let values =
993
996
self . extract_values_and_collect_conflicts ( free_regions,
994
- & var_data[ ..] ,
997
+ & var_data,
998
+ & graph,
995
999
errors) ;
996
1000
self . collect_concrete_region_errors ( free_regions, & values, errors) ;
997
1001
values
@@ -1010,13 +1014,38 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1010
1014
} ) . collect ( )
1011
1015
}
1012
1016
1013
- fn dump_constraints ( & self ) {
1014
- debug ! ( "----() Start constraint listing () ----" ) ;
1017
+ fn dump_constraints ( & self , subject : ast :: NodeId ) {
1018
+ debug ! ( "----() Start constraint listing (subject={}) () ----" , subject ) ;
1015
1019
for ( idx, ( constraint, _) ) in self . constraints . borrow ( ) . iter ( ) . enumerate ( ) {
1016
1020
debug ! ( "Constraint {} => {}" , idx, constraint. repr( self . tcx) ) ;
1017
1021
}
1018
1022
}
1019
1023
1024
+ fn expand_givens ( & self , graph : & RegionGraph ) {
1025
+ // Givens are a kind of horrible hack to account for
1026
+ // constraints like 'c <= '0 that are known to hold due to
1027
+ // closure signatures (see the comment above on the `givens`
1028
+ // field). They should go away. But until they do, the role
1029
+ // of this fn is to account for the transitive nature:
1030
+ //
1031
+ // Given 'c <= '0
1032
+ // and '0 <= '1
1033
+ // then 'c <= '1
1034
+
1035
+ let mut givens = self . givens . borrow_mut ( ) ;
1036
+ let seeds: Vec < _ > = givens. iter ( ) . cloned ( ) . collect ( ) ;
1037
+ for ( fr, vid) in seeds {
1038
+ let seed_index = NodeIndex ( vid. index as usize ) ;
1039
+ for succ_index in graph. depth_traverse ( seed_index) {
1040
+ let succ_index = succ_index. 0 as u32 ;
1041
+ if succ_index < self . num_vars ( ) {
1042
+ let succ_vid = RegionVid { index : succ_index } ;
1043
+ givens. insert ( ( fr, succ_vid) ) ;
1044
+ }
1045
+ }
1046
+ }
1047
+ }
1048
+
1020
1049
fn expansion ( & self , free_regions : & FreeRegionMap , var_data : & mut [ VarData ] ) {
1021
1050
self . iterate_until_fixed_point ( "Expansion" , |constraint| {
1022
1051
debug ! ( "expansion: constraint={} origin={}" ,
@@ -1258,6 +1287,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1258
1287
& self ,
1259
1288
free_regions : & FreeRegionMap ,
1260
1289
var_data : & [ VarData ] ,
1290
+ graph : & RegionGraph ,
1261
1291
errors : & mut Vec < RegionResolutionError < ' tcx > > )
1262
1292
-> Vec < VarValue >
1263
1293
{
@@ -1276,8 +1306,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1276
1306
// overlapping locations.
1277
1307
let mut dup_vec: Vec < _ > = repeat ( u32:: MAX ) . take ( self . num_vars ( ) as usize ) . collect ( ) ;
1278
1308
1279
- let mut opt_graph = None ;
1280
-
1281
1309
for idx in 0 ..self . num_vars ( ) as usize {
1282
1310
match var_data[ idx] . value {
1283
1311
Value ( _) => {
@@ -1313,11 +1341,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1313
1341
starts to create problems we'll have to revisit
1314
1342
this portion of the code and think hard about it. =) */
1315
1343
1316
- if opt_graph. is_none ( ) {
1317
- opt_graph = Some ( self . construct_graph ( ) ) ;
1318
- }
1319
- let graph = opt_graph. as_ref ( ) . unwrap ( ) ;
1320
-
1321
1344
let node_vid = RegionVid { index : idx as u32 } ;
1322
1345
match var_data[ idx] . classification {
1323
1346
Expanding => {
0 commit comments