diff options
| author | Esteban Kuber <esteban@kuber.com.ar> | 2021-10-12 09:19:14 +0000 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2021-12-10 03:08:23 +0000 |
| commit | 09dbf37213a5462c08e5e62e931aabc2fb3b92e4 (patch) | |
| tree | 2c8c8c1a39c990cf61f6087900f1b0676de827b9 /compiler/rustc_infer/src/infer | |
| parent | ab45ab83ac0c9b19b6d692ca5d2e9b7b98c3565a (diff) | |
| download | rust-09dbf37213a5462c08e5e62e931aabc2fb3b92e4.tar.gz rust-09dbf37213a5462c08e5e62e931aabc2fb3b92e4.zip | |
Add filtering based on involved required lifetime
More accurate filtering still needed.
Diffstat (limited to 'compiler/rustc_infer/src/infer')
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs | 29 |
2 files changed, 20 insertions, 17 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index e1f2ec44431..daeb406a839 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -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..."); diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index 3d4e96fa0f2..b6c1e1f5922 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -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 |
