Add an explicit Span field to OutlivesConstraint

Previously, we would retrieve the span from the `Body` using
the `locations` field. However, we may end up changing the
`locations` field when moving a constraint from a promoted
to a different body.

We now store the original `Span` in a dedication field, so that
changes to the `locations` do not affect the quality of our
diagnostics.
This commit is contained in:
Aaron Hill 2022-04-19 20:53:35 -04:00
parent 4ca19e09d3
commit 611a06a375
No known key found for this signature in database
GPG key ID: B4087E510E98B164
16 changed files with 58 additions and 64 deletions

View file

@ -2,6 +2,7 @@ use rustc_data_structures::graph::scc::Sccs;
use rustc_index::vec::IndexVec;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
use rustc_span::Span;
use std::fmt;
use std::ops::Index;
@ -87,6 +88,12 @@ pub struct OutlivesConstraint<'tcx> {
/// Where did this constraint arise?
pub locations: Locations,
/// The `Span` associated with the creation of this constraint.
/// This should be used in preference to obtaining the span from
/// `locations`, since the `locations` may give a poor span
/// in some cases (e.g. converting a constraint from a promoted).
pub span: Span,
/// What caused this constraint?
pub category: ConstraintCategory,