|
|
@@ -284,7 +284,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
AddVar(vid) => { |
|
|
|
let mut var_origins = self.var_origins.borrow_mut(); |
|
|
|
var_origins.pop().unwrap(); |
|
|
|
assert_eq!(var_origins.len(), vid.index as usize); |
|
|
|
assert_eq!(var_origins.len(), vid.index.widen_(0usize)); |
|
|
|
} |
|
|
|
AddConstraint(ref constraint) => { |
|
|
|
self.constraints.borrow_mut().remove(constraint); |
|
|
@@ -312,7 +312,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
pub fn num_vars(&self) -> u32 { |
|
|
|
let len = self.var_origins.borrow().len(); |
|
|
|
// enforce no overflow |
|
|
|
assert!(len as u32 as usize == len); |
|
|
|
assert!((len as u32).widen_(0usize) == len); |
|
|
|
len as u32 |
|
|
|
} |
|
|
|
|
|
|
@@ -557,7 +557,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
match *self.values.borrow() { |
|
|
|
None => { |
|
|
|
self.tcx.sess.span_bug( |
|
|
|
(*self.var_origins.borrow())[rid.index as usize].span(), |
|
|
|
(*self.var_origins.borrow())[rid.index.widen_(0usize)].span(), |
|
|
|
"attempt to resolve region variable before values have \ |
|
|
|
been computed!") |
|
|
|
} |
|
|
@@ -746,7 +746,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
|
|
|
|
(ReInfer(ReVar(v_id)), _) | (_, ReInfer(ReVar(v_id))) => { |
|
|
|
self.tcx.sess.span_bug( |
|
|
|
(*self.var_origins.borrow())[v_id.index as usize].span(), |
|
|
|
(*self.var_origins.borrow())[v_id.index.widen_(0usize)].span(), |
|
|
|
&format!("lub_concrete_regions invoked with \ |
|
|
|
non-concrete regions: {:?}, {:?}", |
|
|
|
a, |
|
|
@@ -854,7 +854,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
(ReInfer(ReVar(v_id)), _) | |
|
|
|
(_, ReInfer(ReVar(v_id))) => { |
|
|
|
self.tcx.sess.span_bug( |
|
|
|
(*self.var_origins.borrow())[v_id.index as usize].span(), |
|
|
|
(*self.var_origins.borrow())[v_id.index.widen_(0usize)].span(), |
|
|
|
&format!("glb_concrete_regions invoked with \ |
|
|
|
non-concrete regions: {:?}, {:?}", |
|
|
|
a, |
|
|
@@ -998,7 +998,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
} |
|
|
|
|
|
|
|
fn construct_var_data(&self) -> Vec<VarData> { |
|
|
|
(0..self.num_vars() as usize).map(|_| { |
|
|
|
(0..self.num_vars()).map(|_| { |
|
|
|
VarData { |
|
|
|
// All nodes are initially classified as contracting; during |
|
|
|
// the expansion phase, we will shift the classification for |
|
|
@@ -1027,14 +1027,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
.repr(self.tcx)); |
|
|
|
match *constraint { |
|
|
|
ConstrainRegSubVar(a_region, b_vid) => { |
|
|
|
let b_data = &mut var_data[b_vid.index as usize]; |
|
|
|
let b_data = &mut var_data[b_vid.index.widen_(0usize)]; |
|
|
|
self.expand_node(free_regions, a_region, b_vid, b_data) |
|
|
|
} |
|
|
|
ConstrainVarSubVar(a_vid, b_vid) => { |
|
|
|
match var_data[a_vid.index as usize].value { |
|
|
|
match var_data[a_vid.index.widen_(0usize)].value { |
|
|
|
NoValue | ErrorValue => false, |
|
|
|
Value(a_region) => { |
|
|
|
let b_node = &mut var_data[b_vid.index as usize]; |
|
|
|
let b_node = &mut var_data[b_vid.index.widen_(0usize)]; |
|
|
|
self.expand_node(free_regions, a_region, b_vid, b_node) |
|
|
|
} |
|
|
|
} |
|
|
@@ -1117,16 +1117,16 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
false |
|
|
|
} |
|
|
|
ConstrainVarSubVar(a_vid, b_vid) => { |
|
|
|
match var_data[b_vid.index as usize].value { |
|
|
|
match var_data[b_vid.index.widen_(0usize)].value { |
|
|
|
NoValue | ErrorValue => false, |
|
|
|
Value(b_region) => { |
|
|
|
let a_data = &mut var_data[a_vid.index as usize]; |
|
|
|
let a_data = &mut var_data[a_vid.index.widen_(0usize)]; |
|
|
|
self.contract_node(free_regions, a_vid, a_data, b_region) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ConstrainVarSubReg(a_vid, b_region) => { |
|
|
|
let a_data = &mut var_data[a_vid.index as usize]; |
|
|
|
let a_data = &mut var_data[a_vid.index.widen_(0usize)]; |
|
|
|
self.contract_node(free_regions, a_vid, a_data, b_region) |
|
|
|
} |
|
|
|
} |
|
|
@@ -1274,12 +1274,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
// idea is to report errors that derive from independent |
|
|
|
// regions of the graph, but not those that derive from |
|
|
|
// overlapping locations. |
|
|
|
let mut dup_vec: Vec<_> = repeat(u32::MAX).take(self.num_vars() as usize).collect(); |
|
|
|
let mut dup_vec: Vec<_> = repeat(u32::MAX).take(self.num_vars().widen()).collect(); |
|
|
|
|
|
|
|
let mut opt_graph = None; |
|
|
|
|
|
|
|
for idx in 0..self.num_vars() as usize { |
|
|
|
match var_data[idx].value { |
|
|
|
for idx in 0..self.num_vars() { |
|
|
|
match var_data[idx.widen_(0usize)].value { |
|
|
|
Value(_) => { |
|
|
|
/* Inference successful */ |
|
|
|
} |
|
|
@@ -1319,7 +1319,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
let graph = opt_graph.as_ref().unwrap(); |
|
|
|
|
|
|
|
let node_vid = RegionVid { index: idx as u32 }; |
|
|
|
match var_data[idx].classification { |
|
|
|
match var_data[idx.widen_(0usize)].classification { |
|
|
|
Expanding => { |
|
|
|
self.collect_error_for_expanding_node( |
|
|
|
free_regions, graph, var_data, &mut dup_vec, |
|
|
@@ -1335,7 +1335,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
(0..self.num_vars() as usize).map(|idx| var_data[idx].value).collect() |
|
|
|
(0..self.num_vars()).map(|idx| var_data[idx.widen_(0usize)].value).collect() |
|
|
|
} |
|
|
|
|
|
|
|
fn construct_graph(&self) -> RegionGraph { |
|
|
@@ -1353,17 +1353,17 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
for (constraint, _) in &*constraints { |
|
|
|
match *constraint { |
|
|
|
ConstrainVarSubVar(a_id, b_id) => { |
|
|
|
graph.add_edge(NodeIndex(a_id.index as usize), |
|
|
|
NodeIndex(b_id.index as usize), |
|
|
|
graph.add_edge(NodeIndex(a_id.index.widen()), |
|
|
|
NodeIndex(b_id.index.widen()), |
|
|
|
*constraint); |
|
|
|
} |
|
|
|
ConstrainRegSubVar(_, b_id) => { |
|
|
|
graph.add_edge(dummy_idx, |
|
|
|
NodeIndex(b_id.index as usize), |
|
|
|
NodeIndex(b_id.index.widen()), |
|
|
|
*constraint); |
|
|
|
} |
|
|
|
ConstrainVarSubReg(a_id, _) => { |
|
|
|
graph.add_edge(NodeIndex(a_id.index as usize), |
|
|
|
graph.add_edge(NodeIndex(a_id.index.widen()), |
|
|
|
dummy_idx, |
|
|
|
*constraint); |
|
|
|
} |
|
|
@@ -1418,7 +1418,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
debug!("pushing SubSupConflict sub: {:?} sup: {:?}", |
|
|
|
lower_bound.region, upper_bound.region); |
|
|
|
errors.push(SubSupConflict( |
|
|
|
(*self.var_origins.borrow())[node_idx.index as usize].clone(), |
|
|
|
(*self.var_origins.borrow())[node_idx.index.widen_(0usize)].clone(), |
|
|
|
lower_bound.origin.clone(), |
|
|
|
lower_bound.region, |
|
|
|
upper_bound.origin.clone(), |
|
|
@@ -1429,7 +1429,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
} |
|
|
|
|
|
|
|
self.tcx.sess.span_bug( |
|
|
|
(*self.var_origins.borrow())[node_idx.index as usize].span(), |
|
|
|
(*self.var_origins.borrow())[node_idx.index.widen_(0usize)].span(), |
|
|
|
&format!("collect_error_for_expanding_node() could not find error \ |
|
|
|
for var {:?}, lower_bounds={}, upper_bounds={}", |
|
|
|
node_idx, |
|
|
@@ -1464,7 +1464,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
Ok(_) => {} |
|
|
|
Err(_) => { |
|
|
|
errors.push(SupSupConflict( |
|
|
|
(*self.var_origins.borrow())[node_idx.index as usize].clone(), |
|
|
|
(*self.var_origins.borrow())[node_idx.index.widen_(0usize)].clone(), |
|
|
|
upper_bound_1.origin.clone(), |
|
|
|
upper_bound_1.region, |
|
|
|
upper_bound_2.origin.clone(), |
|
|
@@ -1476,7 +1476,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
} |
|
|
|
|
|
|
|
self.tcx.sess.span_bug( |
|
|
|
(*self.var_origins.borrow())[node_idx.index as usize].span(), |
|
|
|
(*self.var_origins.borrow())[node_idx.index.widen_(0usize)].span(), |
|
|
|
&format!("collect_error_for_contracting_node() could not find error \ |
|
|
|
for var {:?}, upper_bounds={}", |
|
|
|
node_idx, |
|
|
@@ -1510,12 +1510,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
|
|
|
|
while !state.stack.is_empty() { |
|
|
|
let node_idx = state.stack.pop().unwrap(); |
|
|
|
let classification = var_data[node_idx.index as usize].classification; |
|
|
|
let classification = var_data[node_idx.index.widen_(0usize)].classification; |
|
|
|
|
|
|
|
// check whether we've visited this node on some previous walk |
|
|
|
if dup_vec[node_idx.index as usize] == u32::MAX { |
|
|
|
dup_vec[node_idx.index as usize] = orig_node_idx.index; |
|
|
|
} else if dup_vec[node_idx.index as usize] != orig_node_idx.index { |
|
|
|
if dup_vec[node_idx.index.widen_(0usize)] == u32::MAX { |
|
|
|
dup_vec[node_idx.index.widen_(0usize)] = orig_node_idx.index; |
|
|
|
} else if dup_vec[node_idx.index.widen_(0usize)] != orig_node_idx.index { |
|
|
|
state.dup_found = true; |
|
|
|
} |
|
|
|
|
|
|
@@ -1543,7 +1543,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { |
|
|
|
dir: Direction) { |
|
|
|
debug!("process_edges(source_vid={:?}, dir={:?})", source_vid, dir); |
|
|
|
|
|
|
|
let source_node_index = NodeIndex(source_vid.index as usize); |
|
|
|
let source_node_index = NodeIndex(source_vid.index.widen()); |
|
|
|
for (_, edge) in graph.adjacent_edges(source_node_index, dir) { |
|
|
|
match edge.data { |
|
|
|
ConstrainVarSubVar(from_vid, to_vid) => { |
|
|
@@ -1627,7 +1627,7 @@ fn normalize(values: &Vec<VarValue>, r: ty::Region) -> ty::Region { |
|
|
|
} |
|
|
|
|
|
|
|
fn lookup(values: &Vec<VarValue>, rid: ty::RegionVid) -> ty::Region { |
|
|
|
match values[rid.index as usize] { |
|
|
|
match values[rid.index.widen_(0usize)] { |
|
|
|
Value(r) => r, |
|
|
|
NoValue => ReEmpty, // No constraints, return ty::ReEmpty |
|
|
|
ErrorValue => ReStatic, // Previously reported error. |
|
|
|