Add filtering based on involved required lifetime
More accurate filtering still needed.
This commit is contained in:
parent
ab45ab83ac
commit
09dbf37213
3 changed files with 21 additions and 23 deletions
|
@ -156,11 +156,13 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
spans.dedup_by_key(|span| (span.lo(), span.hi()));
|
||||
|
||||
// We try to make the output have fewer overlapping spans if possible.
|
||||
let (require_msg, require_span) = if sup_origin.span().overlaps(return_sp) {
|
||||
("...is captured and required to live as long as `'static` here", sup_origin.span())
|
||||
let require_msg = if spans.is_empty() {
|
||||
"...is captured and required to live as long as `'static` here"
|
||||
} else {
|
||||
("...and is required to live as long as `'static` here", return_sp)
|
||||
"...and is required to live as long as `'static` here"
|
||||
};
|
||||
let require_span =
|
||||
if sup_origin.span().overlaps(return_sp) { sup_origin.span() } else { return_sp };
|
||||
|
||||
for span in &spans {
|
||||
err.span_label(*span, "...is captured here...");
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn resolve<'tcx>(
|
|||
|
||||
values.values.iter_mut().for_each(|v| match *v {
|
||||
VarValue::Value(ref mut r) => *r = re_erased,
|
||||
VarValue::ErrorValue => {}
|
||||
VarValue::ErrorValue(_) => {}
|
||||
});
|
||||
(values, errors)
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub struct LexicalRegionResolutions<'tcx> {
|
|||
#[derive(Copy, Clone, Debug)]
|
||||
enum VarValue<'tcx> {
|
||||
Value(Region<'tcx>),
|
||||
ErrorValue,
|
||||
ErrorValue(RegionVid),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -233,7 +233,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
(None, a_region, b_vid, b_data)
|
||||
}
|
||||
Constraint::VarSubVar(a_vid, b_vid) => match *var_values.value(a_vid) {
|
||||
VarValue::ErrorValue => continue,
|
||||
VarValue::ErrorValue(_) => continue,
|
||||
VarValue::Value(a_region) => {
|
||||
let b_data = var_values.value_mut(b_vid);
|
||||
(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 {
|
||||
match *b_data {
|
||||
VarValue::Value(ReStatic) | VarValue::ErrorValue => (),
|
||||
VarValue::Value(ReStatic) | VarValue::ErrorValue(_) => (),
|
||||
_ => {
|
||||
constraints[a_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() {
|
||||
constraints[vid].retain(|&(a_vid, b_vid)| {
|
||||
let a_region = match *var_values.value(a_vid) {
|
||||
VarValue::ErrorValue => return false,
|
||||
VarValue::ErrorValue(_) => return false,
|
||||
VarValue::Value(a_region) => a_region,
|
||||
};
|
||||
let b_data = var_values.value_mut(b_vid);
|
||||
if self.expand_node(a_region, b_vid, b_data) {
|
||||
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
|
||||
}
|
||||
|
||||
VarValue::ErrorValue => false,
|
||||
VarValue::ErrorValue(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
debug!("contraction: {:?} == {:?}, {:?}", a_vid, a_data, b_region);
|
||||
|
||||
let a_region = match *a_data {
|
||||
VarValue::ErrorValue => continue,
|
||||
VarValue::ErrorValue(_) => continue,
|
||||
VarValue::Value(a_region) => a_region,
|
||||
};
|
||||
|
||||
|
@ -489,7 +489,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
cannot verify that {:?}={:?} <= {:?}",
|
||||
origin, a_vid, a_region, b_region
|
||||
);
|
||||
*a_data = VarValue::ErrorValue;
|
||||
*a_data = VarValue::ErrorValue(a_vid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
for (node_vid, value) in var_data.values.iter_enumerated() {
|
||||
match *value {
|
||||
VarValue::Value(_) => { /* Inference successful */ }
|
||||
VarValue::ErrorValue => {
|
||||
VarValue::ErrorValue(reg) => {
|
||||
// Inference impossible: this value contains
|
||||
// inconsistent constraints.
|
||||
//
|
||||
|
@ -577,9 +577,10 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
.constraints
|
||||
.iter()
|
||||
.filter_map(|(constraint, origin)| match (constraint, origin) {
|
||||
(Constraint::VarSubVar(_, _), SubregionOrigin::DataBorrowed(_, sp)) => {
|
||||
Some(*sp)
|
||||
}
|
||||
(
|
||||
Constraint::VarSubVar(_, sup),
|
||||
SubregionOrigin::DataBorrowed(_, sp),
|
||||
) if sup == ® => Some(*sp),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
|
@ -898,7 +899,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> {
|
|||
pub fn resolve_var(&self, rid: RegionVid) -> ty::Region<'tcx> {
|
||||
let result = match self.values[rid] {
|
||||
VarValue::Value(r) => r,
|
||||
VarValue::ErrorValue => self.error_region,
|
||||
VarValue::ErrorValue(_) => self.error_region,
|
||||
};
|
||||
debug!("resolve_var({:?}) = {:?}", rid, result);
|
||||
result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue