From 690206c74ac9b7ee9f13788c900f5a1f86b9add2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 28 Oct 2015 16:42:47 -0400 Subject: [PATCH] Do some slight refactoring, leave the rest for #29436 --- .../middle/infer/region_inference/mod.rs | 66 +++++++------------ 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 947815951df..279ab9d5f30 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -47,6 +47,8 @@ pub enum Constraint { ConstrainRegSubVar(Region, RegionVid), // Region variable is subregion of concrete region + // + // FIXME(#29436) -- should be remove in favor of a Verify ConstrainVarSubReg(RegionVid, Region), } @@ -972,6 +974,7 @@ fn expand_node(&self, } } + // FIXME(#29436) -- this fn would just go away if we removed ConstrainVarSubReg fn contraction(&self, free_regions: &FreeRegionMap, var_data: &mut [VarData]) { @@ -983,50 +986,31 @@ fn contraction(&self, .unwrap() ); match *constraint { - ConstrainRegSubVar(..) | - ConstrainVarSubVar(..) => { - // Expansion will ensure that these constraints hold. Ignore. - false - } - ConstrainVarSubReg(a_vid, b_region) => { - let a_data = &mut var_data[a_vid.index as usize]; - self.contract_node(free_regions, a_vid, a_data, b_region) - } + ConstrainRegSubVar(..) | + ConstrainVarSubVar(..) => { + // Expansion will ensure that these constraints hold. Ignore. + } + ConstrainVarSubReg(a_vid, b_region) => { + let a_data = &mut var_data[a_vid.index as usize]; + debug!("contraction: {:?} == {:?}, {:?}", a_vid, a_data.value, b_region); + + let a_region = match a_data.value { + ErrorValue => return false, + Value(a_region) => a_region, + }; + + if !free_regions.is_subregion_of(self.tcx, a_region, b_region) { + debug!("Setting {:?} to ErrorValue: {:?} not subregion of {:?}", + a_vid, + a_region, + b_region); + a_data.value = ErrorValue; + } + } } - }) - } - - fn contract_node(&self, - free_regions: &FreeRegionMap, - a_vid: RegionVid, - a_data: &mut VarData, - b_region: Region) - -> bool { - debug!("contract_node({:?} == {:?}, {:?})", - a_vid, a_data.value, b_region); - - return match a_data.value { - ErrorValue => false, // no change - Value(a_region) => check_node(self, free_regions, a_vid, a_data, a_region, b_region), - }; - fn check_node(this: &RegionVarBindings, - free_regions: &FreeRegionMap, - a_vid: RegionVid, - a_data: &mut VarData, - a_region: Region, - b_region: Region) - -> bool - { - if !free_regions.is_subregion_of(this.tcx, a_region, b_region) { - debug!("Setting {:?} to ErrorValue: {:?} not subregion of {:?}", - a_vid, - a_region, - b_region); - a_data.value = ErrorValue; - } false - } + }) } fn collect_concrete_region_errors(&self, -- 2.44.0