- // If we are not in a context where we can propagate
- // errors, or we could not shrink `fr` to something
- // smaller, then just report an error.
- //
- // Note: in this case, we use the unapproximated regions
- // to report the error. This gives better error messages
- // in some cases.
- self.report_error(mir, infcx, mir_def_id, longer_fr, shorter_fr, errors_buffer);
- return; // continuing to iterate just reports more errors than necessary
+ if let Some(propagated_outlives_requirements) = propagated_outlives_requirements {
+ // Shrink `fr` until we find a non-local region (if we do).
+ // We'll call that `fr-` -- it's ever so slightly smaller than `fr`.
+ if let Some(fr_minus) = self.universal_region_relations
+ .non_local_lower_bound(longer_fr)
+ {
+ debug!("check_universal_region: fr_minus={:?}", fr_minus);
+
+ let blame_span_category = self.find_outlives_blame_span(mir, longer_fr, shorter_fr);
+
+ // Grow `shorter_fr` until we find a non-local
+ // region. (We always will.) We'll call that
+ // `shorter_fr+` -- it's ever so slightly larger than
+ // `fr`.
+ let shorter_fr_plus = self.universal_region_relations
+ .non_local_upper_bound(shorter_fr);
+ debug!(
+ "check_universal_region: shorter_fr_plus={:?}",
+ shorter_fr_plus
+ );
+
+ // Push the constraint `fr-: shorter_fr+`
+ propagated_outlives_requirements.push(ClosureOutlivesRequirement {
+ subject: ClosureOutlivesSubject::Region(fr_minus),
+ outlived_free_region: shorter_fr_plus,
+ blame_span: blame_span_category.1,
+ category: blame_span_category.0,
+ });
+ return None;
+ }