Remove field from ErrorValue

This commit is contained in:
Esteban Kuber 2021-11-16 22:58:54 +00:00
parent 9cc7bd7692
commit d33fa135fe

View File

@ -48,7 +48,7 @@ pub fn resolve<'tcx>(
values.values.iter_mut().for_each(|v| match *v { values.values.iter_mut().for_each(|v| match *v {
VarValue::Value(ref mut r) => *r = re_erased, VarValue::Value(ref mut r) => *r = re_erased,
VarValue::ErrorValue(_) => {} VarValue::ErrorValue => {}
}); });
(values, errors) (values, errors)
} }
@ -69,7 +69,7 @@ pub struct LexicalRegionResolutions<'tcx> {
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
enum VarValue<'tcx> { enum VarValue<'tcx> {
Value(Region<'tcx>), Value(Region<'tcx>),
ErrorValue(RegionVid), ErrorValue,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -233,7 +233,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
(None, a_region, b_vid, b_data) (None, a_region, b_vid, b_data)
} }
Constraint::VarSubVar(a_vid, b_vid) => match *var_values.value(a_vid) { Constraint::VarSubVar(a_vid, b_vid) => match *var_values.value(a_vid) {
VarValue::ErrorValue(_) => continue, VarValue::ErrorValue => continue,
VarValue::Value(a_region) => { VarValue::Value(a_region) => {
let b_data = var_values.value_mut(b_vid); let b_data = var_values.value_mut(b_vid);
(Some(a_vid), a_region, b_vid, b_data) (Some(a_vid), a_region, b_vid, b_data)
@ -250,7 +250,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
} }
if let Some(a_vid) = a_vid { if let Some(a_vid) = a_vid {
match *b_data { match *b_data {
VarValue::Value(ReStatic) | VarValue::ErrorValue(_) => (), VarValue::Value(ReStatic) | VarValue::ErrorValue => (),
_ => { _ => {
constraints[a_vid].push((a_vid, b_vid)); constraints[a_vid].push((a_vid, b_vid));
constraints[b_vid].push((a_vid, b_vid)); constraints[b_vid].push((a_vid, b_vid));
@ -262,14 +262,14 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
while let Some(vid) = changes.pop() { while let Some(vid) = changes.pop() {
constraints[vid].retain(|&(a_vid, b_vid)| { constraints[vid].retain(|&(a_vid, b_vid)| {
let a_region = match *var_values.value(a_vid) { let a_region = match *var_values.value(a_vid) {
VarValue::ErrorValue(_) => return false, VarValue::ErrorValue => return false,
VarValue::Value(a_region) => a_region, VarValue::Value(a_region) => a_region,
}; };
let b_data = var_values.value_mut(b_vid); let b_data = var_values.value_mut(b_vid);
if self.expand_node(a_region, b_vid, b_data) { if self.expand_node(a_region, b_vid, b_data) {
changes.push(b_vid); changes.push(b_vid);
} }
!matches!(b_data, VarValue::Value(ReStatic) | VarValue::ErrorValue(_)) !matches!(b_data, VarValue::Value(ReStatic) | VarValue::ErrorValue)
}); });
} }
} }
@ -332,7 +332,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
true true
} }
VarValue::ErrorValue(_) => false, VarValue::ErrorValue => false,
} }
} }
@ -476,7 +476,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
debug!("contraction: {:?} == {:?}, {:?}", a_vid, a_data, b_region); debug!("contraction: {:?} == {:?}, {:?}", a_vid, a_data, b_region);
let a_region = match *a_data { let a_region = match *a_data {
VarValue::ErrorValue(_) => continue, VarValue::ErrorValue => continue,
VarValue::Value(a_region) => a_region, VarValue::Value(a_region) => a_region,
}; };
@ -489,7 +489,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
cannot verify that {:?}={:?} <= {:?}", cannot verify that {:?}={:?} <= {:?}",
origin, a_vid, a_region, b_region origin, a_vid, a_region, b_region
); );
*a_data = VarValue::ErrorValue(a_vid); *a_data = VarValue::ErrorValue;
} }
} }
} }
@ -545,7 +545,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
for (node_vid, value) in var_data.values.iter_enumerated() { for (node_vid, value) in var_data.values.iter_enumerated() {
match *value { match *value {
VarValue::Value(_) => { /* Inference successful */ } VarValue::Value(_) => { /* Inference successful */ }
VarValue::ErrorValue(reg) => { VarValue::ErrorValue => {
// Inference impossible: this value contains // Inference impossible: this value contains
// inconsistent constraints. // inconsistent constraints.
// //
@ -581,7 +581,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
( (
Constraint::VarSubVar(_, sup), Constraint::VarSubVar(_, sup),
SubregionOrigin::DataBorrowed(_, sp), SubregionOrigin::DataBorrowed(_, sp),
) if sup == &reg => Some(*sp), ) if sup == &node_vid => Some(*sp),
_ => None, _ => None,
}) })
.collect(); .collect();
@ -900,7 +900,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> {
pub fn resolve_var(&self, rid: RegionVid) -> ty::Region<'tcx> { pub fn resolve_var(&self, rid: RegionVid) -> ty::Region<'tcx> {
let result = match self.values[rid] { let result = match self.values[rid] {
VarValue::Value(r) => r, VarValue::Value(r) => r,
VarValue::ErrorValue(_) => self.error_region, VarValue::ErrorValue => self.error_region,
}; };
debug!("resolve_var({:?}) = {:?}", rid, result); debug!("resolve_var({:?}) = {:?}", rid, result);
result result