@@ -978,13 +978,17 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
978978
979979 // Dorky hack to cause `dump_constraints` to only get called
980980 // 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) ) ;
982983 graphviz:: maybe_print_constraints_for ( self , subject) ;
983984
985+ let graph = self . construct_graph ( ) ;
986+ self . expand_givens ( & graph) ;
984987 self . expansion ( & mut var_data) ;
985988 self . contraction ( & mut var_data) ;
986989 let values =
987990 self . extract_values_and_collect_conflicts ( & var_data[ ..] ,
991+ & graph,
988992 errors) ;
989993 self . collect_concrete_region_errors ( & values, errors) ;
990994 values
@@ -1003,13 +1007,38 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
10031007 } ) . collect ( )
10041008 }
10051009
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 ) ;
10081012 for ( idx, ( constraint, _) ) in self . constraints . borrow ( ) . iter ( ) . enumerate ( ) {
10091013 debug ! ( "Constraint {} => {}" , idx, constraint. repr( self . tcx) ) ;
10101014 }
10111015 }
10121016
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+
10131042 fn expansion ( & self , var_data : & mut [ VarData ] ) {
10141043 self . iterate_until_fixed_point ( "Expansion" , |constraint| {
10151044 debug ! ( "expansion: constraint={} origin={}" ,
@@ -1241,6 +1270,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
12411270 fn extract_values_and_collect_conflicts (
12421271 & self ,
12431272 var_data : & [ VarData ] ,
1273+ graph : & RegionGraph ,
12441274 errors : & mut Vec < RegionResolutionError < ' tcx > > )
12451275 -> Vec < VarValue >
12461276 {
@@ -1259,8 +1289,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
12591289 // overlapping locations.
12601290 let mut dup_vec: Vec < _ > = repeat ( u32:: MAX ) . take ( self . num_vars ( ) as usize ) . collect ( ) ;
12611291
1262- let mut opt_graph = None ;
1263-
12641292 for idx in 0 ..self . num_vars ( ) as usize {
12651293 match var_data[ idx] . value {
12661294 Value ( _) => {
@@ -1296,11 +1324,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
12961324 starts to create problems we'll have to revisit
12971325 this portion of the code and think hard about it. =) */
12981326
1299- if opt_graph. is_none ( ) {
1300- opt_graph = Some ( self . construct_graph ( ) ) ;
1301- }
1302- let graph = opt_graph. as_ref ( ) . unwrap ( ) ;
1303-
13041327 let node_vid = RegionVid { index : idx as u32 } ;
13051328 match var_data[ idx] . classification {
13061329 Expanding => {
0 commit comments