@@ -978,13 +978,17 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
978
978
979
979
// Dorky hack to cause `dump_constraints` to only get called
980
980
// if debug mode is enabled:
981
- debug ! ( "----() End constraint listing {:?}---" , self . dump_constraints( ) ) ;
981
+ debug ! ( "----() End constraint listing (subject={}) {:?}---" ,
982
+ subject, self . dump_constraints( subject) ) ;
982
983
graphviz:: maybe_print_constraints_for ( self , subject) ;
983
984
985
+ let graph = self . construct_graph ( ) ;
986
+ self . expand_givens ( & graph) ;
984
987
self . expansion ( & mut var_data) ;
985
988
self . contraction ( & mut var_data) ;
986
989
let values =
987
990
self . extract_values_and_collect_conflicts ( & var_data[ ..] ,
991
+ & graph,
988
992
errors) ;
989
993
self . collect_concrete_region_errors ( & values, errors) ;
990
994
values
@@ -1003,13 +1007,38 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1003
1007
} ) . collect ( )
1004
1008
}
1005
1009
1006
- fn dump_constraints ( & self ) {
1007
- debug ! ( "----() Start constraint listing () ----" ) ;
1010
+ fn dump_constraints ( & self , subject : ast :: NodeId ) {
1011
+ debug ! ( "----() Start constraint listing (subject={}) () ----" , subject ) ;
1008
1012
for ( idx, ( constraint, _) ) in self . constraints . borrow ( ) . iter ( ) . enumerate ( ) {
1009
1013
debug ! ( "Constraint {} => {}" , idx, constraint. repr( self . tcx) ) ;
1010
1014
}
1011
1015
}
1012
1016
1017
+ fn expand_givens ( & self , graph : & RegionGraph ) {
1018
+ // Givens are a kind of horrible hack to account for
1019
+ // constraints like 'c <= '0 that are known to hold due to
1020
+ // closure signatures (see the comment above on the `givens`
1021
+ // field). They should go away. But until they do, the role
1022
+ // of this fn is to account for the transitive nature:
1023
+ //
1024
+ // Given 'c <= '0
1025
+ // and '0 <= '1
1026
+ // then 'c <= '1
1027
+
1028
+ let mut givens = self . givens . borrow_mut ( ) ;
1029
+ let seeds: Vec < _ > = givens. iter ( ) . cloned ( ) . collect ( ) ;
1030
+ for ( fr, vid) in seeds {
1031
+ let seed_index = NodeIndex ( vid. index as usize ) ;
1032
+ for succ_index in graph. depth_traverse ( seed_index) {
1033
+ let succ_index = succ_index. 0 as u32 ;
1034
+ if succ_index < self . num_vars ( ) {
1035
+ let succ_vid = RegionVid { index : succ_index } ;
1036
+ givens. insert ( ( fr, succ_vid) ) ;
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+
1013
1042
fn expansion ( & self , var_data : & mut [ VarData ] ) {
1014
1043
self . iterate_until_fixed_point ( "Expansion" , |constraint| {
1015
1044
debug ! ( "expansion: constraint={} origin={}" ,
@@ -1241,6 +1270,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1241
1270
fn extract_values_and_collect_conflicts (
1242
1271
& self ,
1243
1272
var_data : & [ VarData ] ,
1273
+ graph : & RegionGraph ,
1244
1274
errors : & mut Vec < RegionResolutionError < ' tcx > > )
1245
1275
-> Vec < VarValue >
1246
1276
{
@@ -1259,8 +1289,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1259
1289
// overlapping locations.
1260
1290
let mut dup_vec: Vec < _ > = repeat ( u32:: MAX ) . take ( self . num_vars ( ) as usize ) . collect ( ) ;
1261
1291
1262
- let mut opt_graph = None ;
1263
-
1264
1292
for idx in 0 ..self . num_vars ( ) as usize {
1265
1293
match var_data[ idx] . value {
1266
1294
Value ( _) => {
@@ -1296,11 +1324,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
1296
1324
starts to create problems we'll have to revisit
1297
1325
this portion of the code and think hard about it. =) */
1298
1326
1299
- if opt_graph. is_none ( ) {
1300
- opt_graph = Some ( self . construct_graph ( ) ) ;
1301
- }
1302
- let graph = opt_graph. as_ref ( ) . unwrap ( ) ;
1303
-
1304
1327
let node_vid = RegionVid { index : idx as u32 } ;
1305
1328
match var_data[ idx] . classification {
1306
1329
Expanding => {
0 commit comments